kernc / logkeys

:memo: :keyboard: A GNU/Linux keylogger that works!
Other
758 stars 253 forks source link

Does not log anything starting at commit fff9d1d using --output flag #205

Closed theryangeary closed 4 years ago

theryangeary commented 4 years ago

git bisect and testing shows that this commit introduces this issue:

fff9d1d60f85a09208935170940c14ef7604b9d0 is the first bad commit
commit fff9d1d60f85a09208935170940c14ef7604b9d0
Author: Thomas Weber <thomas.weber@notengrafik.com>
Date:   Fri Sep 20 22:40:48 2019 +0200

    Make main loop a function of its own

 src/logkeys.cc | 171 +++++++++++++++++++++++++++++++--------------------------
 1 file changed, 92 insertions(+), 79 deletions(-)

It seems from an external standpoint that it simply isn't writing to the log file whatsoever. I'm running as sudo logkeys -s -o keys.log on Arch: Linux commodus 5.3.5-arch1-1-ARCH #1 SMP PREEMPT Mon Oct 7 19:03:08 UTC 2019 x86_64 GNU/Linux

th-we commented 4 years ago

Sorry that I caused you problems with my commit. I just re-checked – it works on my system. A few ideas how to get closer to the cause of this:

theryangeary commented 4 years ago
theryangeary commented 4 years ago

Found it! It appears as though the file is being opened with a relative path (i.e. if I say -o keys.log it will put it in the CWD of the process) but the process CWD appears to actually be the root directory /, so it ends up writing it to /keys.log when I was expecting it to be in $PWD/keys.log.

kernc commented 4 years ago

The culprit is daemon(3) call, which is passed nochdir=0 and which since fff9d1d60f85a09208935170940c14ef7604b9d0 happens before the log file is opened. https://github.com/kernc/logkeys/blob/2e33f93efdf11bafee26a987355c82ce913a41c3/src/logkeys.cc#L705

The simple options I see, not in preferential order: