Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to start pkexec swhkd #282

Open
alexindigo opened this issue Jan 7, 2025 · 7 comments
Open

Unable to start pkexec swhkd #282

alexindigo opened this issue Jan 7, 2025 · 7 comments
Assignees

Comments

@alexindigo
Copy link

Version Information:

  • Distribution Information ( run uname -a )
Linux arch 6.6.67-1-lts #1 SMP PREEMPT_DYNAMIC Thu, 19 Dec 2024 20:39:01 +0000 x86_64 GNU/Linux
  • swhkd version ( swhkd -V )
Simple-Wayland-HotKey-Daemon 1.3.0-dev

Describe the bug:
I was able to install it finally (#281). And following next steps in the readme, trying to start it manually:

Running swhks & works fine, or at least no errors,
but running swhkd, I get:

$ swhkd
[2025-01-07T07:02:36Z ERROR swhkd::perms] Failed to set EGID: EPERM

Expected behavior:
Not to error and run.

Actual behavior:
Errors out.

To Reproduce:
Install from AUR, and then run swhkd.

Additional information:

If I try to run via systemd service with pexec swhkd I get sudo request, and then bunch of errors as well:

$ pkexec swhkd -d
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/usr/bin/swhkd -d' as the super user
Authenticating as: alex
Password: 
==== AUTHENTICATION COMPLETE ====
[2025-01-07T06:53:47Z TRACE swhkd] Logger initialized.
[2025-01-07T06:53:47Z DEBUG swhkd::perms] Setting EGID...
[2025-01-07T06:53:47Z DEBUG swhkd::perms] Setting EUID...
[2025-01-07T06:53:47Z DEBUG swhkd::perms] Setting initgroups...
[2025-01-07T06:53:47Z DEBUG swhkd] Wating for server to start...
[2025-01-07T06:53:47Z INFO  swhkd] Env refreshed
[2025-01-07T06:53:47Z TRACE swhkd] Environment Aquired
[2025-01-07T06:53:47Z TRACE swhkd] Setting process umask.
[2025-01-07T06:53:47Z TRACE swhkd] Reading /run/user/1000/swhkd_1000.pid file and checking for running instances.
[2025-01-07T06:53:47Z DEBUG swhkd] Previous PID: 775931
[2025-01-07T06:53:47Z DEBUG swhkd] Using config file path: "/home/alex/.config/swhkd/swhkdrc"
[2025-01-07T06:53:47Z TRACE swhkd] Attempting to find all keyboard file descriptors.
[2025-01-07T06:53:47Z TRACE swhkd] Other: Lid Switch
[2025-01-07T06:53:47Z TRACE swhkd] Other: Power Button
[2025-01-07T06:53:47Z DEBUG swhkd] Keyboard: AT Translated Set 2 keyboard
[2025-01-07T06:53:47Z TRACE swhkd] Other: PC Speaker
[2025-01-07T06:53:47Z TRACE swhkd] Other: FRMW0004:00 32AC:0006 Wireless Radio Control
[2025-01-07T06:53:47Z DEBUG swhkd] Keyboard: FRMW0004:00 32AC:0006 Consumer Control
[2025-01-07T06:53:47Z TRACE swhkd] Other: PIXA3854:00 093A:0274 Mouse
[2025-01-07T06:53:47Z TRACE swhkd] Other: PIXA3854:00 093A:0274 Touchpad
[2025-01-07T06:53:47Z TRACE swhkd] Other: ImExPS/2 Generic Explorer Mouse
[2025-01-07T06:53:47Z TRACE swhkd] Other: Video Bus
[2025-01-07T06:53:47Z TRACE swhkd] Other: HDA Intel PCH Headphone
[2025-01-07T06:53:47Z TRACE swhkd] Other: HDA Intel PCH HDMI/DP,pcm=3
[2025-01-07T06:53:47Z TRACE swhkd] Other: HDA Intel PCH HDMI/DP,pcm=7
[2025-01-07T06:53:47Z TRACE swhkd] Other: HDA Intel PCH HDMI/DP,pcm=8
[2025-01-07T06:53:47Z TRACE swhkd] Other: HDA Intel PCH HDMI/DP,pcm=9
[2025-01-07T06:53:47Z DEBUG swhkd] 2 Keyboard device(s) detected.
[2025-01-07T06:53:47Z ERROR swhkd] Err: Os {
        code: 19,
        kind: Uncategorized,
        message: "No such device",
    }
@manthanabc
Copy link

just a wild guess but can you check weather /dev/rfkill exists on your system?

@alexindigo
Copy link
Author

@manthanabc

$ ls -la /dev/rfkill
crw-rw-r--+ 1 root rfkill 10, 242 Jan  5 23:22 /dev/rfkill

Thank you for getting back to me.

@alexindigo
Copy link
Author

Looks like it's trying to raise privileges:

set_egid(0);

Not sure why it's trying to do that, and if I should it run as root, although in the readme, it doesn't talk about sudo.

@alexindigo
Copy link
Author

But if I run it with sudo, it's trying to read config for the root user:

$ sudo swhkd -d
[2025-01-09T04:18:29Z TRACE swhkd] Logger initialized.
[2025-01-09T04:18:29Z DEBUG swhkd::perms] Setting EGID...
[2025-01-09T04:18:29Z DEBUG swhkd::perms] Setting EUID...
[2025-01-09T04:18:29Z DEBUG swhkd::perms] Setting initgroups...
[2025-01-09T04:18:29Z DEBUG swhkd] Wating for server to start...
[2025-01-09T04:18:29Z INFO  swhkd] Env refreshed
[2025-01-09T04:18:29Z TRACE swhkd] Environment Aquired
[2025-01-09T04:18:29Z TRACE swhkd] Setting process umask.
[2025-01-09T04:18:29Z TRACE swhkd] Reading /run/user/1000/swhkd_1000.pid file and checking for running instances.
[2025-01-09T04:18:29Z DEBUG swhkd] Previous PID: 6347
[2025-01-09T04:18:29Z DEBUG swhkd] Using config file path: "/root/.config/swhkd/swhkdrc"
thread 'main' panicked at swhkd/src/config.rs:7:80:
called `Result::unwrap()` on an `Err` value: ConfigRead(ReadingConfig(Os { code: 2, kind: NotFound, message: "No such file or directory" }))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted

@alexindigo
Copy link
Author

Looks like it might be related to #156

@alexindigo
Copy link
Author

Hey @manthanabc, I'm curious why you asked about rfkill?

I think I was able to successfully run swhkd, not sure if I can reproduce it, as I had to use pkexec when running manually from command line.

Here is the log:

$ swhks & pkexec swhkd -d
[1] 6513
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/usr/bin/swhkd -d' as the super user
Authenticating as: alex
Password: 
==== AUTHENTICATION COMPLETE ====
[2025-01-09T04:41:35Z TRACE swhkd] Logger initialized.
[2025-01-09T04:41:35Z DEBUG swhkd::perms] Setting EGID...
[2025-01-09T04:41:35Z DEBUG swhkd::perms] Setting EUID...
[2025-01-09T04:41:35Z DEBUG swhkd::perms] Setting initgroups...
[2025-01-09T04:41:35Z DEBUG swhkd] Wating for server to start...
[2025-01-09T04:41:35Z INFO  swhkd] Env refreshed
[2025-01-09T04:41:35Z TRACE swhkd] Environment Aquired
[2025-01-09T04:41:35Z TRACE swhkd] Setting process umask.
[2025-01-09T04:41:35Z TRACE swhkd] Reading /run/user/1000/swhkd_1000.pid file and checking for running instances.
[2025-01-09T04:41:35Z DEBUG swhkd] Previous PID: 6399
[2025-01-09T04:41:35Z INFO  swhkd] Env refreshed
[2025-01-09T04:41:35Z DEBUG swhkd] Using config file path: "/home/alex/.config/swhkd/swhkdrc"
[2025-01-09T04:41:35Z TRACE swhkd] Attempting to find all keyboard file descriptors.
[2025-01-09T04:41:35Z TRACE swhkd] Other: Lid Switch
[2025-01-09T04:41:35Z TRACE swhkd] Other: Power Button
[2025-01-09T04:41:35Z DEBUG swhkd] Keyboard: AT Translated Set 2 keyboard
[2025-01-09T04:41:35Z TRACE swhkd] Other: PC Speaker
[2025-01-09T04:41:35Z TRACE swhkd] Other: FRMW0004:00 32AC:0006 Wireless Radio Control
[2025-01-09T04:41:35Z DEBUG swhkd] Keyboard: FRMW0004:00 32AC:0006 Consumer Control
[2025-01-09T04:41:35Z TRACE swhkd] Other: PIXA3854:00 093A:0274 Mouse
[2025-01-09T04:41:35Z TRACE swhkd] Other: PIXA3854:00 093A:0274 Touchpad
[2025-01-09T04:41:35Z TRACE swhkd] Other: Video Bus
[2025-01-09T04:41:35Z TRACE swhkd] Other: HDA Intel PCH Headphone
[2025-01-09T04:41:35Z TRACE swhkd] Other: HDA Intel PCH HDMI/DP,pcm=3
[2025-01-09T04:41:35Z TRACE swhkd] Other: HDA Intel PCH HDMI/DP,pcm=7
[2025-01-09T04:41:35Z TRACE swhkd] Other: HDA Intel PCH HDMI/DP,pcm=8
[2025-01-09T04:41:35Z TRACE swhkd] Other: HDA Intel PCH HDMI/DP,pcm=9
[2025-01-09T04:41:35Z TRACE swhkd] Other: ImExPS/2 Generic Explorer Mouse
[2025-01-09T04:41:35Z DEBUG swhkd] 2 Keyboard device(s) detected.
client_loop: send disconnect: Broken pipe

But also, for some reason, it killed my wifi, and i see rfkill mentioned in systemctl status NetworkManager.

@alexindigo
Copy link
Author

And this is what I see when I try to run it as part of systemd

Jan 08 23:19:03 arch swhkd-service.sh[11211]: Error creating textual authentication agent: Error opening current controlling terminal for the process (`/dev/tty'): No such device or address
$ systemctl --user status swhkd.service

This is my service file:

$ cat /usr/lib/systemd/user/swhkd.service
[Unit]
Description=swhkd hotkey daemon
BindsTo=default.target

[Service]
Type=simple
ExecStart=/usr/local/bin/swhkd-service.sh

[Install]
WantedBy=default.target

And this is the script:

$ cat /usr/local/bin/swhkd-service.sh
#!/usr/bin/env bash

killall swhks

swhks & pkexec swhkd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants