Skip to content

Newly connected devices not processed after new security model #321

@heyzec

Description

@heyzec

Version Information:

  • Distribution: NixOS
  • swhkd version: Simple-Wayland-HotKey-Daemon 1.3.0-dev, built off ae372e0

Describe the bug:
This bug is similar to #162 (closed), but I believe the cause is different.

Note that the bug only occurs after at least one hotkey has been triggered.

Expected behavior:
swhkd should be able to register hotkeys on a newly connected keyboard.

Actual behavior:
swhkd does not grab newly connected devices and thus cannot handle their keypresses events.

To Reproduce:

  1. Start swhkd.
  2. Trigger a hotkey first.
  3. Connect a keyboard (or disconnect yours before reconnecting it).
  4. Hotkeys will not work.
    • swhkd will log: Could not open evdev device at /dev/input/eventX: Permission denied (os error 13)

Additional information:
While I have not did a git bisect, I believe it is caused by #270. This is deduced by running this command to observe UID of the swhkd process:

watch -n1 'sh -c "{ head -n1; grep -v sudo | grep -i \"swhk[sd]\"; } < <(ps -eo pid,ruid,euid,gid,cmd)"'

After step (2), we observe swhkd drop permissions as RUID and EUID turn from the root (0) to the user (e.g. 1000). As a result, it no longer has permissions to read newly connected files in /dev/input.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions