From: Simon Josefsson via Guix-patches via <guix-patches@gnu.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: Mathieu Othacehe <othacehe@gnu.org>,
Josselin Poiret <dev@jpoiret.xyz>,
74962@debbugs.gnu.org,
Maxim Cournoyer <maxim.cournoyer@gmail.com>,
Janneke Nieuwenhuizen <janneke@gnu.org>
Subject: [bug#74962] [PATCH v3 4/5] etc/guix-install.sh: Remove 'which' commands from requirements.
Date: Thu, 26 Dec 2024 13:34:21 +0100 [thread overview]
Message-ID: <87v7v6tygi.fsf@kaka.sjd.se> (raw)
In-Reply-To: <878qs2zpaf.fsf@gnu.org> ("Ludovic Courtès"'s message of "Thu, 26 Dec 2024 11:55:52 +0100")
[-- Attachment #1: Type: text/plain, Size: 2136 bytes --]
Ludovic Courtès <ludo@gnu.org> writes:
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> * etc/guix-install.sh (REQUIRE): Remove "which". Add "nologin".
>> (sys_create_build_user): Use 'type' instead of 'which'.
>>
>> Fixes: <https://issues.guix.gnu.org/74952>
>> Reported-by: Simon Josefsson <simon@josefsson.org>
>> Change-Id: I0675716bab3fc22d3289ee7af2cb0ab33a1cee71
>
> LGTM.
Using 'type -P' is not POSIX and neither /bin/dash nor /bin/gash
supports it. It seems like a GNU bash extension. Is that okay?
The snippet ends up in the manual as recommendations for users to run on
different operating systems. We may want to assume GNU bash to favor
it, but I'm not sure if that is really helping users.
If 'type -P' is used, shouldn't that really be 'type -fP' to avoid shell
function expansion? It isn't all that clear from the man page if -f is
still needed for -P or not:
https://manpages.debian.org/bookworm/bash/bash.1.en.html#type
Even so 'type' uses hashed names, do they survive sub-shell $()
execution? If type is to be used, maybe this should be:
$(hash -r nologin && type -Pf nologin)
My suggestion was to use 'command -v nologin' which behaviour is
standard POSIX /bin/sh. I acknowledge that it has the trouble of
expanding to an alias if the shell had 'nologin' aliases somehow
(unlikely but not impossible).
$(unalias nologin; command -v nologin)
It seems all of the options (which, type -P, command -v) has another
unwanted property: if 'nologin' is not available in the path, these
commands expand to the empty string, and that empty string gets passed
to 'useradd -s STR -c ...' and the user gets an ugly error message about
'-c' not being a proper shell.
I wonder what all this solves compared to hard-coding "/" as the login
shell for the guixbuild user?
Here is source code for nologin, which we seem to make some effort to
use - is this better than 'false'?
https://github.com/shadow-maint/shadow/blob/master/src/nologin.c
At least I'm happy nobody wants to keep using 'which'.
I am sorry for the rabbit hole :)
/Simon
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 255 bytes --]
next prev parent reply other threads:[~2024-12-26 12:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 6:57 [bug#74962] [PATCH] etc/guix-install.sh: Explicit shebang to use /usr/bin/env Maxim Cournoyer
2024-12-19 7:17 ` [bug#74962] [PATCH 1/3] etc/teams.scm: Add etc/guix-install.sh to installer team scope Maxim Cournoyer
2024-12-19 7:17 ` [bug#74962] [PATCH 2/3] etc/guix-install.sh: Explicit shebang to use /usr/bin/env Maxim Cournoyer
2024-12-19 8:18 ` Janneke Nieuwenhuizen
2024-12-19 12:48 ` Maxim Cournoyer
2024-12-19 7:17 ` [bug#74962] [PATCH 3/3] etc/guix-install.sh: Fix quoting and other issues Maxim Cournoyer
2024-12-26 10:55 ` Ludovic Courtès
2024-12-19 7:45 ` [bug#74962] [PATCH v3 1/5] etc/teams.scm: Add etc/guix-install.sh to installer team scope Maxim Cournoyer
2024-12-19 7:45 ` [bug#74962] [PATCH v3 2/5] etc/guix-install.sh: Explicit shebang to use /usr/bin/env Maxim Cournoyer
2024-12-19 7:45 ` [bug#74962] [PATCH v3 3/5] etc/guix-install.sh: Fix quoting and other issues Maxim Cournoyer
2024-12-26 10:56 ` Ludovic Courtès
2024-12-19 7:45 ` [bug#74962] [PATCH v3 4/5] etc/guix-install.sh: Remove 'which' commands from requirements Maxim Cournoyer
2024-12-26 10:55 ` Ludovic Courtès
2024-12-26 12:34 ` Simon Josefsson via Guix-patches via [this message]
2024-12-19 7:45 ` [bug#74962] [PATCH v3 5/5] etc/guix-install.sh: Sort requirements Maxim Cournoyer
2024-12-26 11:00 ` Ludovic Courtès
2024-12-26 10:54 ` [bug#74962] [PATCH] etc/guix-install.sh: Explicit shebang to use /usr/bin/env Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v7v6tygi.fsf@kaka.sjd.se \
--to=guix-patches@gnu.org \
--cc=74962@debbugs.gnu.org \
--cc=dev@jpoiret.xyz \
--cc=janneke@gnu.org \
--cc=ludo@gnu.org \
--cc=maxim.cournoyer@gmail.com \
--cc=othacehe@gnu.org \
--cc=simon@josefsson.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).