GNU bug report logs - #74952
[PATCH] guix-install.sh: Use "command -v nologin" instead of "which nologin".

Previous Next

Package: guix;

Reported by: Simon Josefsson <simon <at> josefsson.org>

Date: Wed, 18 Dec 2024 20:36:01 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 74952 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#74952; Package guix. (Wed, 18 Dec 2024 20:36:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Simon Josefsson <simon <at> josefsson.org>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Wed, 18 Dec 2024 20:36:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Simon Josefsson <simon <at> josefsson.org>
To: bug-guix <at> gnu.org
Subject: [PATCH] guix-install.sh: Use "command -v nologin" instead of "which
 nologin".
Date: Wed, 18 Dec 2024 21:35:27 +0100
[Message part 1 (text/plain, inline)]
Hi!

In a small container image, I do not have the 'which' tool installed.  I
believe 'command -v' is always available since it is /bin/sh standard.
How about changing the idiom for user/group additions from 'which' to
'command -v'?  See attached patch.

/Simon
[0001-guix-install.sh-Use-command-v-nologin-instead-of-whi.patch (text/x-diff, inline)]
From 2bc261126a84a4a9a33acea9f107ad4bdef929d0 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <simon <at> josefsson.org>
Date: Wed, 18 Dec 2024 21:30:10 +0100
Subject: [PATCH] guix-install.sh: Use "command -v nologin" instead of "which
 nologin".

* doc/guix.texi (Build Environment Setup): Change.
* etc/guix-install.sh (sys_create_build_user): Likewise.
* gnu/machine/digital-ocean.scm (guix-infect): Update.
---
 doc/guix.texi                 | 6 +++---
 etc/guix-install.sh           | 4 ++--
 gnu/machine/digital-ocean.scm | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index f7b7569887..46ceb71cde 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -944,9 +944,9 @@ Bash syntax and the @code{shadow} commands):
 # groupadd --system guixbuild
 # for i in $(seq -w 1 10);
   do
-    useradd -g guixbuild -G guixbuild           \
-            -d /var/empty -s $(which nologin)   \
-            -c "Guix build user $i" --system    \
+    useradd -g guixbuild -G guixbuild              \
+            -d /var/empty -s $(command -v nologin) \
+            -c "Guix build user $i" --system       \
             guixbuilder$i;
   done
 @end example
diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index f07b2741bb..44b3e62ed2 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -435,12 +435,12 @@ sys_create_build_user()
         if id "guixbuilder${i}" &>/dev/null; then
             _msg "${INF}user is already in the system, reset"
             usermod -g guixbuild -G guixbuild${KVMGROUP}     \
-                    -d /var/empty -s "$(which nologin)" \
+                    -d /var/empty -s "$(command -v nologin)" \
                     -c "Guix build user $i"             \
                     "guixbuilder${i}";
         else
             useradd -g guixbuild -G guixbuild${KVMGROUP}     \
-                    -d /var/empty -s "$(which nologin)" \
+                    -d /var/empty -s "$(command -v nologin)" \
                     -c "Guix build user $i" --system    \
                     "guixbuilder${i}";
             _msg "${PAS}user added <guixbuilder${i}>"
diff --git a/gnu/machine/digital-ocean.scm b/gnu/machine/digital-ocean.scm
index d0f0bbe4cb..5fa679ab8c 100644
--- a/gnu/machine/digital-ocean.scm
+++ b/gnu/machine/digital-ocean.scm
@@ -260,7 +260,7 @@ (define os
 groupadd --system guixbuild
 for i in `seq -w 1 10`; do
    useradd -g guixbuild -G guixbuild         \
-           -d /var/empty -s `which nologin`  \
+           -d /var/empty -s `command -v nologin`  \
            -c \"Guix build user $i\" --system  \
            guixbuilder$i;
 done;
-- 
2.46.0

[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#74952; Package guix. (Wed, 18 Dec 2024 21:56:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo Famulari <leo <at> famulari.name>
To: Simon Josefsson via Bug reports for GNU Guix <bug-guix <at> gnu.org>
Cc: 74952 <at> debbugs.gnu.org
Subject: Re: bug#74952: [PATCH] guix-install.sh: Use "command -v nologin"
 instead of "which nologin".
Date: Wed, 18 Dec 2024 16:55:21 -0500
On Wed, Dec 18, 2024 at 09:35:27PM +0100, Simon Josefsson via Bug reports for GNU Guix wrote:
> Hi!
> 
> In a small container image, I do not have the 'which' tool installed.  I
> believe 'command -v' is always available since it is /bin/sh standard.
> How about changing the idiom for user/group additions from 'which' to
> 'command -v'?  See attached patch.

Agreed, I don't think we need to require `which` here.

It can also be removed from REQUIRE in 'etc/guix-install.sh'.




Information forwarded to bug-guix <at> gnu.org:
bug#74952; Package guix. (Wed, 18 Dec 2024 21:56:03 GMT) Full text and rfc822 format available.

This bug report was last modified 232 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.