diff options
author | Darrell Anderson <[email protected]> | 2013-05-06 20:01:17 -0500 |
---|---|---|
committer | Darrell Anderson <[email protected]> | 2013-05-06 20:01:17 -0500 |
commit | 799950979232de5711410d9fa4c33aa013a86234 (patch) | |
tree | 0669501afe35d1293b75c0f4638b8262170c79e6 | |
parent | 5d586aeaa6daa28a9753ba88b47e6518a8405a27 (diff) | |
download | smartcardauth-799950979232de5711410d9fa4c33aa013a86234.tar.gz smartcardauth-799950979232de5711410d9fa4c33aa013a86234.zip |
Cleanup output clutter.
-rw-r--r-- | src/smartauthmon.cpp | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/src/smartauthmon.cpp b/src/smartauthmon.cpp index 1386c30..b83c402 100644 --- a/src/smartauthmon.cpp +++ b/src/smartauthmon.cpp @@ -79,7 +79,7 @@ void handle_sigpipe(int sig) { int uidnum; if (sig == SIGPIPE) { - printf("Got SIGPIPE!\n\r"); fflush(stdout); + printf("Got SIGPIPE!\n"); fflush(stdout); } } @@ -89,7 +89,7 @@ TQString readfile(const char * filename) { char *buf; fp=fopen(filename, "rb"); if (fp == NULL) { - printf("[WARNING] Unable to read from file %s\n\r", filename); fflush(stdout); + printf("[WARNING] Unable to read from file %s\n", filename); fflush(stdout); return TQString(); } fseek(fp,0,SEEK_END); // Seek to end @@ -110,7 +110,7 @@ int writefile(const char * filename, TQString contents) { char *buf; fp=open(filename, O_WRONLY | O_NONBLOCK); if (fp < 0) { - printf("[WARNING] Unable to open file %s for writing\n\r", filename); fflush(stdout); + printf("[WARNING] Unable to open file %s for writing\n", filename); fflush(stdout); return -1; } int retcode = write(fp, contents.ascii(), contents.length()); @@ -181,7 +181,7 @@ TQString get_file(TQString prefix, TQString mode) { // 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\r", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); +// printf("[DEBUG 100.0] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); // Read binary systemexec((TQString("echo \"%1\" > %2/query").arg(read_binary).arg(secure_directory)).ascii()); @@ -201,7 +201,7 @@ TQString get_file(TQString prefix, TQString mode) { newstring=""; systemexec((TQString("sed -i \"s#%1#%2#g\" %3/response4").arg(stringtoreplace).arg(newstring).arg(secure_directory)).ascii()); } -// printf("[DEBUG 100.1] %s\n\r", readfile((TQString("%1/response4").arg(secure_directory))).ascii()); fflush(stdout); +// 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()); return(TQString("%1/lukskey").arg(secure_directory)); @@ -247,7 +247,7 @@ void createfile(TQString prefix, TQString mode) 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\r", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); + printf("[DEBUG 300.0] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); } } @@ -256,7 +256,7 @@ void update_file(TQString prefix, TQString mode) { // 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\r", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); + printf("[DEBUG 200.0] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); // Update existing file // Zero pad input file @@ -269,14 +269,14 @@ void update_file(TQString prefix, TQString mode) { 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\r", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); + printf("[DEBUG 200.1] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); 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\r", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); + printf("[DEBUG 200.2] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); // Create new file createfile("FF", prefix); @@ -304,7 +304,7 @@ int main (int argc, char *argv[]) int internet_minutes; int newdisplayint; - printf("[DEBUG 390.0] Starting up\n\r"); fflush(stdout); + printf("[DEBUG 390.0] Starting up\n"); fflush(stdout); // Initialize signal handlers sigfillset(&block_mask); @@ -332,21 +332,21 @@ int main (int argc, char *argv[]) // See if required programs are installed TQString scriptor = exec("whereis scriptor"); if ( scriptor == "scriptor:" ) { - printf("ERROR: scriptor is not installed! This program cannot continue!\n\r"); fflush(stdout); + printf("ERROR: scriptor is not installed! This program cannot continue!\n"); fflush(stdout); return 1; } TQString opensc = exec("whereis opensc-explorer"); if ( opensc == "opensc-explorer:" ) { - printf("ERROR: opensc-explorer is not installed! This program cannot continue!\n\r"); fflush(stdout); + printf("ERROR: opensc-explorer is not installed! This program cannot continue!\n"); fflush(stdout); return 1; } - printf("[DEBUG 390.2] Reading keys\n\r"); fflush(stdout); + printf("[DEBUG 390.2] Reading keys\n"); fflush(stdout); // Read hexidecimal_key from the system crypto files FILE* fpkey = fopen("/etc/smartauth/smartauthmon.key", "rb"); if (fpkey == NULL) { - printf("Smart card login has been disabled. Exiting...\n\r"); fflush(stdout); + printf("Smart card login has been disabled. Exiting...\n"); fflush(stdout); return 1; } else { @@ -356,12 +356,12 @@ int main (int argc, char *argv[]) hexidecimal_key.replace('\n', ""); oldsmartcard_username=""; - printf("[DEBUG 400.0] Ready...\n\r"); fflush(stdout); + printf("[DEBUG 400.0] Ready...\n"); fflush(stdout); while (1) { sleep(1); int output = systemexec("echo \"exit\" | timeout 1 scriptor 2>/dev/null 1>/dev/null"); if (output == 0) { - printf("[DEBUG 400.1] Card inserted!\n\r"); fflush(stdout); + printf("[DEBUG 400.1] Card inserted!\n"); fflush(stdout); systemexec("echo \"TAuthenticating SmartCard...\" > /tmp/tdesocket-global/kdesktoplockcontrol &"); // Get card ATR @@ -375,18 +375,18 @@ int main (int argc, char *argv[]) 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\r", smartatr.ascii()); fflush(stdout); + printf("[DEBUG 400.2] Got ATR: %s\n", smartatr.ascii()); 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\r"); fflush(stdout); + printf("[DEBUG 400.3] Detected ACOS5 card\n"); fflush(stdout); command_mode="acos"; } if (smartatr == "3B 02 14 50 ") { - printf("[DEBUG 400.3] Detected Schlumberger CryptoFlex card\n\r"); fflush(stdout); + printf("[DEBUG 400.3] Detected Schlumberger CryptoFlex card\n"); fflush(stdout); command_mode="cryptoflex"; } } else { - printf("[DEBUG 400.3] No card detected!\n\r"); fflush(stdout); + printf("[DEBUG 400.3] No card detected!\n"); fflush(stdout); } if (command_mode == "cryptoflex") { @@ -412,12 +412,12 @@ int main (int argc, char *argv[]) // 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\r", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); + printf("[DEBUG 400.4] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); 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\r", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); + printf("[DEBUG 400.5] %s\n", readfile((TQString("%1/response2").arg(secure_directory))).ascii()); fflush(stdout); } systemexec((TQString("echo %1 > %2/authscript").arg(get_challenge).arg(secure_directory)).ascii()); @@ -463,9 +463,9 @@ int main (int argc, char *argv[]) // 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\r", response1.ascii()); fflush(stdout); + printf("[DEBUG 400.6] %s\n", response1.ascii()); fflush(stdout); if (response1 != "") { - printf("[DEBUG 400.7] Smart card validation successfull!\n\r"); fflush(stdout); + printf("[DEBUG 400.7] Smart card validation successfull!\n"); fflush(stdout); if (command_mode == "cryptoflex") { opensc_explorer_file = popen("opensc-explorer 2>/dev/null 1>/dev/null", "w"); } @@ -493,7 +493,7 @@ int main (int argc, char *argv[]) } } else { - printf("[DEBUG 400.7] This card does not recognize this system!\n\r"); fflush(stdout); + printf("[DEBUG 400.7] This card does not recognize this system!\n"); fflush(stdout); systemexec("echo \"EInvalid SmartCard Inserted\" > /tmp/tdesocket-global/kdesktoplockcontrol &"); sleep(1); smartcard_username=""; @@ -517,7 +517,7 @@ int main (int argc, char *argv[]) } if (smartcard_minutes == 0) { - printf("[DEBUG 400.8] Minutes have been used up!\n\r"); fflush(stdout); + printf("[DEBUG 400.8] Minutes have been used up!\n"); fflush(stdout); // Prohibit logon smartcard_username=""; unlink((TQString("%1/password").arg(secure_directory)).ascii()); @@ -543,7 +543,7 @@ int main (int argc, char *argv[]) noactivesessions=1; result="okbutempty"; } - printf("[DEBUG 400.9] %s\n\r", result.ascii()); fflush(stdout); + printf("[DEBUG 400.9] %s\n", result.ascii()); fflush(stdout); TQString resultbkp=result; if (errcode == 0) { @@ -575,7 +575,7 @@ int main (int argc, char *argv[]) while (index < MAXIMUM_VTS) { if (darray[index] == smartcard_username) { if (darray[index] != "") { - printf("[DEBUG 400.a] Found existing session on desktop: %d\n\r", index); fflush(stdout); + printf("[DEBUG 400.a] Found existing session on desktop: %d\n", index); fflush(stdout); foundsession=1; udisplay = TQString(":%1").arg(index); // Check password @@ -589,7 +589,7 @@ int main (int argc, char *argv[]) } } else { - printf("[DEBUG 400.b] Username not specified\n\r"); fflush(stdout); + printf("[DEBUG 400.b] Username not specified\n"); fflush(stdout); foundsession=2; sleep(1); } @@ -598,7 +598,7 @@ int main (int argc, char *argv[]) } if (foundsession == 0) { - printf("[DEBUG 400.c] Existing session not found, starting new...\n\r"); fflush(stdout); + printf("[DEBUG 400.c] Existing session not found, starting new...\n"); fflush(stdout); // Get directory listing of tdm control socket directory // Also start new X server if needed @@ -647,7 +647,7 @@ 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\r", (TQString(TDM_CONTROL_FIFO_SAK_FILE).arg(newdisplayint)).ascii()); fflush(stdout); + 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()); writeerror = true; } @@ -666,7 +666,7 @@ 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\r", (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)).ascii()); fflush(stdout); unlink((TQString(TDM_CONTROL_FIFO_FILE).arg(newdisplayint)).ascii()); writeerror = true; } @@ -690,13 +690,13 @@ int main (int argc, char *argv[]) } newdisplay = TQString(":%1").arg(newdisplayint); - printf("[DEBUG 400.f] Logging in on display %s\n\r", newdisplay.ascii()); fflush(stdout); + printf("[DEBUG 400.f] Logging in on display %s\n", newdisplay.ascii()); 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\r", (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)).ascii()); fflush(stdout); } systemexec((TQString(TRINITY_BIN_PREFIX "tdmctl -g activate %1").arg(newdisplay)).ascii()); @@ -736,7 +736,7 @@ int main (int argc, char *argv[]) update_file("10 05", TQString("%1/minutes").arg(secure_directory)); if (smartcard_minutes == 0) { - printf("[DEBUG 401.0] Minutes have been used up!\n\r"); fflush(stdout); + printf("[DEBUG 401.0] Minutes have been used up!\n"); fflush(stdout); // Prohibit logon smartcard_username=""; unlink((TQString("%1/password").arg(secure_directory)).ascii()); @@ -751,15 +751,15 @@ int main (int argc, char *argv[]) } if (smartcard_minutes == 0) { - printf("[DEBUG 401.1] Minutes have been used up!\n\r"); fflush(stdout); - printf("[DEBUG 401.2] Beginning logoff process\n\r"); fflush(stdout); + printf("[DEBUG 401.1] Minutes have been used up!\n"); fflush(stdout); + printf("[DEBUG 401.2] Beginning logoff process\n"); fflush(stdout); output=254; } } } } - printf("[DEBUG 401.3] Card removed\n\r"); fflush(stdout); + printf("[DEBUG 401.3] Card removed\n"); fflush(stdout); // Is the user still logged in? result="ok"; @@ -770,7 +770,7 @@ int main (int argc, char *argv[]) noactivesessions=1; result="okbutempty"; } - printf("[DEBUG 401.4] %s\n\r", result.ascii()); fflush(stdout); + printf("[DEBUG 401.4] %s\n", result.ascii()); fflush(stdout); // Zero the desktop array index=0; @@ -793,7 +793,7 @@ int main (int argc, char *argv[]) while (index != MAXIMUM_VTS) { if (darray[index] == smartcard_username) { if (darray[index] != "") { - printf("[DEBUG 401.5] Found existing session on desktop: %d\n\r", index); fflush(stdout); + printf("[DEBUG 401.5] Found existing session on desktop: %d\n", index); fflush(stdout); udisplay = TQString(":%1").arg(index); foundsession=1; errcode=1; @@ -812,13 +812,13 @@ int main (int argc, char *argv[]) logouttest = exec((TQString("echo %1 | grep 'target display has no VT assigned'").arg(blankresult)).ascii()); if (logouttest != "") { - printf("[DEBUG 401.6] User has logged out\n\r"); fflush(stdout); + printf("[DEBUG 401.6] User has logged out\n"); fflush(stdout); blankresult="true"; } } } else { - printf("[DEBUG 401.7] Username not specified!\n\r"); fflush(stdout); + printf("[DEBUG 401.7] Username not specified!\n"); fflush(stdout); sleep(1); } } |