Compare commits

...

80 Commits

Author SHA1 Message Date
Michele Calgaro 089e8b0d41
Use TDE cmake macro to set version
2 years ago
Michele Calgaro d83277738a
Remove obsolete setting of CMAKE_MODULE_PATH in cmake files.
2 years ago
Slávek Banko df4142bb9f
Update version number to the upcoming R14.0.13.
2 years ago
Slávek Banko 5ee2811f13
Raise the minimum required version of CMake to 3.1.
2 years ago
Slávek Banko 16d93ca4af
Update version number to R14.0.12.
3 years ago
Slávek Banko 1cae1ab1f4
Change README to markdown format.
3 years ago
Slávek Banko b62ce69302
Improve processing of multiarch libraries location in scripts.
3 years ago
Slávek Banko b70630a227
Remove cmake submodule since it has now been replaced by cmake-trinity dependency.
3 years ago
TDE Gitea 8b93486afa Reset submodule main/applications/smartcardauth/cmake to latest HEAD
3 years ago
Slávek Banko 67d76df201
Update version number to R14.0.11.
3 years ago
TDE Gitea aebefc3939 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
3 years ago
TDE Gitea ee3fc61310 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
3 years ago
TDE Gitea c39df6573f Reset submodule main/applications/smartcardauth/cmake to latest HEAD
3 years ago
Slávek Banko 561530ae94
Raise the minimum required version of CMake to 2.8.12.
3 years ago
TDE Gitea dac7238931 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
3 years ago
TDE Gitea 5e0e42498c Reset submodule main/applications/smartcardauth/cmake to latest HEAD
3 years ago
Slávek Banko 04588dd3e5
Update version number to R14.0.10.
4 years ago
TDE Gitea cf89a18328 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
gregory guy b6480d1f10
Drop makefile build support.
4 years ago
TDE Gitea 0125973862 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea bc1e5bfa9c Reset submodule main/applications/smartcardauth/admin to latest HEAD
4 years ago
TDE Gitea 3a8eedd73b Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea 0226cdacf2 Reset submodule main/applications/smartcardauth/admin to latest HEAD
4 years ago
TDE Gitea 1358e5e655 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea e267c95bc5 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea 78a876c9a6 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea 2f9c2448d9 Reset submodule main/applications/smartcardauth/admin to latest HEAD
4 years ago
TDE Gitea b80b475014 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea 7984812759 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea 0ac0e30669 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea 5803d2e083 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea 8e0b8b6d98 Reset submodule main/applications/smartcardauth/admin to latest HEAD
4 years ago
TDE Gitea ac38419b88 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea 9102339c0b Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
Michele Calgaro 2d31f6a7bd
Update release version number to R14.0.9.
4 years ago
TDE Gitea 9fcfcc3b6b Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea 93f77cc950 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea f0c355bcd7 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea 1a7d0538a7 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
Slávek Banko 8661c0af8d
Update version number for R14.0.8 final release.
4 years ago
TDE Gitea 467325c982 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea 1073602a2e Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea fda63d846d Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
TDE Gitea fe14893560 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
4 years ago
Slávek Banko 422b8fb8fc
Switch all submodules to https.
4 years ago
Slávek Banko fa96f7798a
Prevent a large number of TQString => char* => TQString conversions.
5 years ago
Slávek Banko c1af0d2417
Conversion to the cmake building system.
5 years ago
TDE Gitea bf76e158be Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea 955bb047ca Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea 6a52e97223 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea 69a741f5bc Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea 67d8bda738 Reset submodule main/applications/smartcardauth/admin to latest HEAD
5 years ago
TDE Gitea 8ce2944b6b Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea ee11d0b489 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea adcd723432 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea 5b98190d6c Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea 117dfc9518 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea ce898d8e87 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea 6fa5a3112a Reset submodule main/applications/smartcardauth/admin to latest HEAD
5 years ago
TDE Gitea b94ccac2a9 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea 87bf3ff86b Reset submodule main/applications/smartcardauth/cmake to latest HEAD
5 years ago
TDE Gitea ab2060c569 Reset submodule main/applications/smartcardauth/admin to latest HEAD
6 years ago
François Andriot c7f43fb017 Fixed failed rpmlint check on opensuse Leap 15.0
6 years ago
Slávek Banko 13eccac998 Reset submodule main/applications/smartcardauth/admin to latest HEAD
6 years ago
Slávek Banko 7446cb9269 Reset submodule main/applications/smartcardauth/admin to latest HEAD
6 years ago
Slávek Banko 31a67a56f6 Reset submodule main/applications/smartcardauth/admin to latest HEAD
6 years ago
Slávek Banko b12ff72d81 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
7 years ago
Slávek Banko 76bec2a640 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
7 years ago
Slávek Banko d8d505e991 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
7 years ago
Slávek Banko d3ed6f51fa Reset submodule main/applications/smartcardauth/cmake to latest HEAD
7 years ago
Slávek Banko 53eb4e19eb Reset submodule main/applications/smartcardauth/admin to latest HEAD
7 years ago
Slávek Banko e6e29abd1c cmake: add tde_add_check_executable macro
7 years ago
Slávek Banko 56905d3c0f Reset submodule main/applications/smartcardauth/admin to latest HEAD
8 years ago
Slávek Banko 87fee4c335 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
8 years ago
Slávek Banko 5fbe1686f7 Reset submodule main/applications/smartcardauth/cmake to latest HEAD
8 years ago
Slávek Banko d057953830 Fix function prototypes
9 years ago
Timothy Pearson bb1740cd73 Fix initramfs hooks on Debian Jessie
9 years ago
Slávek Banko c83d53af1f Reset submodule main/applications/smartcardauth/cmake to latest HEAD
9 years ago
Slávek Banko a21c5aeb9b Reset submodule main/applications/smartcardauth/cmake to latest HEAD
9 years ago
Slávek Banko 7d5cfd8691 Reset submodule main/applications/smartcardauth/admin to latest HEAD
9 years ago

6
.gitmodules vendored

@ -1,6 +0,0 @@
[submodule "admin"]
path = admin
url = http://scm.trinitydesktop.org/scm/git/tde-common-admin
[submodule "cmake"]
path = cmake
url = http://scm.trinitydesktop.org/scm/git/tde-common-cmake

@ -0,0 +1,124 @@
############################################
# #
# Improvements and feedbacks are welcome #
# #
# This file is released under GPL >= 3 #
# #
############################################
cmake_minimum_required( VERSION 3.1 )
#### general package setup
project( smartcardauth )
#### include essential cmake modules
include( FindPkgConfig )
include( CheckFunctionExists )
include( CheckSymbolExists )
include( CheckIncludeFile )
include( CheckLibraryExists )
include( CheckCSourceCompiles )
#### include our cmake modules
include( TDEMacros )
##### set version number ########################
tde_set_project_version( )
##### setup install paths
include( TDESetupPaths )
tde_setup_paths( )
##### optional stuff
option( WITH_ALL_OPTIONS "Enable all optional support" OFF )
option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} )
##### configure checks
include( ConfigureChecks.cmake )
###### global compiler settings
add_definitions( -DHAVE_CONFIG_H )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" )
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" )
set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" )
##### directories
add_subdirectory( src )
##### write configure files
configure_file( config.h.cmake config.h @ONLY )
##### scriptor_standalone (executable)
file( READ scriptor_standalone.pl SCRIPTOR )
string( REPLACE "scriptor" "scriptor_standalone" SCRIPTOR_STANDALONE "${SCRIPTOR}" )
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone.pl "${SCRIPTOR_STANDALONE}" )
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone
COMMAND ${PERL_PAR_PACKER}
-a ${PERL_LIB_CHIPCARD}
-o ${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone
${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone.pl
COMMENT "Build scriptor_standalone"
)
add_custom_target( scriptor_standalone-binary ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone
)
install(
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/scriptor_standalone
DESTINATION ${BIN_INSTALL_DIR}
)
##### other data
install(
DIRECTORY etc/
DESTINATION ${SYSCONF_INSTALL_DIR}
)
file( GLOB SCRIPTS usr/bin/* )
install(
PROGRAMS ${SCRIPTS}
DESTINATION ${BIN_INSTALL_DIR}
)
file( GLOB INITRAMFS_HOOKS usr/share/initramfs-tools/hooks/* )
install(
PROGRAMS ${INITRAMFS_HOOKS}
DESTINATION ${SHARE_INSTALL_PREFIX}/initramfs-tools/hooks
)
install(
DIRECTORY
usr/share/applications
usr/share/icons
DESTINATION ${SHARE_INSTALL_PREFIX}
)

@ -0,0 +1,113 @@
###########################################
# #
# Improvements and feedback are welcome #
# #
# This file is released under GPL >= 3 #
# #
###########################################
# required stuff
find_package( TQt )
tde_setup_architecture_flags( )
include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)
tde_setup_largefiles( )
##### check for gcc visibility support
if( WITH_GCC_VISIBILITY )
tde_setup_gcc_visibility( )
endif( WITH_GCC_VISIBILITY )
##### check for TDE binary directory
if( NOT DEFINED TDE_PREFIX AND IS_DIRECTORY /opt/trinity )
set( TDE_PREFIX "/opt/trinity" )
else( )
set( TDE_PREFIX "/usr" )
endif( )
if( NOT DEFINED KDECONFIG_EXECUTABLE )
find_program( KDECONFIG_EXECUTABLE
NAMES tde-config
HINTS "${TDE_PREFIX}/bin" ${BIN_INSTALL_DIR} )
if( NOT KDECONFIG_EXECUTABLE )
tde_message_fatal( "tde-config are NOT found." )
endif( NOT KDECONFIG_EXECUTABLE )
endif( NOT DEFINED KDECONFIG_EXECUTABLE )
if( NOT DEFINED TRINITY_BIN_PREFIX )
execute_process(
COMMAND ${KDECONFIG_EXECUTABLE} --install exe
OUTPUT_VARIABLE TDE_BIN_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set( TRINITY_BIN_PREFIX "${TDE_BIN_DIR}" CACHE PATH "" )
message( STATUS "Found TDE binaries: ${TRINITY_BIN_PREFIX}" )
endif( )
##### check for Perl
find_package( PerlLibs )
if( NOT PERLLIBS_FOUND )
tde_message_fatal( "Perl is required but not found on your system." )
endif( )
if( NOT DEFINED PERL_PAR_PACKER )
find_program( PERL_PAR_PACKER pp )
if( NOT PERL_PAR_PACKER )
tde_message_fatal( "Perl PAR packer (pp binary) is required but not found on your system." )
else( )
message( STATUS "Found Perl PAR packer: ${PERL_PAR_PACKER}" )
endif( )
endif( )
if( NOT DEFINED PERL_LIB_CHIPCARD )
find_path( PERL_DIR_CHIPCARD Chipcard
HINTS
${PERL_SITELIB}
${PERL_VENDORARCH}
${PERL_VENDORLIB}
${PERL_ARCHLIB}
${PERL_PRIVLIB}
)
if( NOT PERL_DIR_CHIPCARD )
tde_message_fatal( "libpcsc for perl is required but not found on your system." )
endif( )
set( PERL_LIB_CHIPCARD "${PERL_DIR_CHIPCARD}/Chipcard" CACHE PATH "" )
message( STATUS "Found PCSC-perl: ${PERL_LIB_CHIPCARD}" )
endif( )
##### check for crypt
set( CRYPT_LIBRARY crypt )
check_library_exists( ${CRYPT_LIBRARY} crypt "" HAVE_CRYPT )
if( NOT HAVE_CRYPT )
unset( CRYPT_LIBRARY )
check_function_exists( crypt LIBC_HAVE_CRYPT )
if( LIBC_HAVE_CRYPT )
set( HAVE_CRYPT 1 CACHE INTERNAL "" FORCE )
endif( LIBC_HAVE_CRYPT )
endif( NOT HAVE_CRYPT )
##### check for pam
if( NOT DEFINED PAM_FOUND )
find_path( PAM_INCLUDE_DIR NAMES security/pam_appl.h )
find_library( PAM_LIBRARY pam )
if( PAM_INCLUDE_DIR AND PAM_LIBRARY )
set( PAM_FOUND 1 CACHE BOOL "" )
set( PAM_LIBRARIES ${PAM_LIBRARY} ${CMAKE_DL_LIBS} CACHE INTERNAL "" )
message( STATUS "Found pam: ${PAM_LIBRARY}" )
else( )
tde_message_fatal( "pam is required but not found on your system." )
endif( )
endif( )

@ -0,0 +1,23 @@
Basic Installation
==================
smartcardauth relies on cmake to build.
Here are suggested default options:
-DCMAKE_INSTALL_PREFIX="/usr" \
-DCONFIG_INSTALL_DIR="/etc/trinity" \
-DSYSCONF_INSTALL_DIR="/etc" \
-DXDG_MENU_INSTALL_DIR="/etc/xdg/menus" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_VERBOSE_MAKEFILE="ON" \
-DCMAKE_SKIP_RPATH="OFF" \
-DWITH_ALL_OPTIONS="ON"
Requirements:
=============
- gnutls
- openssl
- libpkcs11-helper

@ -1,22 +0,0 @@
FPACKAGE = smartcardauth
VERSION = 1.0
build:
clean:
install:
sed -i "s#scriptor#scriptor_standalone#g" scriptor_standalone.pl
/usr/bin/pp -a /usr/lib/perl5/Chipcard -a /usr/lib/perl5/Chipcard -o scriptor_standalone scriptor_standalone.pl
rm scriptor_standalone.pl
mv scriptor_standalone usr/bin/scriptor_standalone
./build_ckpasswd
mkdir -p $(DESTDIR)/usr
cp -Rp src/ckpasswd usr/bin/smartauthckpasswd
cp -Rp src/smartauthmon usr/bin/smartauthmon
cp -Rp usr/* $(DESTDIR)/usr/
mkdir -p $(DESTDIR)/etc
cp -Rp etc/* $(DESTDIR)/etc/

@ -0,0 +1,30 @@
smartcardauth - a SmartCard Login and LUKS Decrypt Setup Utility for TDE.
Smartcardauth will allow you to set up your computer to accept a
SmartCard as an authentication source. It is designed to work with any
OpenSC-supported, ISO 7816-4,-8 compliant, PKCS#11 enabled smartcard.
Examples of such cards are:
- The OpenPGP card (ISO ISO 7816-4,-8 compliant)
Features:
---------
* support encrypted LUKS partition
* automatic login, lock, and unlock
.
Contributing
--------------
If you wish to contribute to smartcardauth, you might do so:
- TDE Gitea Workspace (TGW) collaboration tool.
https://mirror.git.trinitydesktop.org/gitea
- TDE Weblate Translation Workspace (TWTW) collaboration tool.
https://mirror.git.trinitydesktop.org/weblate

@ -1 +0,0 @@
Subproject commit 04db460623e1f235e7239f08fdcc2d0ef72636af

@ -1,5 +0,0 @@
#!/bin/bash
cd src/
make
cd ..

@ -1 +0,0 @@
Subproject commit 1994b808819fd74446cb8f1a0491b3e10244f463

@ -0,0 +1,11 @@
#define VERSION "@VERSION@"
// Defined if you have fvisibility and fvisibility-inlines-hidden support.
#cmakedefine __KDE_HAVE_GCC_VISIBILITY 1
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
/* Define path to Trinity binaries */
#cmakedefine TRINITY_BIN_PREFIX "@TRINITY_BIN_PREFIX@/"

@ -0,0 +1,43 @@
include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
link_directories(
${TQT_LIBRARY_DIRS}
)
##### smartauthckpasswd (executable)
tde_add_executable( smartauthckpasswd
SOURCES
ckpasswd.c
xmalloc.c
messages.c
LINK
${CRYPT_LIBRARY}
${PAM_LIBRARIES}
DESTINATION ${BIN_INSTALL_DIR}
)
##### smartauthmon (executable)
tde_add_executable( smartauthmon
SOURCES
smartauthmon.cpp
ckpass.c
xmalloc.c
messages.c
LINK
${CRYPT_LIBRARY}
${PAM_LIBRARIES}
${TQT_LIBRARIES}
DESTINATION ${BIN_INSTALL_DIR}
)

@ -1,25 +0,0 @@
all: ckpasswd.o xmalloc.o messages.o ckpass.o ckpasswd smartauthmon
ckpass.o: ckpass.c
gcc ckpass.c -c
ckpasswd.o: ckpasswd.c
gcc ckpasswd.c -c
xmalloc.o: xmalloc.c
gcc xmalloc.c -c
messages.o: messages.c
gcc messages.c -c
smartauthmon.o: smartauthmon.cpp
g++ -I/usr/include/tqt -I/usr/include/qt3 -I/usr/include/tqt3 smartauthmon.cpp -c
ckpasswd: ckpasswd.o
gcc ckpasswd.o xmalloc.o messages.o -o ckpasswd -lpam -lcrypt
smartauthmon: smartauthmon.o ckpass.o
gcc smartauthmon.o ckpass.o xmalloc.o messages.o -o smartauthmon -ltqt -lpam -lcrypt -ltqt-mt -lstdc++
clean:
rm -f ckpasswd.o xmalloc.o messages.o ckpasswd

@ -42,14 +42,8 @@
# define OPT_SHADOW ""
#endif
/* The functions are actually macros so that we can pick up the file and line
number information for debugging error messages without the user having to
pass those in every time. */
#define xcalloc(n, size) x_calloc((n), (size), __FILE__, __LINE__)
#define xmalloc(size) x_malloc((size), __FILE__, __LINE__)
#define xrealloc(p, size) x_realloc((p), (size), __FILE__, __LINE__)
#define xstrdup(p) x_strdup((p), __FILE__, __LINE__)
#define xstrndup(p, size) x_strndup((p), (size), __FILE__, __LINE__)
#include "messages.h"
#include "xmalloc.h"
#include <security/pam_appl.h>

@ -43,14 +43,8 @@
# define OPT_SHADOW ""
#endif
/* The functions are actually macros so that we can pick up the file and line
number information for debugging error messages without the user having to
pass those in every time. */
#define xcalloc(n, size) x_calloc((n), (size), __FILE__, __LINE__)
#define xmalloc(size) x_malloc((size), __FILE__, __LINE__)
#define xrealloc(p, size) x_realloc((p), (size), __FILE__, __LINE__)
#define xstrdup(p) x_strdup((p), __FILE__, __LINE__)
#define xstrndup(p, size) x_strndup((p), (size), __FILE__, __LINE__)
#include "messages.h"
#include "xmalloc.h"
#include <security/pam_appl.h>

@ -82,14 +82,7 @@
#include <pwd.h>
#include <grp.h>
/* The functions are actually macros so that we can pick up the file and line
number information for debugging error messages without the user having to
pass those in every time. */
#define xcalloc(n, size) x_calloc((n), (size), __FILE__, __LINE__)
#define xmalloc(size) x_malloc((size), __FILE__, __LINE__)
#define xrealloc(p, size) x_realloc((p), (size), __FILE__, __LINE__)
#define xstrdup(p) x_strdup((p), __FILE__, __LINE__)
#define xstrndup(p, size) x_strndup((p), (size), __FILE__, __LINE__)
#include "xmalloc.h"
/* These are the currently-supported types of traces. */
enum message_trace {

@ -0,0 +1,18 @@
/* $Id: messages.h $
*
* Message and error reporting (possibly fatal).
*
*/
#if !defined(_MESSAGES_H)
#define _MESSAGES_H
/* The reporting functions. The ones prefaced by "sys" add a colon, a space,
and the results of strerror(errno) to the output and are intended for
reporting failures of system calls. */
extern void die(const char *, ...)
__attribute__((__noreturn__, __format__(printf, 1, 2)));
extern void sysdie(const char *, ...)
__attribute__((__noreturn__, __format__(printf, 1, 2)));
#endif /* _MESSAGES_H */

@ -14,6 +14,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define _XOPEN_SOURCE 500
#include <stdio.h>
#include <stdlib.h>
@ -42,7 +46,9 @@
#define SECURE_DIRECTORY_PATH "/tmp/smartauth"
// The Trinity binary directory
#ifndef TRINTIY_BIN_PREFIX
#define TRINITY_BIN_PREFIX "/opt/trinity/bin/"
#endif
// Some internal constants
#define CREATE_LIFE_CYCLE "01"
@ -83,13 +89,13 @@ void handle_sigpipe(int sig)
}
}
TQString readfile(const char * filename) {
TQString readfile(const TQString filename) {
FILE *fp;
long len;
char *buf;
fp=fopen(filename, "rb");
fp=fopen(filename.local8Bit(), "rb");
if (fp == NULL) {
printf("[WARNING] Unable to read from file %s\n", filename); fflush(stdout);
printf("[WARNING] Unable to read from file %s\n", filename.local8Bit().data()); fflush(stdout);
return TQString();
}
fseek(fp,0,SEEK_END); // Seek to end
@ -104,13 +110,13 @@ TQString readfile(const char * filename) {
return contents;
}
int writefile(const char * filename, TQString contents) {
int writefile(const TQString filename, TQString contents) {
int fp;
long len;
char *buf;
fp=open(filename, O_WRONLY | O_NONBLOCK);
fp=open(filename.local8Bit(), O_WRONLY | O_NONBLOCK);
if (fp < 0) {
printf("[WARNING] Unable to open file %s for writing\n", filename); fflush(stdout);
printf("[WARNING] Unable to open file %s for writing\n", filename.local8Bit().data()); fflush(stdout);
return -1;
}
int retcode = write(fp, contents.ascii(), contents.length());
@ -118,11 +124,11 @@ int writefile(const char * filename, TQString contents) {
return retcode;
}
TQString exec(const char * cmd) {
TQString exec(const TQString cmd) {
TQString bashcommand = cmd;
bashcommand = bashcommand.replace("\"", "\\\"");
bashcommand = TQString("/bin/bash -c \"%1\"").arg(bashcommand);
FILE* pipe = popen(bashcommand.ascii(), "r");
FILE* pipe = popen(bashcommand.local8Bit(), "r");
if (!pipe) return "ERROR";
char buffer[128];
TQString result = "";
@ -136,18 +142,18 @@ TQString exec(const char * cmd) {
return result;
}
int systemexec(const char * cmd) {
int systemexec(const TQString cmd) {
TQString bashcommand = cmd;
bashcommand = bashcommand.replace("\"", "\\\"");
bashcommand = TQString("/bin/bash -c \"%1\"").arg(bashcommand);
return system(bashcommand.ascii()) >> 8;
return system(bashcommand.local8Bit()) >> 8;
}
TQString execret(const char * cmd, int * retcode) {
TQString execret(const TQString cmd, int * retcode) {
TQString bashcommand = cmd;
bashcommand = bashcommand.replace("\"", "\\\"");
bashcommand = TQString("/bin/bash -c \"%1\"").arg(bashcommand);
FILE* pipe = popen(bashcommand.ascii(), "r");
FILE* pipe = popen(bashcommand.local8Bit(), "r");
if (!pipe) return "ERROR";
char buffer[128];
TQString result = "";
@ -179,45 +185,45 @@ int rmrf(const char *path)
TQString get_file(TQString prefix, TQString mode) {
if (command_mode == "acos") {
// Select EF prefix under DF 1000
systemexec((TQString("echo \"%1 %2\" > %3/query").arg(select_file).arg(prefix).arg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory)).ascii());
// printf("[DEBUG 100.0] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout);
systemexec(TQString("echo \"%1 %2\" > %3/query").arg(select_file).arg(prefix).arg(secure_directory));
systemexec(TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory));
// printf("[DEBUG 100.0] %s\n", readfile(TQString("%1/response2").arg(secure_directory)).local8Bit().data()); fflush(stdout);
// Read binary
systemexec((TQString("echo \"%1\" > %2/query").arg(read_binary).arg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory)).ascii());
systemexec(TQString("echo \"%1\" > %2/query").arg(read_binary).arg(secure_directory));
systemexec(TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory));
TQString authokresponse="90 00 : Normal processing";
TQString response1 = exec((TQString("cat %1/response2 | grep \"%2\"").arg(secure_directory).arg(authokresponse)).ascii());
TQString response1 = exec(TQString("cat %1/response2 | grep \"%2\"").arg(secure_directory).arg(authokresponse));
if (response1 != "") {
systemexec((TQString("cat %1/response2 | tr -d '\n' > %2/response4").arg(secure_directory).arg(secure_directory)).ascii());
systemexec(TQString("cat %1/response2 | tr -d '\n' > %2/response4").arg(secure_directory).arg(secure_directory));
TQString stringtoreplace="Using T=0 protocol00 B0 00 00 FF> 00 B0 00 00 FF< ";
TQString newstring="";
systemexec((TQString("sed -i \"s#%1#%2#g\" %3/response4").arg(stringtoreplace).arg(newstring).arg(secure_directory)).ascii());
systemexec(TQString("sed -i \"s#%1#%2#g\" %3/response4").arg(stringtoreplace).arg(newstring).arg(secure_directory));
stringtoreplace=" 90 00 : Normal processing.";
newstring="";
systemexec((TQString("sed -i \"s#%1#%2#g\" %3/response4").arg(stringtoreplace).arg(newstring).arg(secure_directory)).ascii());
systemexec(TQString("sed -i \"s#%1#%2#g\" %3/response4").arg(stringtoreplace).arg(newstring).arg(secure_directory));
if (mode == "text") {
stringtoreplace=" 00";
newstring="";
systemexec((TQString("sed -i \"s#%1#%2#g\" %3/response4").arg(stringtoreplace).arg(newstring).arg(secure_directory)).ascii());
systemexec(TQString("sed -i \"s#%1#%2#g\" %3/response4").arg(stringtoreplace).arg(newstring).arg(secure_directory));
}
// printf("[DEBUG 100.1] %s\n", readfile((TQString("%1/response4").arg(secure_directory))).ascii()); fflush(stdout);
unlink((TQString("%1/lukskey").arg(secure_directory)).ascii());
systemexec((TQString("xxd -r -p %1/response4 %2/lukskey").arg(secure_directory).arg(secure_directory)).ascii());
// printf("[DEBUG 100.1] %s\n", readfile(TQString("%1/response4").arg(secure_directory)).local8Bit().data()); fflush(stdout);
unlink((TQString("%1/lukskey").arg(secure_directory)).local8Bit());
systemexec(TQString("xxd -r -p %1/response4 %2/lukskey").arg(secure_directory).arg(secure_directory));
return(TQString("%1/lukskey").arg(secure_directory));
}
}
if (command_mode == "cryptoflex") {
TQString file = TQString(prefix).replace(' ', "");
unlink((TQString("3F00_%1").arg(file)).ascii());
// systemexec((TQString("echo \"get %1\" | opensc-explorer").arg(file)).ascii());
fputs((TQString("get %1\n").arg(file)).ascii(), opensc_explorer_file);
unlink((TQString("3F00_%1").arg(file)).local8Bit());
// systemexec(TQString("echo \"get %1\" | opensc-explorer").arg(file));
fputs((TQString("get %1\n").arg(file)).local8Bit(), opensc_explorer_file);
fflush(opensc_explorer_file);
int j;
// Wait up to 2 seconds for the file to be written
for (j=0;j<200;j++) {
FILE* fp1 = fopen((TQString("3F00_%1").arg(file)).ascii(), "r");
FILE* fp1 = fopen((TQString("3F00_%1").arg(file)).local8Bit(), "r");
if (fp1) {
// file exists
fclose(fp1);
@ -228,6 +234,8 @@ TQString get_file(TQString prefix, TQString mode) {
usleep(100000); // [FIXME] Here I assume that the entire file will be written (after it was created) within 100us. This may not be correct in all cases!
return TQString("3F00_%1").arg(file);
}
return TQString("");
}
void createfile(TQString prefix, TQString mode)
@ -235,8 +243,8 @@ void createfile(TQString prefix, TQString mode)
if (command_mode == "cryptoflex") {
// Create transparent file with permissions:
// delete, terminate, activate, deactivate, update, read for Key 1 and Key 2 only
systemexec((TQString("echo \"F0 E0 00 FF 10 FF FF 00 %1 %2 01 3F 44 FF 44 01 03 11 FF 11\" > %3/query").arg(prefix).arg(mode).arg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/query 1> %2/response2 2>/dev/null").arg(secure_directory).arg(secure_directory)).ascii());
systemexec(TQString("echo \"F0 E0 00 FF 10 FF FF 00 %1 %2 01 3F 44 FF 44 01 03 11 FF 11\" > %3/query").arg(prefix).arg(mode).arg(secure_directory));
systemexec(TQString("scriptor %1/query 1> %2/response2 2>/dev/null").arg(secure_directory).arg(secure_directory));
}
if (command_mode == "acos") {
@ -245,43 +253,43 @@ void createfile(TQString prefix, TQString mode)
// created in DF 1000 under MF, SE file is 10FE
// SIZE TRANSPARENT
systemexec((TQString("echo \"00 E0 00 00 1A 62 18 80 02 00 %1 82 01 01 83 02 %2 8A 01 %3 8C 08 7F 04 04 04 04 04 04 04\" > %4/query").arg(prefix).arg(mode).arg(CREATE_LIFE_CYCLE).arg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/query 1> %2/response2 2>/dev/null").arg(secure_directory)).ascii());
printf("[DEBUG 300.0] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout);
systemexec(TQString("echo \"00 E0 00 00 1A 62 18 80 02 00 %1 82 01 01 83 02 %2 8A 01 %3 8C 08 7F 04 04 04 04 04 04 04\" > %4/query").arg(prefix).arg(mode).arg(CREATE_LIFE_CYCLE).arg(secure_directory));
systemexec(TQString("scriptor %1/query 1> %2/response2 2>/dev/null").arg(secure_directory));
printf("[DEBUG 300.0] %s\n", readfile(TQString("%1/response2").arg(secure_directory)).local8Bit().data()); fflush(stdout);
}
}
void update_file(TQString prefix, TQString mode) {
if (command_mode == "acos") {
// Select EF prefix under DF 1000
systemexec((TQString("echo \"$SELECT_FILE %1\" > %2/query").arg(prefix).arg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory)).ascii());
printf("[DEBUG 200.0] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout);
systemexec(TQString("echo \"$SELECT_FILE %1\" > %2/query").arg(prefix).arg(secure_directory));
systemexec(TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory));
printf("[DEBUG 200.0] %s\n", readfile(TQString("%1/response2").arg(secure_directory)).local8Bit().data()); fflush(stdout);
// Update existing file
// Zero pad input file
systemexec((TQString("dd if=/dev/zero of=%1/response2 bs=1 count=255 2>/dev/null 1>/dev/null").arg(secure_directory)).ascii());
systemexec((TQString("dd if=%1 of=%2/response2 bs=1 count=255 conv=notrunc 2>/dev/null 1>/dev/null").arg(mode).arg(secure_directory)).ascii());
systemexec(TQString("dd if=/dev/zero of=%1/response2 bs=1 count=255 2>/dev/null 1>/dev/null").arg(secure_directory));
systemexec(TQString("dd if=%1 of=%2/response2 bs=1 count=255 conv=notrunc 2>/dev/null 1>/dev/null").arg(mode).arg(secure_directory));
// Truncate to 255 bytes and expand to standard hex listing format
systemexec((TQString("xxd -l 255 -ps -c 1 %1/response2 > %2/response").arg(secure_directory).arg(secure_directory)).ascii());
systemexec((TQString("cat %1/response | tr '\n' ' ' > %1/hexready").arg(secure_directory)).ascii());
TQString hexready = readfile((TQString("%1/hexready").arg(secure_directory)).ascii());
systemexec((TQString("echo \"%1 %2\" > %3/query").arg(update_binary).arg(hexready).arg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/query 1> %2/response2 2>/dev/null").arg(secure_directory).arg(secure_directory)).ascii());
printf("[DEBUG 200.1] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout);
systemexec(TQString("xxd -l 255 -ps -c 1 %1/response2 > %2/response").arg(secure_directory).arg(secure_directory));
systemexec(TQString("cat %1/response | tr '\n' ' ' > %1/hexready").arg(secure_directory));
TQString hexready = readfile(TQString("%1/hexready").arg(secure_directory));
systemexec(TQString("echo \"%1 %2\" > %3/query").arg(update_binary).arg(hexready).arg(secure_directory));
systemexec(TQString("scriptor %1/query 1> %2/response2 2>/dev/null").arg(secure_directory).arg(secure_directory));
printf("[DEBUG 200.1] %s\n", readfile(TQString("%1/response2").arg(secure_directory)).local8Bit().data()); fflush(stdout);
}
if (command_mode == "cryptoflex") {
// Delete old file
systemexec((TQString("echo \"%1 $1\" > %2/query").arg(delete_file).arg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/query 1> %2/response2 2>/dev/null").arg(secure_directory).arg(secure_directory)).ascii());
printf("[DEBUG 200.2] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout);
systemexec(TQString("echo \"%1 $1\" > %2/query").arg(delete_file).arg(secure_directory));
systemexec(TQString("scriptor %1/query 1> %2/response2 2>/dev/null").arg(secure_directory).arg(secure_directory));
printf("[DEBUG 200.2] %s\n", readfile(TQString("%1/response2").arg(secure_directory)).local8Bit().data()); fflush(stdout);
// Create new file
createfile("FF", prefix);
TQString file = TQString(prefix).replace(' ', "");
systemexec((TQString("echo \"put %1 %2\" | opensc-explorer").arg(file).arg(mode)).ascii());
systemexec(TQString("echo \"put %1 %2\" | opensc-explorer").arg(file).arg(mode));
}
}
@ -315,16 +323,16 @@ int main (int argc, char *argv[])
// Create the secure directory and lock it down
secure_directory = SECURE_DIRECTORY_PATH;
rmrf(secure_directory.ascii());
mkdir(secure_directory.ascii(), 600);
chown(secure_directory.ascii(), 0, 0);
chmod(secure_directory.ascii(), 600);
secure_directory=exec("mktemp " SECURE_DIRECTORY_PATH "/smartauthmon.XXXXXXXXXX");
rmrf(secure_directory.local8Bit());
mkdir(secure_directory.local8Bit(), 600);
chown(secure_directory.local8Bit(), 0, 0);
chmod(secure_directory.local8Bit(), 600);
secure_directory=exec(TQString("mktemp %1/smartauthmon.XXXXXXXXXX").arg(SECURE_DIRECTORY_PATH));
secure_directory.replace('\n', "");
rmrf(secure_directory.ascii());
mkdir(secure_directory.ascii(), 600);
chown(secure_directory.ascii(), 0, 0);
chmod(secure_directory.ascii(), 600);
rmrf(secure_directory.local8Bit());
mkdir(secure_directory.local8Bit(), 600);
chown(secure_directory.local8Bit(), 0, 0);
chmod(secure_directory.local8Bit(), 600);
// Terminate old pcscd process from initrd
system("killall -9 pcscd");
@ -365,17 +373,17 @@ int main (int argc, char *argv[])
systemexec("echo \"TAuthenticating SmartCard...\" > /tmp/tdesocket-global/kdesktoplockcontrol &");
// Get card ATR
systemexec((TQString("echo \"RESET\" > %1/query").arg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory)).ascii());
systemexec(TQString("echo \"RESET\" > %1/query").arg(secure_directory));
systemexec(TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory));
TQString authokresponse="OK: ";
TQString response1 = exec((TQString("cat %1/response2 | grep \"%2\"").arg(secure_directory).arg(authokresponse)).ascii());
TQString response1 = exec(TQString("cat %1/response2 | grep \"%2\"").arg(secure_directory).arg(authokresponse));
if (response1 != "") {
systemexec((TQString("cat %1/response2 | tr -d '\n' > %2/response4").arg(secure_directory).arg(secure_directory)).ascii());
systemexec(TQString("cat %1/response2 | tr -d '\n' > %2/response4").arg(secure_directory).arg(secure_directory));
TQString stringtoreplace="Using T=0 protocolRESET> RESET< OK: ";
TQString newstring="";
systemexec((TQString("sed -i \"s#%1#%2#g\" %3/response4").arg(stringtoreplace).arg(newstring).arg(secure_directory)).ascii());
TQString smartatr = readfile((TQString("%1/response4").arg(secure_directory)).ascii());
printf("[DEBUG 400.2] Got ATR: %s\n", smartatr.ascii()); fflush(stdout);
systemexec(TQString("sed -i \"s#%1#%2#g\" %3/response4").arg(stringtoreplace).arg(newstring).arg(secure_directory));
TQString smartatr = readfile(TQString("%1/response4").arg(secure_directory));
printf("[DEBUG 400.2] Got ATR: %s\n", smartatr.local8Bit().data()); fflush(stdout);
if (smartatr == "3B BE 18 00 00 41 05 10 00 00 00 00 00 00 00 00 00 90 00 ") {
printf("[DEBUG 400.3] Detected ACOS5 card\n"); fflush(stdout);
command_mode="acos";
@ -410,60 +418,60 @@ int main (int argc, char *argv[])
if (command_mode == "acos") {
// Select MF
systemexec((TQString("echo \"00 A4 00 00 00\" > %1/query").arg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory)).ascii());
printf("[DEBUG 400.4] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout);
systemexec(TQString("echo \"00 A4 00 00 00\" > %1/query").arg(secure_directory));
systemexec(TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory));
printf("[DEBUG 400.4] %s\n", readfile(TQString("%1/response2").arg(secure_directory)).local8Bit().data()); fflush(stdout);
// Select DF 1000 under MF
systemexec((TQString("echo \"%1 10 00\" > %2/query").arg(select_file).arg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory)).ascii());
printf("[DEBUG 400.5] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout);
systemexec(TQString("echo \"%1 10 00\" > %2/query").arg(select_file).arg(secure_directory));
systemexec(TQString("scriptor %1/query 1> %2/response2").arg(secure_directory).arg(secure_directory));
printf("[DEBUG 400.5] %s\n", readfile(TQString("%1/response2").arg(secure_directory)).local8Bit().data()); fflush(stdout);
}
systemexec((TQString("echo %1 > %2/authscript").arg(get_challenge).arg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/authscript | grep 'Normal processing' > %2/challenge").arg(secure_directory).arg(secure_directory)).ascii());
systemexec((TQString("perl -pi -e 's/ //g' %1/challenge").arg(secure_directory)).ascii());
systemexec((TQString("perl -pi -e 's/:Normalprocessing.//g' %1/challenge").arg(secure_directory)).ascii());
systemexec((TQString("perl -pi -e 's/<//g' %1/challenge").arg(secure_directory)).ascii());
systemexec((TQString("xxd -r -p %1/challenge %2/challenge").arg(secure_directory).arg(secure_directory)).ascii());
systemexec(TQString("echo %1 > %2/authscript").arg(get_challenge).arg(secure_directory));
systemexec(TQString("scriptor %1/authscript | grep 'Normal processing' > %2/challenge").arg(secure_directory).arg(secure_directory));
systemexec(TQString("perl -pi -e 's/ //g' %1/challenge").arg(secure_directory));
systemexec(TQString("perl -pi -e 's/:Normalprocessing.//g' %1/challenge").arg(secure_directory));
systemexec(TQString("perl -pi -e 's/<//g' %1/challenge").arg(secure_directory));
systemexec(TQString("xxd -r -p %1/challenge %2/challenge").arg(secure_directory).arg(secure_directory));
// Now DES encrypt the challenge
// Later, change the initialization vector to random if possible
// Create the response from the challenge
systemexec((TQString("openssl des-ecb -in %1/challenge -out %2/response -K %3 -iv 1").arg(secure_directory).arg(secure_directory).arg(hexidecimal_key)).ascii());
systemexec(TQString("openssl des-ecb -in %1/challenge -out %2/response -K %3 -iv 1").arg(secure_directory).arg(secure_directory).arg(hexidecimal_key));
if (command_mode == "acos") {
// Truncate to 8 bytes
systemexec((TQString("dd if=%1/response of=%2/response2 bs=1 count=8 2>/dev/null 1>/dev/null").arg(secure_directory).arg(secure_directory)).ascii());
systemexec(TQString("dd if=%1/response of=%2/response2 bs=1 count=8 2>/dev/null 1>/dev/null").arg(secure_directory).arg(secure_directory));
// Expand to standard hex listing format
systemexec((TQString("xxd -g 1 %1/response2 %2/response").arg(secure_directory).arg(secure_directory)).ascii());
systemexec((TQString("dd if=%1/response of=%2/response2 bs=1 count=23 skip=9 2>/dev/null 1>/dev/null").arg(secure_directory).arg(secure_directory)).ascii());
systemexec(TQString("xxd -g 1 %1/response2 %2/response").arg(secure_directory).arg(secure_directory));
systemexec(TQString("dd if=%1/response of=%2/response2 bs=1 count=23 skip=9 2>/dev/null 1>/dev/null").arg(secure_directory).arg(secure_directory));
}
if (command_mode == "cryptoflex") {
// Truncate to 6 bytes
systemexec((TQString("dd if=%1/response of=%2/response2 bs=1 count=6 2>/dev/null 1>/dev/null").arg(secure_directory).arg(secure_directory)).ascii());
systemexec(TQString("dd if=%1/response of=%2/response2 bs=1 count=6 2>/dev/null 1>/dev/null").arg(secure_directory).arg(secure_directory));
// Expand to standard hex listing format
systemexec((TQString("xxd -g 1 %1/response2 %2/response").arg(secure_directory).arg(secure_directory)).ascii());
systemexec((TQString("dd if=%1/response of=%2/response2 bs=1 count=17 skip=9 2>/dev/null 1>/dev/null").arg(secure_directory).arg(secure_directory)).ascii());
systemexec(TQString("xxd -g 1 %1/response2 %2/response").arg(secure_directory).arg(secure_directory));
systemexec(TQString("dd if=%1/response of=%2/response2 bs=1 count=17 skip=9 2>/dev/null 1>/dev/null").arg(secure_directory).arg(secure_directory));
}
// Assemble the response file
TQString response2 = readfile((TQString("%1/response2").arg(secure_directory)).ascii());
TQString response2 = readfile(TQString("%1/response2").arg(secure_directory));
response1 = TQString("%1 %2").arg(external_auth).arg(response2);
systemexec((TQString("echo %1 > %2/response").arg(response1).arg(secure_directory)).ascii());
systemexec(TQString("echo %1 > %2/response").arg(response1).arg(secure_directory));
// Send the response!
systemexec((TQString("scriptor %1/response > %2/response2").arg(secure_directory).arg(secure_directory)).ascii());
systemexec(TQString("scriptor %1/response > %2/response2").arg(secure_directory).arg(secure_directory));
// Get the result
authokresponse = "< 90 00 : Normal processing";
response1 = exec((TQString("cat %1/response2 | grep \"%2\"").arg(secure_directory).arg(authokresponse)).ascii());
printf("[DEBUG 400.6] %s\n", response1.ascii()); fflush(stdout);
response1 = exec(TQString("cat %1/response2 | grep \"%2\"").arg(secure_directory).arg(authokresponse));
printf("[DEBUG 400.6] %s\n", response1.local8Bit().data()); fflush(stdout);
if (response1 != "") {
printf("[DEBUG 400.7] Smart card validation successfull!\n"); fflush(stdout);
if (command_mode == "cryptoflex") {
@ -473,23 +481,23 @@ int main (int argc, char *argv[])
TQString response = get_file("10 02", "text");
smartcard_username = readfile(response);
smartcard_username = smartcard_username.replace('\n', "");
unlink(response.ascii());
unlink(response.local8Bit());
response = get_file("10 03", "text");
smartcard_password = readfile(response.ascii());
smartcard_password = readfile(response);
smartcard_password = smartcard_password.replace('\n', "");
unlink(response.ascii());
unlink(response.local8Bit());
response = get_file("10 04", "text");
smartcard_slave = readfile(response);
smartcard_slave = smartcard_slave.replace('\n', "");
unlink(response.ascii());
unlink(response.local8Bit());
if (smartcard_slave == "SLAVE") {
get_file("10 05", "text");
smartcard_minutes_raw = readfile(response);
smartcard_minutes_raw = smartcard_minutes_raw.replace('\n', "");
unlink(response.ascii());
unlink(response.local8Bit());
get_file("10 06", "text");
internet_minutes = readfile(response).toInt();
unlink(response.ascii());
unlink(response.local8Bit());
}
}
else {
@ -497,7 +505,7 @@ int main (int argc, char *argv[])
systemexec("echo \"EInvalid SmartCard Inserted\" > /tmp/tdesocket-global/kdesktoplockcontrol &");
sleep(1);
smartcard_username="";
unlink((TQString("%1/password").arg(secure_directory)).ascii());
unlink((TQString("%1/password").arg(secure_directory)).local8Bit());
smartcard_slave="";
}
@ -512,7 +520,7 @@ int main (int argc, char *argv[])
// Decrement minutes on card
if (smartcard_minutes > 0) {
smartcard_minutes=smartcard_minutes-1;
systemexec((TQString("echo %1 > %2/minutes").arg(smartcard_minutes).arg(secure_directory)).ascii());
systemexec(TQString("echo %1 > %2/minutes").arg(smartcard_minutes).arg(secure_directory));
update_file("10 05", TQString("%1/minutes").arg(secure_directory));
}
@ -520,11 +528,11 @@ int main (int argc, char *argv[])
printf("[DEBUG 400.8] Minutes have been used up!\n"); fflush(stdout);
// Prohibit logon
smartcard_username="";
unlink((TQString("%1/password").arg(secure_directory)).ascii());
unlink((TQString("%1/password").arg(secure_directory)).local8Bit());
}
mkdir("/etc/smartmon", 644);
systemexec((TQString("echo %1 > /etc/smartmon/minutesremaining").arg(smartcard_minutes)).ascii());
systemexec(TQString("echo %1 > /etc/smartmon/minutesremaining").arg(smartcard_minutes));
chmod("/etc/smartmon/minutesremaining", 755);
}
@ -543,7 +551,7 @@ int main (int argc, char *argv[])
noactivesessions=1;
result="okbutempty";
}
printf("[DEBUG 400.9] %s\n", result.ascii()); fflush(stdout);
printf("[DEBUG 400.9] %s\n", result.local8Bit().data()); fflush(stdout);
TQString resultbkp=result;
if (errcode == 0) {
@ -579,10 +587,10 @@ int main (int argc, char *argv[])
foundsession=1;
udisplay = TQString(":%1").arg(index);
// Check password
if (check_password(smartcard_username.ascii(), smartcard_password.ascii()) == 0) {
systemexec((TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface quit\"").arg(smartcard_username).arg(udisplay)).ascii());
systemexec((TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface enable false\"").arg(smartcard_username).arg(udisplay)).ascii());
systemexec((TQString(TRINITY_BIN_PREFIX "tdmctl activate %1").arg(udisplay)).ascii());
if (check_password(smartcard_username.local8Bit(), smartcard_password.local8Bit()) == 0) {
systemexec(TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface quit\"").arg(smartcard_username).arg(udisplay));
systemexec(TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface enable false\"").arg(smartcard_username).arg(udisplay));
systemexec(TQString(TRINITY_BIN_PREFIX "tdmctl activate %1").arg(udisplay));
}
else {
systemexec("echo \"EUnauthorized SmartCard Inserted\" > /tmp/tdesocket-global/kdesktoplockcontrol &");
@ -647,8 +655,8 @@ int main (int argc, char *argv[])
if (display_has_sak) {
if (writefile(TQString(TDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint), "CLOSE\n") < 0) {
// Uh oh, something failed...
printf("Unable to write to TDM control socket %s\n", (TQString(TDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint)).ascii()); fflush(stdout);
unlink((TQString(TDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint)).ascii());
printf("Unable to write to TDM control socket %s\n", (TQString(TDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint)).local8Bit().data()); fflush(stdout);
unlink((TQString(TDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint)).local8Bit());
writeerror = true;
}
else {
@ -656,7 +664,7 @@ int main (int argc, char *argv[])
int status = -1;
int timeout_counter = 0;
while ((status != 0) && (timeout_counter < 30)) {
status = stat((TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii(), &buffer);
status = stat((TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).local8Bit(), &buffer);
timeout_counter++;
usleep(100000);
}
@ -666,8 +674,8 @@ int main (int argc, char *argv[])
// Make sure the control socket is writable
if (writefile(TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint), "PING\n") < 0) {
// Uh oh, something failed...
printf("Unable to write to TDM control socket %s\n", (TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii()); fflush(stdout);
unlink((TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii());
printf("Unable to write to TDM control socket %s\n", (TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).local8Bit().data()); fflush(stdout);
unlink((TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).local8Bit());
writeerror = true;
}
}
@ -690,26 +698,26 @@ int main (int argc, char *argv[])
}
newdisplay = TQString(":%1").arg(newdisplayint);
printf("[DEBUG 400.f] Logging in on display %s\n", newdisplay.ascii()); fflush(stdout);
printf("[DEBUG 400.f] Logging in on display %s\n", newdisplay.local8Bit().data()); fflush(stdout);
// Construct login string
TQString logincommand = TQString("LOGIN\t%1\t%2\n").arg(smartcard_username).arg(smartcard_password);
if (writefile(TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint), logincommand) < 0) {
// Uh oh, something failed...
printf("Unable to write to TDM control socket %s\n", (TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii()); fflush(stdout);
printf("Unable to write to TDM control socket %s\n", (TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).local8Bit().data()); fflush(stdout);
}
systemexec((TQString(TRINITY_BIN_PREFIX "tdmctl -g activate %1").arg(newdisplay)).ascii());
systemexec(TQString(TRINITY_BIN_PREFIX "tdmctl -g activate %1").arg(newdisplay));
udisplay=newdisplay;
}
if (smartcard_slave == "SLAVE") {
if (smartcard_minutes < 5) {
systemexec((TQString("su %1 -c \"export DISPLAY=%2; zenity --warning --text 'You have less than 5 minutes of computer time remaining' || exit 0\" &").arg(smartcard_username).arg(udisplay)).ascii());
systemexec(TQString("su %1 -c \"export DISPLAY=%2; zenity --warning --text 'You have less than 5 minutes of computer time remaining' || exit 0\" &").arg(smartcard_username).arg(udisplay));
}
}
unlink((TQString("%1/password").arg(secure_directory)).ascii());
unlink((TQString("%1/password").arg(secure_directory)).local8Bit());
// if (loginok == 1) {
// Wait for SmartCard removal
@ -719,35 +727,35 @@ int main (int argc, char *argv[])
while (output == 0) {
sleep(1);
systemexec((TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface quit\"").arg(smartcard_username).arg(udisplay)).ascii());
systemexec((TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface enable false\"").arg(smartcard_username).arg(udisplay)).ascii());
systemexec(TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface quit\"").arg(smartcard_username).arg(udisplay));
systemexec(TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface enable false\"").arg(smartcard_username).arg(udisplay));
output = systemexec("echo \"exit\" | scriptor 2>/dev/null 1>/dev/null");
if (smartcard_slave == "SLAVE") {
timer--;
if (timer == 0) {
// 60 seconds have passed, decrement minutes on card
smartcard_minutes--;
systemexec((TQString("echo %1 > /etc/smartmon/minutesremaining").arg(smartcard_minutes)).ascii());
systemexec(TQString("echo %1 > /etc/smartmon/minutesremaining").arg(smartcard_minutes));
chmod("/etc/smartmon/minutesremaining", 755);
timer=60;
systemexec((TQString("echo %1 > %2/minutes").arg(smartcard_minutes).arg(secure_directory)).ascii());
systemexec(TQString("echo %1 > %2/minutes").arg(smartcard_minutes).arg(secure_directory));
update_file("10 05", TQString("%1/minutes").arg(secure_directory));
if (smartcard_minutes == 0) {
printf("[DEBUG 401.0] Minutes have been used up!\n"); fflush(stdout);
// Prohibit logon
smartcard_username="";
unlink((TQString("%1/password").arg(secure_directory)).ascii());
unlink((TQString("%1/password").arg(secure_directory)).local8Bit());
}
mkdir("/etc/smartmon", 644);
systemexec((TQString("echo %1 > /etc/smartmon/minutesremaining").arg(smartcard_minutes)).ascii());
systemexec(TQString("echo %1 > /etc/smartmon/minutesremaining").arg(smartcard_minutes));
chmod("/etc/smartmon/minutesremaining", 755);
if (smartcard_minutes == 5) {
systemexec((TQString("su %1 -c \"export DISPLAY=%2; zenity --warning --text 'You have less than 5 minutes of computer time remaining' || exit 0\" &").arg(smartcard_username).arg(udisplay)).ascii());
systemexec(TQString("su %1 -c \"export DISPLAY=%2; zenity --warning --text 'You have less than 5 minutes of computer time remaining' || exit 0\" &").arg(smartcard_username).arg(udisplay));
}
if (smartcard_minutes == 0) {
@ -770,7 +778,7 @@ int main (int argc, char *argv[])
noactivesessions=1;
result="okbutempty";
}
printf("[DEBUG 401.4] %s\n", result.ascii()); fflush(stdout);
printf("[DEBUG 401.4] %s\n", result.local8Bit().data()); fflush(stdout);
// Zero the desktop array
index=0;
@ -800,17 +808,17 @@ int main (int argc, char *argv[])
timeout=0;
blankresult="";
while (blankresult != "true") {
systemexec((TQString(TRINITY_BIN_PREFIX "tdmctl -g activate %1").arg(udisplay)).ascii());
systemexec((TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface enable true\"").arg(smartcard_username).arg(udisplay)).ascii());
systemexec((TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface lock\"").arg(smartcard_username).arg(udisplay)).ascii());
systemexec(TQString(TRINITY_BIN_PREFIX "tdmctl -g activate %1").arg(udisplay));
systemexec(TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface enable true\"").arg(smartcard_username).arg(udisplay));
systemexec(TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface lock\"").arg(smartcard_username).arg(udisplay));
int retcode;
blankresult = execret(TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface isBlanked\"").arg(smartcard_username).arg(udisplay).ascii(), &retcode);
blankresult = execret(TQString("su %1 -c \"export DISPLAY=%2; " TRINITY_BIN_PREFIX "dcop kdesktop KScreensaverIface isBlanked\"").arg(smartcard_username).arg(udisplay), &retcode);
if (retcode != 0) {
blankresult="true";
}
blankresult = blankresult.replace('\n', "");
logouttest = exec((TQString("echo %1 | grep 'target display has no VT assigned'").arg(blankresult)).ascii());
logouttest = exec(TQString("echo %1 | grep 'target display has no VT assigned'").arg(blankresult));
if (logouttest != "") {
printf("[DEBUG 401.6] User has logged out\n"); fflush(stdout);
blankresult="true";

@ -70,6 +70,8 @@
#include <pwd.h>
#include <grp.h>
#include "messages.h"
/* Failure handler takes the function, the size, the file, and the line. */
typedef void (*xmalloc_handler_t)(const char *, size_t, const char *, int);

@ -0,0 +1,28 @@
/* $Id: xmalloc.h $
*
* malloc routines with failure handling.
*
*/
#if !defined(_XMALLOC_H)
#define _XMALLOC_H
/* The functions are actually macros so that we can pick up the file and line
number information for debugging error messages without the user having to
pass those in every time. */
#define xcalloc(n, size) x_calloc((n), (size), __FILE__, __LINE__)
#define xmalloc(size) x_malloc((size), __FILE__, __LINE__)
#define xrealloc(p, size) x_realloc((p), (size), __FILE__, __LINE__)
#define xstrdup(p) x_strdup((p), __FILE__, __LINE__)
#define xstrndup(p, size) x_strndup((p), (size), __FILE__, __LINE__)
/*
* Prototypes of functions
*/
void* x_malloc(size_t size, const char *file, int line);
void* x_calloc(size_t n, size_t size, const char *file, int line);
void* x_realloc(void *p, size_t size, const char *file, int line);
char* x_strdup(const char *s, const char *file, int line);
char* x_strndup(const char *s, size_t size, const char *file, int line);
#endif /* _XMALLOC_H */

@ -18,48 +18,84 @@ esac
. /usr/share/initramfs-tools/hook-functions
# Additional function for copying plugin (library) from multiarch directory.
# Based on copy_exec.
copy_plugin() {
local src target x
src="${1}"
if [ ${src} = "${src#/}" ]; then
for x in /${ARCHDIR} /lib /usr/${ARCHDIR} /usr/lib; do
if [ -e $x/$src ]; then
src=$(echo $x/$src)
break
fi
done
fi
target="${2:-$src}"
copy_exec "${src}" "${target}" || return $(($? - 1))
}
# Determine multiarch directory
ARCHDIR=$(ldd $SHELL | grep libc\.so |\
sed -e "s|^.*=> \(.*\)/[^/]*$|\1|" -e "s|^/usr||" -e "s|^/||")
if [ -z "$ARCHDIR" ] && [ -n "$HOSTTYPE" ] && [ -n "$OSTYPE" ]; then
ARCHDIR=$HOSTTYPE-$OSTYPE
fi
if [ -z "$ARCHDIR" ]; then
ARCHDIR=$(uname -i)
if [ "$ARCHDIR" = "unknown" ]; then
ARCHDIR=$(uname -m)
fi
if [ "$ARCHDIR" = "ppc64le" ]; then
ARCHDIR="powerpc64"
fi
if [ "$ARCHDIR" = "ppc64el" ]; then
ARCHDIR="powerpc64"
fi
ARCHDIR="*${ARCHDIR}*"
fi
# Hooks for loading smartcard reading software into the initramfs
# Install directories needed by smartcard reading daemon, command, and
# key-script
for dir in etc/opensc usr/lib/pcsc var/run tmp ; do
if [ ! -d ${DESTDIR}/${dir} ] ; then mkdir -p ${DESTDIR}/${dir} ; fi
for dir in etc/opensc lib usr/lib var/run tmp ; do
if [ ! -d ${DESTDIR}/${dir} ] ;
then
mkdir -p ${DESTDIR}/${dir}
fi
done
# Install pcscd daemon, drivers, conf file, and include libgcc as well since
# pcscd utilizes pthread_cancel
mkdir -p ${DESTDIR}/lib
# Install pcscd daemon, drivers, conf file
copy_exec /usr/sbin/pcscd /sbin
if [ -e /lib/*`uname -i`*/libgcc_s.so.1 ]
then
copy_exec /lib/*`uname -i`*/libgcc_s.so.1 /lib
else
copy_exec /lib/libgcc_s.so.1 /lib
fi
if [ -e /lib/*`uname -i`*/libpcsclite.so.1 ]
then
copy_exec /lib/*`uname -i`*/libpcsclite.so.1 /lib
else
copy_exec /lib/libpcsclite.so.1 /lib
fi
if [ -e /usr/lib/*`uname -i`*/libusb-1.0.so.0 ]
then
copy_exec /usr/lib/*`uname -i`*/libusb-1.0.so.0 /usr/lib
else
copy_exec /usr/lib/libusb-1.0.so.0 /usr/lib
copy_plugin libpcsclite.so.1
find /usr/lib/pcsc ! -type d |
while read PSCS_FILE; do
if [ ! -x ${PSCS_FILE} ] && [ ${PSCS_FILE} = ${PSCS_FILE%.so} ]; then
[ -d ${DESTDIR}${PSCS_FILE%/*} ] || \
mkdir -p ${DESTDIR}${PSCS_FILE%/*}
cp -pL $PSCS_FILE ${DESTDIR}${PSCS_FILE%/*}
else
copy_exec $PSCS_FILE
fi
done
if [ -d /etc/reader.conf.d ]; then
cp -pLR /etc/reader.conf.d ${DESTDIR}/etc/
fi
cp -r /usr/lib/pcsc ${DESTDIR}/usr/lib
if [ -e /etc/reader.conf.d ]
then
cp -Rp /etc/reader.conf.d ${DESTDIR}/etc/
else
cp /etc/reader.conf ${DESTDIR}/etc
if [ -e /etc/reader.conf ]; then
cp -pL /etc/reader.conf ${DESTDIR}/etc/
fi
# Install opensc commands and conf file
copy_exec /usr/bin/opensc-tool /bin
copy_exec /usr/bin/pkcs15-crypt /bin
cp /etc/opensc/opensc.conf ${DESTDIR}/etc/opensc
copy_exec /usr/bin/opensc-tool /bin/
copy_exec /usr/bin/pkcs15-crypt /bin/
copy_exec /usr/bin/pkcs15-tool /bin/
cp -pL /etc/opensc/opensc.conf ${DESTDIR}/etc/opensc/
# Install other required utilities
copy_exec /bin/grep /bin
@ -81,11 +117,4 @@ copy_exec /usr/bin/scriptor_standalone /bin
copy_exec /usr/bin/smartauth.sh /bin
# Libraries
# cp /usr/lib/libltdl.so* ${DESTDIR}/usr/lib
# cp /lib/libncurses.so.5 ${DESTDIR}/lib
if [ -e /lib/*`uname -i`*/libncursesw.so.5 ]
then
cp /lib/*`uname -i`*/libncursesw.so.5 ${DESTDIR}/lib
else
cp /lib/libncursesw.so.5 ${DESTDIR}/lib
fi
copy_plugin libncursesw.so.[0-9]

Loading…
Cancel
Save