Message ID | 6d1f4ffaa70f4cfb3ed9e18b46fe3cedb44025f2.1734594333.git.maxim.cournoyer@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E3A9727BBEA; Thu, 19 Dec 2024 07:48:35 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6F05D27BBE2 for <patchwork@mira.cbaines.net>; Thu, 19 Dec 2024 07:48:34 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1tOBGR-0002w2-Kl; Thu, 19 Dec 2024 02:48:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tOBGO-0002uw-Cc for guix-patches@gnu.org; Thu, 19 Dec 2024 02:48:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tOBGO-0002l5-3i; Thu, 19 Dec 2024 02:48:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=QfXLRdKWac+l1JVI0CcxwfLR7mQ3W5V+OryjERhOp70=; b=VyDFBDUT6RWi71GV32wq3CkbpgPfMQJnvxXa8F1a8Z3iD4tiZav6VQBB4iWmvEPJdfBc4MlC8Sx4FV5WUJZI0GW4CJmC2xnYw3pJ2YzXo6dAuLXOoy38bR8gPYaIKemRJiF5beStgfrfyQzMLTWk5Tma4V3e1QltVL8EiToy0dMC+5nXPui62HD+6NQpCOdHo9NNntV0y6Rz3wTA/JIb+1u9F0YShUTxmk0zbyjK8fng/wp2Eh8OMTyijSicxagxZq1lzm2zD1iW8GDPA9U8eH9065V27k3kxQzAeKUFq2P48i2tyYndW7uYIcSzMX/Q2aZfRtoLzDJk8W8AV/6JTw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1tOBGN-0008Ih-U9; Thu, 19 Dec 2024 02:48:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74962] [PATCH v3 4/5] etc/guix-install.sh: Remove 'which' commands from requirements. Resent-From: Maxim Cournoyer <maxim.cournoyer@gmail.com> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: janneke@gnu.org, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, guix-patches@gnu.org Resent-Date: Thu, 19 Dec 2024 07:48:03 +0000 Resent-Message-ID: <handler.74962.B74962.173459444931817@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74962 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74962@debbugs.gnu.org Cc: Simon Josefsson <simon@josefsson.org>, Maxim Cournoyer <maxim.cournoyer@gmail.com>, Janneke Nieuwenhuizen <janneke@gnu.org>, Josselin Poiret <dev@jpoiret.xyz>, Ludovic =?utf-8?q?Court=C3=A8s?= <ludo@gnu.org>, Mathieu Othacehe <othacehe@gnu.org> X-Debbugs-Original-Xcc: Janneke Nieuwenhuizen <janneke@gnu.org>, Josselin Poiret <dev@jpoiret.xyz>, Ludovic =?utf-8?q?Court=C3=A8s?= <ludo@gnu.org>, Mathieu Othacehe <othacehe@gnu.org> Received: via spool by 74962-submit@debbugs.gnu.org id=B74962.173459444931817 (code B ref 74962); Thu, 19 Dec 2024 07:48:03 +0000 Received: (at 74962) by debbugs.gnu.org; 19 Dec 2024 07:47:29 +0000 Received: from localhost ([127.0.0.1]:37288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1tOBFp-0008H0-5I for submit@debbugs.gnu.org; Thu, 19 Dec 2024 02:47:29 -0500 Received: from mail-pg1-f175.google.com ([209.85.215.175]:44096) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <maxim.cournoyer@gmail.com>) id 1tOBFm-0008GU-Tg for 74962@debbugs.gnu.org; Thu, 19 Dec 2024 02:47:27 -0500 Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-7fd17f2312bso305058a12.0 for <74962@debbugs.gnu.org>; Wed, 18 Dec 2024 23:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734594381; x=1735199181; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QfXLRdKWac+l1JVI0CcxwfLR7mQ3W5V+OryjERhOp70=; b=fqURryhHD48rnWcZwIRuuliByu78NRdrXIVUDMYBbWGomWqcfiKqyO2VO+ZPBDbE6s Wxvg2/vWI8VBut/ew44OgYRrYxVs2a29cxpJKvHcbpUZK0DDf69yF+dHkNv3wdALGNWa AOGEuwQhqCjbwiPnQlKx/I29dQHFS7dAQULveg3ptXdksC5g0GRu4IGgAcYx9LoBmvoe lRVlNOIGmEGGreDyb7aoL5NEV97HUUzUgohX7zgPFS/fxTXsRoPbfCWCPN5/yuyCW51A r7sgqvH4C1ZfhIPKHR6VOEf+iQwSAEawD7Jf8iKRFLc3FDjGApTPE4utogLHR4gZ1bKt KdKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734594381; x=1735199181; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QfXLRdKWac+l1JVI0CcxwfLR7mQ3W5V+OryjERhOp70=; b=cqfg8baf7qP3rbPBAc6McURm/d0qcbEs+MWadexEks4wi88mbFNo0BI6VmN4MWCvoj mayR0RCHe9oPW/JG4HtWv3/LipqnHQZvpXIqKv4RWG+ZireKyIkZYfvORMl3oSD0T+FH nFZImVhjeX8KulGHjhMQ9e9u4A9viaVVR5BHvmNq5n6t72TQ4BNrWRmnafrZqVvXW5n/ H8lEdCmpBjh5tXFEmowqsJkT2S05k7j5jpb1/efSoXNGkoqnVQmkVcoNE1zCJk7hICSD FHNAKVk54wdODbQKxKRfT8IP+15J/gaSINLGdnfxoNUkHQcma8I7LGLclbekspvZcYyV r/jg== X-Gm-Message-State: AOJu0YxcaniTMNUrSJdWVhC/4RQLJamGrmxUiIeKQWhT8EuWecXrF1LA ehQIV0e+bfYFH6kGsQzqtzASEFQBSsV6qDrOOktCtLCkFL5FvbB7inSE1hMU9hE= X-Gm-Gg: ASbGncuVfDhxlfSkYvpsCYBtedRUuwwTMYHzutX28rfWAeCv3ufAcX6hU0Xu0bQM13l Ly2HbM50IwdYxho8JJo2G27nAR3qAwEJ7H6GBp+laq1kdv7shnpBhv8DGzQJ933UeoNVlw07xZe jpCI6W3SmlW0v7Cv50sRj15A1STuoqMUoF2SelzwctsTQ+OEHGSBz5mdCePYKot8rCa/dv1MBbv zw+mH04aCsaLxAva2RRfgbWf2Di5y5dpWtN5uj0ivs/wwKYS+GLv/Vj09UzFuUgom39qe6wek0= X-Google-Smtp-Source: AGHT+IEi8kkno3BmGpVLxKtgaXOqqPvrAlEoyupybimJMODH97HA5Zkfv9i6jUFsGjnUrc0sQ9iYIA== X-Received: by 2002:a17:90b:524f:b0:2f4:49d8:e6f6 with SMTP id 98e67ed59e1d1-2f449d8e82emr1288257a91.3.1734594380685; Wed, 18 Dec 2024 23:46:20 -0800 (PST) Received: from localhost.localdomain ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2ed62e390sm2632821a91.21.2024.12.18.23.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 23:46:20 -0800 (PST) From: Maxim Cournoyer <maxim.cournoyer@gmail.com> Date: Thu, 19 Dec 2024 16:45:32 +0900 Message-ID: <6d1f4ffaa70f4cfb3ed9e18b46fe3cedb44025f2.1734594333.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <3d0ccfc5f28f48b0a4e513e4ebfd3018c85b4407.1734594333.git.maxim.cournoyer@gmail.com> References: <3d0ccfc5f28f48b0a4e513e4ebfd3018c85b4407.1734594333.git.maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches |
Series |
[bug#74962,v3,1/5] etc/teams.scm: Add etc/guix-install.sh to installer team scope.
|
|
Commit Message
Maxim Cournoyer
Dec. 19, 2024, 7:45 a.m. UTC
* 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 --- Changes in v3: - New. etc/guix-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Comments
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.
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
Simon Josefsson <simon@josefsson.org> skribis: > 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? Oh, not great. From what you write, I’m not sure what to conclude; just skip this patch and be done with it? Thanks! Ludo’.
Hi, Ludovic Courtès <ludo@gnu.org> writes: > Simon Josefsson <simon@josefsson.org> skribis: > >> 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? > > Oh, not great. From what you write, I’m not sure what to conclude; > just skip this patch and be done with it? We currently use other Bash-specific features, so I think it's fine to embrace the Bash requirement instead of shying away from it. If we decide that we don't want Bash as a requirement at some point, we'll have to change a bunch of things; one of them would be to no longer make use of arrays since POSIX shells don't have them, for example.
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes: > Hi, > > Ludovic Courtès <ludo@gnu.org> writes: > >> Simon Josefsson <simon@josefsson.org> skribis: >> >>> 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? >> >> Oh, not great. From what you write, I’m not sure what to conclude; >> just skip this patch and be done with it? > > We currently use other Bash-specific features, so I think it's fine to > embrace the Bash requirement instead of shying away from it. > > If we decide that we don't want Bash as a requirement at some point, > we'll have to change a bunch of things; one of them would be to no > longer make use of arrays since POSIX shells don't have them, for > example. There is a difference to use bashisms in code in Guix intended to be run on bash, and code we have in the manual that is suggested to be used on other operating system as part of the Guix installation process. There appears to be no perfect solution here. I think 'command -v nologin' is the closest. Or just keep the code as-is and use 'which', but that caused my initial problem (lack of 'which'). I'd like to second-guess why we even bother with using "nologin" instead of simply hard-coding "/bin/false" or why not "/" which I suppose is not a executable shell on any system. /Simon
Hi Simon, Simon Josefsson <simon@josefsson.org> writes: > 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? I think it's OK, since we currently mandate Bash, but we could use 'command -v the-command > /dev/null' for the same result, which *is* POSIX, so perhaps we should use that instead. > 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 I think we'd have to use -f if we want to guard against shell functions being found instead; but maybe then it's simpler and clearer to just use 'command -v' as I mentioned above. > 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). I agree; I'll make the change. Perhaps adjust the other 'type' usages also (there was only 2). > $(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. Yuck. > 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 It seems marginally better than using 'false' in that it logs something to syslog when a login is attempted and fail :-). > At least I'm happy nobody wants to keep using 'which'. > > I am sorry for the rabbit hole :) Thanks for the comments. I'll send a reworked version.
diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 8d3d9d224b..fb22287cf4 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -58,7 +58,7 @@ REQUIRE=( "wget" "gpg" "grep" - "which" + "nologin" "sed" "sort" "getent" @@ -429,12 +429,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 "$(type -P 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 "$(type -P nologin)" \ -c "Guix build user $i" --system \ "guixbuilder${i}"; _msg "${PAS}user added <guixbuilder${i}>"