diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-04-03 15:44:29 -0500 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2013-04-03 22:58:17 +0200 |
commit | 57a8101b06003c29d92e323cdcabaa2049cd542d (patch) | |
tree | 9ee7fb7b760618be9d9da266088e02c4e5ea2587 /tsak | |
parent | e7782fa8dd0669023ab306cfab113523c4ba5888 (diff) | |
download | tdebase-57a8101b06003c29d92e323cdcabaa2049cd542d.tar.gz tdebase-57a8101b06003c29d92e323cdcabaa2049cd542d.zip |
Fix tsak corrupting input events
This resolves Bug 1423
Thanks to Slavek for the patch!
Clean up tsak debug output
Remove spurious checks from tsak main replication loop
(cherry picked from commit 86cc65ce51ca652ff1e7517bf29fcd375639719f)
Diffstat (limited to 'tsak')
-rw-r--r-- | tsak/main.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tsak/main.cpp b/tsak/main.cpp index 39ce77ebe..2e79954fb 100644 --- a/tsak/main.cpp +++ b/tsak/main.cpp @@ -386,11 +386,20 @@ void restart_tsak() // Release all exclusive keyboard locks for (int current_keyboard=0;current_keyboard<keyboard_fd_num;current_keyboard++) { if(ioctl(keyboard_fds[current_keyboard], EVIOCGRAB, 0) < 0) { - fprintf(stderr, "[tsak] Failed to release exclusive input device lock"); + fprintf(stderr, "[tsak] Failed to release exclusive input device lock\n"); } close(keyboard_fds[current_keyboard]); } + // Unset the exclusive file lock + if (mPipe_fd_out != -1) { + struct flock fl; + if (fcntl(mPipe_fd_out, F_UNLCK, &fl) == -1) { + fprintf(stderr, "[tsak] Failed to release exclusive pipe lock\n"); + } + close(mPipe_fd_out); + } + #if 1 // Restart now // Note that the execl function never returns @@ -498,14 +507,14 @@ int main (int argc, char *argv[]) } 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"); + printf ("[tsak] 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"); return 5; } // Find keyboards find_keyboards(); if (keyboard_fd_num == 0) { - printf ("Could not find any usable keyboard(s)!\n"); + printf ("[tsak] Could not find any usable keyboard(s)!\n"); if (depcheck == true) { return 50; } @@ -658,10 +667,10 @@ int main (int argc, char *argv[]) } } - if ((hide_event == false) && (ev[0].type != EV_LED) && (ev[1].type != EV_LED)) { + if ((hide_event == false) && (ev[0].type != EV_LED) && (ev[0].type != EV_MSC)) { // Pass the event on... event = ev[0]; - if (write(devout[current_keyboard], &event, sizeof event) < 0) { + if (write(devout[current_keyboard], &event, sizeof(event)) < 0) { fprintf(stderr, "[tsak] Unable to replicate keyboard event!\n"); } } |