diff mbox series

[bug#40601,08/28] guix-install.sh: Use getent for both user & group presence checking.

Message ID 20200517171725.732-8-vincent.legoll@gmail.com
State Under Review
Delegated to: Christopher Baines
Headers show
Series [bug#40601,01/28] nix/local.mk: Add missing comment to sysvinit section. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Vincent Legoll May 17, 2020, 5:17 p.m. UTC
* etc/guix-install.sh (sys_create_build_user): Use getent instead of id to check
presence of users, use bare getent call with output redirection for group check.
---
 etc/guix-install.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 225cf532b8..a56e0ec7b2 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -303,7 +303,7 @@  sys_create_build_user()
 
     _debug "--- [ $FUNCNAME ] ---"
 
-    if [ $(getent group guixbuild) ]; then
+    if getent group guixbuild >/dev/null 2>&1; then
         _msg "${INF}group guixbuild exists"
     else
         groupadd --system guixbuild
@@ -311,7 +311,7 @@  sys_create_build_user()
     fi
 
     for i in $(seq -w 1 10); do
-        if id "guixbuilder${i}" &>/dev/null; then
+        if getent passwd "guixbuilder${i}" >/dev/null 2>&1; then
             _msg "${INF}user is already in the system, reset"
             usermod -g guixbuild -G guixbuild           \
                     -d /var/empty -s "$(which nologin)" \