unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* shepherd service, unexplained permission errors
@ 2023-06-28 20:27 Attila Lendvai
  2023-06-28 20:56 ` Felix Lechner via Development of GNU Guix and the GNU System distribution.
  0 siblings, 1 reply; 3+ messages in thread
From: Attila Lendvai @ 2023-06-28 20:27 UTC (permalink / raw)
  To: guix-devel

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)



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-29  7:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-28 20:27 shepherd service, unexplained permission errors Attila Lendvai
2023-06-28 20:56 ` Felix Lechner via Development of GNU Guix and the GNU System distribution.
2023-06-29  7:42   ` Attila Lendvai

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).