diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-09-15 17:44:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-09-15 17:44:02 +0000 |
commit | b82e4034156bf3c1d268aecc65a50e6569ecf2ee (patch) | |
tree | 46da6eedab7e9ddc2c73167784e4207a99ec2bfb | |
parent | 9942172e2d42cb89996fe260f65ca2ec5d6d91cf (diff) | |
download | tdebase-b82e4034156bf3c1d268aecc65a50e6569ecf2ee.tar.gz tdebase-b82e4034156bf3c1d268aecc65a50e6569ecf2ee.zip |
Fix prior commit
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1253839 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
-rw-r--r-- | kdmlib/kdmtsak.cpp | 36 | ||||
-rw-r--r-- | kdmlib/kdmtsak.h | 29 |
2 files changed, 36 insertions, 29 deletions
diff --git a/kdmlib/kdmtsak.cpp b/kdmlib/kdmtsak.cpp index 2602025bb..ab73826c9 100644 --- a/kdmlib/kdmtsak.cpp +++ b/kdmlib/kdmtsak.cpp @@ -20,7 +20,41 @@ #include "kdmtsak.h" +#define FIFO_FILE "/tmp/ksocket-global/tsak" + int main (int argc, char *argv[]) { - return tde_sak_verify_calling_process(); + int mPipe_fd; + char readbuf[128]; + int numread; + + int verifier_result = tde_sak_verify_calling_process(); + + if (verifier_result == 0) { + // OK, the calling process is authorized to retrieve SAK data + // First, flush the buffer + mPipe_fd = open(FIFO_FILE, O_RDWR | O_NONBLOCK); + numread = 1; + while (numread > 0) { + numread = read(mPipe_fd, readbuf, 128); + } + // Now wait for SAK press + mPipe_fd = open(FIFO_FILE, O_RDWR); + if (mPipe_fd > -1) { + numread = read(mPipe_fd, readbuf, 128); + readbuf[numread] = 0; + readbuf[127] = 0; + close(mPipe_fd); + if (strcmp(readbuf, "SAK\n\r") == 0) { + return 0; + } + else { + return 1; + } + } + return 6; + } + else { + return verifier_result; + } }
\ No newline at end of file diff --git a/kdmlib/kdmtsak.h b/kdmlib/kdmtsak.h index 171bece0b..21b2f85c7 100644 --- a/kdmlib/kdmtsak.h +++ b/kdmlib/kdmtsak.h @@ -37,15 +37,10 @@ #include "config.h" -#define FIFO_FILE "/tmp/ksocket-global/tsak" - // #define DEBUG inline int tde_sak_verify_calling_process() { - int mPipe_fd; - char readbuf[128]; - int numread; bool authorized = false; pid_t parentproc = getppid(); @@ -134,33 +129,11 @@ inline int tde_sak_verify_calling_process() } if (authorized == true) { - // OK, the calling process is authorized to retrieve SAK data - // First, flush the buffer - mPipe_fd = open(FIFO_FILE, O_RDWR | O_NONBLOCK); - numread = 1; - while (numread > 0) { - numread = read(mPipe_fd, readbuf, 128); - } - // Now wait for SAK press - mPipe_fd = open(FIFO_FILE, O_RDWR); - if (mPipe_fd > -1) { - numread = read(mPipe_fd, readbuf, 128); - readbuf[numread] = 0; - readbuf[127] = 0; - close(mPipe_fd); - if (strcmp(readbuf, "SAK\n\r") == 0) { - return 0; - } - else { - return 1; - } - } - return 6; + return 0; } } return 5; } -#undef FIFO_FILE #undef DEBUG
\ No newline at end of file |