guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

shepherd service, unexplained permission errors


From: Attila Lendvai
Subject: shepherd service, unexplained permission errors
Date: Wed, 28 Jun 2023 20:27:14 +0000

dear Guix,

i have a daemon that i (try to) run/start through Shepherd's fork+exec-command, 
with a specific user and group. i can start it up using su or sudo, both work:

$ sudo --user zigbee2mqtt bash -c "guix shell node gcc-toolchain make python 
libuv -- bash -c 'cd /srv/zigbee2mqtt && npm start'"

# su zigbee2mqtt --command "guix shell node gcc-toolchain make python libuv -- 
bash -c 'cd /srv/zigbee2mqtt && npm start'"

but through Shepherd the daemon fails while starting up due to a permission 
denied error:

"Error: Permission denied, cannot open /dev/ttyUSB0"

$ ls -l /dev/ttyUSB0 
crw-rw---- 1 root dialout 188, 0 Jun 28 21:04 /dev/ttyUSB0

i created a user for that daemon, and added dialout as a supplementary group:

(user-account
 (name "zigbee2mqtt")
 (comment "zigbee2mqtt service")
 (group "homeaut")
 (supplementary-groups '("dialout"))
 (system? #true))

(user-group
 (name "homeaut")
 (system? #true))

i start the service like this:

(simple-service
  'zigbee2mqtt
  shepherd-root-service-type
  (list
   (shepherd-service
    (requirement '(...))
    (provision '(...))
    (documentation "")
    (start
     #~(lambda _
         (let* ((cmd (list
                      "guix" "shell"
                      "node" "gcc-toolchain" "make" "python" "libuv"
                      "--"
                      "bash" "-c" "cd /srv/zigbee2mqtt && npm start")))
           (fork+exec-command
            cmd
            #:log-file "/var/log/zigbee2mqtt.log"
            #:user "zigbee2mqtt"
            #:group "homeaut")))))))

so, my question boils down to this:

what is different in the two environments? what am i missing?

PS: i have another daemon where i have a very similar issue, so it's probably 
not a daemon-specific issue.

PS2: i know that i should package zigbee2mqtt, but i'm taking this shortcut 
because life is short.

-- 
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“The trouble is, you think you have time.”
        — Siddhartha Gutama, aka Buddha (c. 5th century BC)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]