Lvl4Sword / Killer

🔪 System tamper detector for USB, Bluetooth, AC, Battery, Disk Tray, and Ethernet.
https://pypi.org/project/killer/
GNU Affero General Public License v3.0
71 stars 11 forks source link

killer doesn't catch the error if configfile is invalid (or nonexistent) #41

Closed 1989gironimo closed 2 years ago

1989gironimo commented 5 years ago

It just throws the python error message, which is confusing for non-pythondevs :)

Lvl4Sword commented 5 years ago

Your comment on #37 would cover this. I'll keep this open though.

Lvl4Sword commented 5 years ago

@1989gironimo Can you give a full traceback of where/when this happens?

1989gironimo commented 5 years ago

Directly at trying to start killer. Traceback (most recent call last): File "/home/robot/.local/bin/killer", line 10, in <module> sys.exit(main()) File "/home/robot/.local/lib/python3.7/site-packages/killer/killer.py", line 62, in main execute.detect_tray() File "/home/robot/.local/lib/python3.7/site-packages/killer/killer_posix.py", line 121, in detect_tray fd = os.open(disk_tray, os.O_RDONLY | os.O_NONBLOCK) FileNotFoundError: [Errno 2] No such file or directory: '/dev/sr0'

1989gironimo commented 5 years ago

Updated killer to the newest version 0.7.1 and got this: `sh: 0: getcwd() failed: No such file or directory

    _  _  _  _ _
   | |/ /(_)| | |
   |   /  _ | | | ____ _ _
   |  \  | || | |/ _  ) `_|
   | | \ | || | ( (/_/| |
   |_|\_\|_|\__)_)____)_|

\ | _ \ `. _|__/



Traceback (most recent call last):
  File "/home/robot/.local/bin/killer", line 10, in <module>
    sys.exit(main())
  File "/home/robot/.local/lib/python3.7/site-packages/killer/killer.py", line 88, in main
    execute = get_killer(args)
  File "/home/robot/.local/lib/python3.7/site-packages/killer/killer.py", line 48, in get_killer
    from killer.killer_posix import KillerPosix
  File "/home/robot/.local/lib/python3.7/site-packages/killer/killer_posix.py", line 9, in <module>
    from killer.killer_base import KillerBase
  File "/home/robot/.local/lib/python3.7/site-packages/killer/killer_base.py", line 16, in <module>
    class KillerBase(ABC):
  File "/home/robot/.local/lib/python3.7/site-packages/killer/killer_base.py", line 17, in KillerBase
    CONFIG_SEARCH_PATHS = [Path.cwd(), Path.home()]
  File "/usr/lib/python3.7/pathlib.py", line 1057, in cwd
    return cls(os.getcwd())
FileNotFoundError: [Errno 2] No such file or directory
`
Lvl4Sword commented 5 years ago

https://github.com/Lvl4Sword/Killer/issues/41#issuecomment-520932801 is just because FileNotFoundError: [Errno 2] No such file or directory: '/dev/sr0' - which is the CDROM drive not being found.

I see you're running as robot as opposed to root. This'll prevent the shutdown command from actually initiating if any tampering is detected.

Can you run

from pathlib import Path
print(Path.cwd())

as the robot user?

I'm curious as to why File "/usr/lib/python3.7/pathlib.py", line 1057, in cwd return cls(os.getcwd()) shows up before the FileNoFoundError

Lvl4Sword commented 5 years ago

Also, your second comment doesn't actually include everything. Can you provide the full traceback including what's causing the FileNotFoundError?

1989gironimo commented 5 years ago

I'll report back in a few days :)

1989gironimo commented 5 years ago

Ok, reporting back. killer was installed via pip3 install --user -U killer sudo killer doesn't work, probably it's installed in the "user" folder of pip, not the systemwide one. Should I try this as well? What's the point anyway to recommend installing it in the home directory and not systemwide?

Lvl4Sword commented 2 years ago

@1989gironimo If you try the new branch, do you still have this issue?

Lvl4Sword commented 2 years ago

This should be fixed in the new branch, closing