all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 8cac24417d3897fc0b64fa4c15224f36336f96bd 1683 bytes (raw)
name: gnu/packages/patches/shepherd-set-supplementary-groups.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index bd7e379..2344915 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -758,6 +758,28 @@ daemon writing FILE is running in a separate PID namespace."
               (try-again)
               (apply throw args)))))))
 
+(define (supplementary-gids user)
+  "Return a vector with the gid for each supplementary group USER belongs to.
+USER is the user name as a string."
+  ;; TODO: To find them, we loop through the group database, but maybe using
+  ;; glibc’s getgrouplist would be better.  But it is not exported from Guile
+  ;; and it seems it is not part of POSIX (?).
+  (list->vector
+   (delete-duplicates
+    (dynamic-wind
+        (lambda () (setgrent))
+        (lambda ()
+          (let loop ((supgids '()))
+            (let ((group (getgrent)))
+              (define (user-among-group? group)
+                (member user (group:mem group)))
+              (match group
+                     (#f supgids)
+                     ((? user-among-group?)
+                      (loop (cons (group:gid group) supgids)))
+                     (else (loop supgids))))))
+        (lambda () (endgrent))))))
+
 (define* (exec-command command
                        #:key
                        (user #f)
@@ -826,7 +848,8 @@ false."
      (when user
        (catch #t
          (lambda ()
-           (setuid (passwd:uid (getpw user))))
+           (setuid (passwd:uid (getpw user)))
+           (setgroups (supplementary-gids user)))
          (lambda (key . args)
            (format (current-error-port)
                    "failed to change to user ~s:~%" user)

debug log:

solving 8cac24417d ...
found 8cac24417d in https://yhetil.org/guix/20191204102212.ldt6w4whzfz6ceq5@pelzflorian.localdomain/

applying [1/1] https://yhetil.org/guix/20191204102212.ldt6w4whzfz6ceq5@pelzflorian.localdomain/
diff --git a/gnu/packages/patches/shepherd-set-supplementary-groups.patch b/gnu/packages/patches/shepherd-set-supplementary-groups.patch
new file mode 100644
index 0000000000..8cac24417d

1:14: trailing whitespace.
 
Checking patch gnu/packages/patches/shepherd-set-supplementary-groups.patch...
Applied patch gnu/packages/patches/shepherd-set-supplementary-groups.patch cleanly.
warning: 1 line adds whitespace errors.

index at:
100644 8cac24417d3897fc0b64fa4c15224f36336f96bd	gnu/packages/patches/shepherd-set-supplementary-groups.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.