Fix some smartautmon issues with ACOS cards

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/smartcardauth@1254718 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 13 years ago
parent 4cef0073c0
commit 08211e05a2

@ -153,7 +153,7 @@ TQString get_file(TQString prefix, TQString mode) {
// Select EF prefix under DF 1000
systemexec((TQString("echo \"%1 %2\" > %3/query").tqarg(select_file).tqarg(prefix).tqarg(secure_directory)).ascii());
systemexec((TQString("scriptor %1/query 1> %2/response2").tqarg(secure_directory).tqarg(secure_directory)).ascii());
printf("[DEBUG 100.0] %s\n\r", readfile((TQString("%1/response2").tqarg(secure_directory))).ascii());
// printf("[DEBUG 100.0] %s\n\r", readfile((TQString("%1/response2").tqarg(secure_directory))).ascii());
// Read binary
systemexec((TQString("echo \"%1\" > %2/query").tqarg(read_binary).tqarg(secure_directory)).ascii());
@ -161,7 +161,7 @@ TQString get_file(TQString prefix, TQString mode) {
TQString authokresponse="90 00 : Normal processing";
TQString response1 = exec((TQString("cat %1/response2 | grep \"%2\"").tqarg(secure_directory).tqarg(authokresponse)).ascii());
if (response1 != "") {
systemexec((TQString("cat %1/response2 | tr -d '\n' > %1/response4").tqarg(secure_directory)).ascii());
systemexec((TQString("cat %1/response2 | tr -d '\n' > %2/response4").tqarg(secure_directory).tqarg(secure_directory)).ascii());
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").tqarg(stringtoreplace).tqarg(newstring).tqarg(secure_directory)).ascii());
@ -173,9 +173,9 @@ TQString get_file(TQString prefix, TQString mode) {
newstring="";
systemexec((TQString("sed -i \"s#%1#%2#g\" %3/response4").tqarg(stringtoreplace).tqarg(newstring).tqarg(secure_directory)).ascii());
}
printf("[DEBUG 100.1] %s\n\r", readfile((TQString("%1/response4").tqarg(secure_directory))).ascii());
// printf("[DEBUG 100.1] %s\n\r", readfile((TQString("%1/response4").tqarg(secure_directory))).ascii());
unlink((TQString("%1/lukskey").tqarg(secure_directory)).ascii());
systemexec((TQString("xxd -r -p %1/response4 %1/lukskey").tqarg(secure_directory)).ascii());
systemexec((TQString("xxd -r -p %1/response4 %2/lukskey").tqarg(secure_directory).tqarg(secure_directory)).ascii());
return(TQString("%1/lukskey").tqarg(secure_directory));
}
}
@ -435,16 +435,20 @@ int main (int argc, char *argv[])
// Get username and password
TQString response = get_file("10 02", "text");
smartcard_username = readfile(response);
smartcard_username = smartcard_username.replace('\n', "");
unlink(response.ascii());
response = get_file("10 03", "text");
smartcard_password = readfile(response.ascii());
smartcard_password = smartcard_password.replace('\n', "");
unlink(response.ascii());
response = get_file("10 04", "text");
smartcard_slave = readfile(response);
smartcard_slave = smartcard_slave.replace('\n', "");
unlink(response.ascii());
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());
get_file("10 06", "text");
internet_minutes = readfile(response).toInt();
@ -555,10 +559,10 @@ int main (int argc, char *argv[])
}
index++;
}
if (foundsession == 0) {
printf("[DEBUG 400.c] Existing session not found, starting new...\n\r");
// Make sure that this is not display :0 (default login screen).
// If it is, execute login. If not, create new session, then execute login
int usebasedisplay=0;
@ -576,10 +580,10 @@ int main (int argc, char *argv[])
usebasedisplay=1;
}
}
printf("[DEBUG 400.e] Creating new session\n\r");
// Attempt login
// Find next sequential inactive display
// FIXME
// This assumes the original VT is on display 0 at all times
@ -597,10 +601,10 @@ int main (int argc, char *argv[])
break;
}
}
newdisplay = TQString(":%1").tqarg(newdisplayint);
printf("[DEBUG 400.f] The next display to start will be %s\n\r", newdisplay.ascii());
systemexec(TRINITY_BIN_PREFIX "kdmctl -g reserve");
TQString kdmctl_command = TQString("login\t%1\tnow\t%2\t%3\n").tqarg(newdisplay).tqarg(smartcard_username).tqarg(smartcard_password);
FILE* kdmctlpipe = popen(TRINITY_BIN_PREFIX "kdmctl -g -", "w");
@ -613,7 +617,7 @@ int main (int argc, char *argv[])
systemexec((TQString(TRINITY_BIN_PREFIX "kdmctl -g activate %1").tqarg(newdisplay)).ascii());
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\" &").tqarg(smartcard_username).tqarg(udisplay)).ascii());

Loading…
Cancel
Save