[PATCH] guix-install.sh: Use "command -v nologin" instead of "which nologin".

  • Open
  • quality assurance status badge
Details
2 participants
  • Leo Famulari
  • Simon Josefsson
Owner
unassigned
Submitted by
Simon Josefsson
Severity
normal
S
S
Simon Josefsson wrote 16 hours ago
(address . bug-guix@gnu.org)
871py4k9v4.fsf@kaka.sjd.se
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
From 2bc261126a84a4a9a33acea9f107ad4bdef929d0 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <simon@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(-)

Toggle diff (51 lines)
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
-----BEGIN PGP SIGNATURE-----

iIoEARYIADIWIQSjzJyHC50xCrrUzy9RcisI/kdFogUCZ2MyDxQcc2ltb25Aam9z
ZWZzc29uLm9yZwAKCRBRcisI/kdFohOiAP9M1lkpygkqn3WVp03fj5V3wWeGYSuM
OpYEbgUfmOxwowD9E7bmWBNzJTVMGVHbpsTqperCPfJ9fvtb4E0ryV+RvwQ=
=Gd72
-----END PGP SIGNATURE-----

L
L
Leo Famulari wrote 15 hours ago
(name . Simon Josefsson via Bug reports for GNU Guix)(address . bug-guix@gnu.org)(address . 74952@debbugs.gnu.org)
Z2NEyYfmnuWr60r-@jasmine.lan
On Wed, Dec 18, 2024 at 09:35:27PM +0100, Simon Josefsson via Bug reports for GNU Guix wrote:
Toggle quote (7 lines)
> 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'.
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 74952@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 74952
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch