system: Make sure user accounts refer to existing groups.

Fixes <http://bugs.gnu.org/20646>.
Reported by David Thompson <davet@gnu.org>.

* gnu/system/shadow.scm (assert-valid-users/groups): New procedure
* gnu/system.scm (operating-system-activation-script): Use it.
* tests/guix-system.sh (make_user_config): New function.
  Add 3 tests using it.
* po/guix/POTFILES.in: Add gnu/system/shadow.scm.
This commit is contained in:
Ludovic Courtès 2015-05-24 18:02:54 +02:00
parent 6ec1f4caa3
commit 0c09a306e5
4 changed files with 76 additions and 1 deletions

View file

@ -76,3 +76,42 @@ then
else
grep "service 'networking'.*more than once" "$errorfile"
fi
make_user_config ()
{
cat > "$tmpfile" <<EOF
(use-modules (gnu))
(use-service-modules networking)
(operating-system
(host-name "antelope")
(timezone "Europe/Paris")
(locale "en_US.UTF-8")
(bootloader (grub-configuration (device "/dev/sdX")))
(file-systems (cons (file-system
(device "root")
(title 'label)
(mount-point "/")
(type "ext4"))
%base-file-systems))
(users (list (user-account
(name "dave")
(home-directory "/home/dave")
(group "$1")
(supplementary-groups '("$2"))))))
EOF
}
make_user_config "users" "wheel"
guix system build "$tmpfile" -n # succeeds
make_user_config "group-that-does-not-exist" "users"
if guix system build "$tmpfile" -n 2> "$errorfile"
then false
else grep "primary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi
make_user_config "users" "group-that-does-not-exist"
if guix system build "$tmpfile" -n 2> "$errorfile"
then false
else grep "supplementary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi