From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id SFgSFu+GxGM1qwAAbAwnHQ (envelope-from ) for ; Mon, 16 Jan 2023 00:06:23 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 2PE5Fe+GxGNBMgEAG6o9tA (envelope-from ) for ; Mon, 16 Jan 2023 00:06:23 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0C50E2CBA7 for ; Mon, 16 Jan 2023 00:06:23 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHC4h-0003sl-Vl; Sun, 15 Jan 2023 18:06:04 -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 ) id 1pHC4g-0003ro-Oa for bug-guix@gnu.org; Sun, 15 Jan 2023 18:06:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHC4g-0000fB-GI for bug-guix@gnu.org; Sun, 15 Jan 2023 18:06:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pHC4g-0000p5-11 for bug-guix@gnu.org; Sun, 15 Jan 2023 18:06:02 -0500 Subject: bug#60566: [PATCH] environment: Fix '--emulate-fhs' option overriding $PATH. Resent-From: John Kehayias Original-Sender: "Debbugs-submit" Resent-To: bug-guix@gnu.org Resent-Date: Sun, 15 Jan 2023 23:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 60566 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: jman , 60566-done@debbugs.gnu.org Mail-Followup-To: 60566@debbugs.gnu.org, john.kehayias@protonmail.com, jman@city17.xyz Received: via spool by 60566-done@debbugs.gnu.org id=D60566.16738239283107 (code D ref 60566); Sun, 15 Jan 2023 23:06:01 +0000 Received: (at 60566-done) by debbugs.gnu.org; 15 Jan 2023 23:05:28 +0000 Received: from localhost ([127.0.0.1]:59891 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHC47-0000o2-Re for submit@debbugs.gnu.org; Sun, 15 Jan 2023 18:05:28 -0500 Received: from mail-4316.protonmail.ch ([185.70.43.16]:39935) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHC46-0000no-3V for 60566-done@debbugs.gnu.org; Sun, 15 Jan 2023 18:05:26 -0500 Date: Sun, 15 Jan 2023 23:05:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1673823920; x=1674083120; bh=1u3kZqJ0rDg2pNKqXwNGXzqAX5bge5+73Qf5Y92d0bU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Mi/Ty+Lp4KOH8XEkK58sI0uFwyMWwlZ4Q2Z/T+5+4rrZ6q3WrJsrxgRH6Dsv/HZGP Bi0rkrEsRflI/YwLEZLXPA8pqjslTJCZu24USw6NjuZPHh1br0FRWQEosBDw33L+yn sje3lThfxEWsJe3AOkksrTc7QpnXbvaHjCTL63G91M0zLf68AbKZZdxEjIrgktKrKJ A1sKUK/PgsLCRPwPapbjGluBU+0NwO+N9AtPbr+VnrUSAFdMjX2K3PkEXxeIpZCZSa eT9IOCUVEuIRzJ7sPui4OFNX1brQc2ip9aoIfYLEIpUzfXxdW4ojETXVXOJIoU5FVq PB4Qyv35p4GnA== Message-ID: <87wn5n8km5.fsf@protonmail.com> In-Reply-To: <87ilh99o1g.fsf@gnu.org> References: <874jt4k7bl.fsf@protonmail.com> <874jt3xo37.fsf@gnu.org> <87zgam85yj.fsf@protonmail.com> <87ilh99o1g.fsf@gnu.org> Feedback-ID: 7805494:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: John Kehayias From: John Kehayias via Bug reports for GNU Guix Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=protonmail.com header.s=protonmail3 header.b="Mi/Ty+Lp"; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1673823983; a=rsa-sha256; cv=none; b=MVAz3rWXTj3n1UuQywAvZmyOInkWdBLtpCKCc+SmWpWtx5REMoH89oqAXx1ET2sroXMY+c pY08SvtpDhUDPvEr+ZCEh28B5r/GmiClHqb+SRpos1zJeTpfG1t5OZdFwM4K0z1lw/F2x2 UoPnu1Np8PAU63XyTpTZk1DKrZnbBTWN4tFAyS4kkRynUK3nxMNqvrHKruSoXNpiBHuw0H IDH4hfzFYSXKxjfILDGZH+uOa8FCLDRUjhxjq6IcyToUHD+cxVrrZ1vaJZk0vjqz2Wnr0U LncUOwd0No56U9DK7tlsNnHxfC2l2esS77FNKLRQY9sl59mLJknDvKe8iJV3XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1673823983; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-to: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=1u3kZqJ0rDg2pNKqXwNGXzqAX5bge5+73Qf5Y92d0bU=; b=jbCAVdBWvGh1aMDJoYX/6fElIjkqzVJ3NutLnY00LB0yPDAykR+LG9Hc7hUnh2xQvKnD19 wN+NLq/5f6jsYvTKupyxbsYvkHDx84FanxtayLwgls9W3se6RyHa54HwWOytKlhzi94Mbo MFd6MZ4IStcsDnSXjw5UUf8ZXOBcix3104H8iVTQOGWccnAt3U6RLLAUf7ZDXyacpjk774 xEAgF9nlAF0Ug6NNW+YCBe+FEof286mx6zFqlNyHvfDfOGmHmZw4zVcXO7+cyKavNaL/y6 jwerZ2XxFiuijqZJtyxtQ2oluJhnMbJ60LTHoNLEIvY9ftE7fSuWAgakgzrFnA== X-Migadu-Queue-Id: 0C50E2CBA7 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=protonmail.com header.s=protonmail3 header.b="Mi/Ty+Lp"; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org X-Migadu-Spam-Score: -2.92 X-Spam-Score: -2.92 X-TUID: jTL1WVcuFHw7 Hi Ludo=E2=80=99, On Sat, Jan 14, 2023 at 03:41 PM, Ludovic Court=C3=A8s wrote: > Hi John, > > John Kehayias skribis: > > [...] > >> - (setenv "PATH" "/bin:/usr/bin:/sbin:/usr/sbin") >> + (setenv "PATH" (string-append "/bin:/usr/bin:/sbin:/usr/sbin= " >> + (when (getenv "PATH") >> + (string-append ":" (getenv "= PATH"))))) > > Remember that =E2=80=98when=E2=80=99 returns *unspecified* when the condi= tion is false, > so you=E2=80=99d get a type error here when PATH is undefined. > > Instead write: (if (getenv "PATH") =E2=80=A6 ""). > Ah yes, my Common Lisp showing through and relying on nil instead. Fixed an= d thanks! >> +# Test that $PATH inside the container has FHS directories. >> +guix shell -CF --bootstrap guile-bootstrap \ >> + -- guile -c '(exit (if (string-contains (getenv "PATH") >> + "/bin:/usr/bin:/sbin:/usr/sbin") >> + 0 >> + 1))' > > Even (exit (string=3D? (getenv "PATH") "/bin:/usr/bin:/sbin:/usr/sbin")). > With this patch PATH now gets the FHS directories in addition to what it no= rmally has (like the profile's bin directory). While slightly redundant, th= is seems to be better than clobbering it. Anyway, so we can't check that th= e PATH is completely equal here. >> +# Make sure '--preserve' is honored for $PATH, which the '--emulate-fhs= ' >> +# option will modify. We can't (easily) check the whole $PATH as it wi= ll >> +# differ inside and outside the container, so just check for an added s= tring. >> +PATH=3Dthis-is-a-test:$PATH guix shell -CF --bootstrap guile-bootstrap = -E PATH \ >> + -- guile -c '(exit (if (string-contains (getenv "PATH") >> + "this-is-a-test") >> + 0 >> + 1))' > > It might be slightly more concise with =E2=80=98env=E2=80=99: > > PATH=3D/foo $(type -P guix) shell -E ^PATH$ -C coreutils -- env |grep ^= PATH=3D.*:/foo > > (I think =E2=80=98--bootstrap=E2=80=99 doesn=E2=80=99t buy us much here b= ecause we have to > download/build =E2=80=98glibc-for-fhs=E2=80=99 anyway. =E2=80=98--bootst= rap=E2=80=99 and > =E2=80=98guile-bootstrap=E2=80=99 are particularly useful for testse that= can run > without network access and without building tons of stuff, as in > =E2=80=98tests/guix-environment.sh=E2=80=99 for instance.) > Ah, thanks, that is nicer if we can just use coreutils. I rewrote the previ= ous test to use that as well. Probably some other tests here could use that= simplification, but outside of the scope here. (Side note that 'type' in zsh works differently, one could use 'whence' the= re or even the built-in 'which'. For the tests we are running with bash or = bash compliant here, so it is not a problem.) > Otherwise LGTM, thanks! > > Ludo=E2=80=99. Thanks again for your careful review! Pushed as 3bfbfa2946aebb7f68c8027ae80= f272f6915c94f and closing this issue. Thanks also for jman for reporting. John