@ -360,12 +402,21 @@ int main (int argc, char *argv[])
boolhide_event=false;
boolestablished=false;
booltestrun=false;
booldepcheck=false;
intcurrent_keyboard;
boolcan_proceed;
// Ignore SIGPIPE
signal(SIGPIPE,SIG_IGN);
// Register signal handlers
// Register signal and signal handler
signal(SIGINT,signal_callback_handler);
signal(SIGTERM,signal_callback_handler);
set_terminate(tsak_friendly_termination);
try{
for(i=0;i<MAX_KEYBOARDS;i++){
child_pids[i]=0;
}
@ -374,27 +425,36 @@ int main (int argc, char *argv[])
if(strcmp(argv[1],"checkactive")==0){
testrun=true;
}
if(strcmp(argv[1],"checkdeps")==0){
depcheck=true;
}
}
if(depcheck==false){
// Check for existing file locks
if(!checkFileLock()){
fprintf(stderr,"Another instance of this program is already running [1]\n");
return8;
}
if(!setupLockingPipe()){
if(!setupLockingPipe(true)){
fprintf(stderr,"Another instance of this program is already running [2]\n");
return8;
}
}
// Create the output pipe
PipeHandlercontrolpipe;
if(depcheck==false){
if(!setupPipe()){
fprintf(stderr,"Another instance of this program is already running\n");
return8;
}
}
while(1){
if(depcheck==false){
controlpipe.active=true;
}
if((getuid())!=0){
printf("You are not root! This WILL NOT WORK!\nDO NOT attempt to bypass security restrictions, e.g. by changing keyboard permissions or owner, if you want the SAK system to remain secure...\n");
@ -405,6 +465,9 @@ int main (int argc, char *argv[])
find_keyboards();
if(keyboard_fd_num==0){
printf("Could not find any usable keyboard(s)!\n");
if(depcheck==true){
return50;
}
// Make sure everyone knows we physically can't detect a SAK
// Before we do this we broadcast one so that active dialogs are updated appropriately
// Also, we keep watching for a keyboard to be added via a forked child process...
@ -450,6 +513,9 @@ int main (int argc, char *argv[])