From 952afb6f8c209692e52f9561965ee39e143e1d88 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 26 Mar 2019 18:07:58 +0100 Subject: environment: Create /etc/group in containers. Reported by Pierre Neidhardt . * guix/scripts/environment.scm (launch-environment/container): Create GROUPS and call 'write-group'. * tests/guix-environment-container.sh: Test it. --- guix/scripts/environment.scm | 4 ++++ tests/guix-environment-container.sh | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index 597a5b4ab1..c27edc7982 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -469,6 +469,9 @@ (define* (launch-environment/container #:key command bash user user-mappings (directory (if user (string-append "/home/" user) (passwd:dir pwd)))))) + (groups (list (group-entry (name "users") (gid 0)) + (group-entry (gid 65534) ;the overflow GID + (name "overflow")))) (home-dir (password-entry-directory passwd)) ;; Bind-mount all requisite store items, user-specified mappings, ;; /bin/sh, the current working directory, and possibly networking @@ -528,6 +531,7 @@ (define* (launch-environment/container #:key command bash user user-mappings ;; sharing the host's network namespace. (mkdir-p "/etc") (write-passwd (list passwd)) + (write-group groups) ;; For convenience, start in the user's current working ;; directory rather than the root directory. diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index 059c4d9213..f2221af95b 100644 --- a/tests/guix-environment-container.sh +++ b/tests/guix-environment-container.sh @@ -46,9 +46,15 @@ fi if test "x$USER" = "x"; then USER="`id -un`"; fi -# Check whether /etc/passwd is valid. +# Check whether /etc/passwd and /etc/group are valid. guix environment -C --ad-hoc --bootstrap guile-bootstrap \ -- guile -c "(exit (string=? \"$USER\" (passwd:name (getpwuid (getuid)))))" +guix environment -C --ad-hoc --bootstrap guile-bootstrap \ + -- guile -c '(exit (string? (group:name (getgrgid (getgid)))))' +guix environment -C --ad-hoc --bootstrap guile-bootstrap \ + -- guile -c '(use-modules (srfi srfi-1)) + (exit (every group:name + (map getgrgid (vector->list (getgroups)))))' # Make sure file-not-found errors in mounts are reported. if guix environment --container --ad-hoc --bootstrap guile-bootstrap \ -- cgit v1.2.3