From unknown Sat Aug 16 14:50:54 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#77707 <77707@debbugs.gnu.org> To: bug#77707 <77707@debbugs.gnu.org> Subject: Status: [shepherd] chdir and invoke do not work as intended in services Reply-To: bug#77707 <77707@debbugs.gnu.org> Date: Sat, 16 Aug 2025 21:50:54 +0000 retitle 77707 [shepherd] chdir and invoke do not work as intended in servic= es reassign 77707 guix submitter 77707 Maxim Cournoyer severity 77707 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 10 10:44:37 2025 Received: (at submit) by debbugs.gnu.org; 10 Apr 2025 14:44:37 +0000 Received: from localhost ([127.0.0.1]:46234 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u2t8v-0001cs-6W for submit@debbugs.gnu.org; Thu, 10 Apr 2025 10:44:37 -0400 Received: from lists.gnu.org ([2001:470:142::17]:33876) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u2t8s-0001cX-9L for submit@debbugs.gnu.org; Thu, 10 Apr 2025 10:44:35 -0400 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 1u2t8l-0007sJ-Ma for bug-guix@gnu.org; Thu, 10 Apr 2025 10:44:27 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u2t8j-0000ZJ-Mi for bug-guix@gnu.org; Thu, 10 Apr 2025 10:44:27 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-223fb0f619dso9252815ad.1 for ; Thu, 10 Apr 2025 07:44:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744296263; x=1744901063; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=2m4DjMl7W1kcPqSZFvNPfZYJVky1K9XfIWFlCSRmJrc=; b=G/FFUjndLkWXfsmJgL+Z7UDcAJbz3yWQKWj9yHIZalB91RUTtzkNcr42Ax44ldu9rJ T/fPgiTifBCBRJyDZu1wl3AUOi0fD0n5mUKtiwpppW2VKI2McsAukRnps/RJg02mlBz1 E6Pzz8NGoCFvZOMZxITDfjFOC8Cq5qWAivxBZAdVuVOyPN0Fi9G1fsBP8eMKJ+o4P2Sg 4H7eY4aVh8lvnhLTDmeARwI33y5orKl7qHy5A+Y2KOibuRNoV4FSeX3YfB4ZVnfZK1VH 5JB6eCHvybC31LzJbsOwP6l1eYnOjPtKJzPJ14EuZQ93zyf/9MSf+k7hf6407J2PUoP9 0ktw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744296263; x=1744901063; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=2m4DjMl7W1kcPqSZFvNPfZYJVky1K9XfIWFlCSRmJrc=; b=BwXsMRf8AqihOEzjns1r4+ytDUp4k/PaUpmfNpPRMKtJ8Aco9H7lR2ePqHwTvvLO35 2ogeZ0I4vQvBpQ87FXOWcu3w23S09E1MLSD2H+NwpsaEYlaKO10s93h4EtV3Q/fklyAA lE034Byz1x4irClYZM/AHsjkrgnIRbFDU+ASYQuFSXPQTwnlfHqEywjDW0n/ONPxomx1 +JU3IMlO7QwUngHltl7sh2JqEeVP7sE+6GKyqwxLA216NbBUqX0pj8AoirQW1NXd5lRe Lgy974GSVd/gyB/7nE0u86Y8tAzhaxC4RaVWKbYUTcWI4F6bGiTlwV554oULiFw6ZbCH mnHw== X-Gm-Message-State: AOJu0YzFYlIwx1HB3ukop3qvpibUAP5PXIVNqXeO6cw8aJmQNQAaXIT2 Dz4yJAduxo/bRmdfP6IaA/EhV4Y++ivAJ72Jfrqa5hmfYbwA3q2KNwu2/j0G X-Gm-Gg: ASbGncs9zJz4AEnLZ0LjM7Fue2ic9aCjN68l83Lzd2bB1qbbsV8AKrVk5+YU4tCZ9cA SwRJYCXiaWeoJ8XisMW7O3uTClyhKIMgZZ4w1G+lrN0CpjIuqRhWYiQC/nvwevSeLF7asN/nBBV wleM6ChWzJ4o1vo5yDg4BcJddqQQC3ogZFggjp2iSlKZGgD6S76iFhbUfAl0/T0kSh59q4JNMMq b7BJqFh5XgwuOyDY/pYPw/nKZ823sOJt42nrPqozknnPmSfqgeExLzVFYAISGnJLww+hug63SSu UQlnPxK9rKWZ4hK1OcdN8A8gmf+RJVZjYsyx6DCZyicJvr83sA== X-Google-Smtp-Source: AGHT+IGssvq/wtr9lbX3SuF/d4Cgo+gzb7qk1u6LAPxpGZFmj6cSaKw14a9G6e6fA/6z0kS/g2APAA== X-Received: by 2002:a17:903:22c1:b0:223:653e:eb09 with SMTP id d9443c01a7336-22b2edae52fmr40415965ad.7.1744296263030; Thu, 10 Apr 2025 07:44:23 -0700 (PDT) Received: from terra ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73bb1d2aea9sm3354023b3a.29.2025.04.10.07.44.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Apr 2025 07:44:22 -0700 (PDT) From: Maxim Cournoyer To: bug-guix Subject: [shepherd] chdir and invoke do not work as intended in services Date: Thu, 10 Apr 2025 23:44:04 +0900 Message-ID: <87r020xeiz.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=maxim.cournoyer@gmail.com; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Hi, It appears that when changing directory and calling a program with 'invoke', the program still has its current working directory set to '/'. I'm betting this may be some kind of odd interaction between the Shepherd service threads and forking a process? Can we improve that? If it's a limitation of the implementation model, than I think it's a surprising enough gotcha to warrant documenting it in Shepherd's manual. Here's a simple reproducer: --8<---------------cut here---------------start------------->8--- modified gnu/system/examples/bare-bones.tmpl @@ -3,8 +3,8 @@ ;; for a "bare bones" setup, with no X11 display server. (use-modules (gnu)) -(use-service-modules networking ssh) -(use-package-modules screen ssh) +(use-service-modules networking shepherd ssh) +(use-package-modules base screen ssh) (operating-system (host-name "komputilo") @@ -47,7 +47,20 @@ ;; Add services to the baseline: a DHCP client and an SSH ;; server. You may wish to add an NTP service here. - (services (append (list (service dhcp-client-service-type) + (services (append (list (simple-service + 'forked-processes-cwd-wrong + shepherd-root-service-type + (list + (shepherd-service + (provision '(bug-77115)) + (start #~(lambda _ + (mkdir "/etc/testdir") + (chdir "/etc/testdir") + (invoke #$(file-append coreutils "/bin/touch") + "new-file.txt") + #t)) + (one-shot? #t)))) + (service dhcp-client-service-type) (service openssh-service-type (openssh-configuration (openssh openssh-sans-x) --8<---------------cut here---------------end--------------->8--- Then run it from your tree using something like: --8<---------------cut here---------------start------------->8--- $(./pre-inst-env guix system vm gnu/system/examples/bare-bones.tmpl --no-graphic) --8<---------------cut here---------------end--------------->8--- You should see upon inspection that: --8<---------------cut here---------------start------------->8--- root@komputilo ~# ls /new-file.txt /new-file.txt # wrong place root@komputilo ~# ls /etc/testdir/ # empty --8<---------------cut here---------------end--------------->8--- -- Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 13 15:52:49 2025 Received: (at 77707-done) by debbugs.gnu.org; 13 Apr 2025 19:52:49 +0000 Received: from localhost ([127.0.0.1]:43971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u43No-0007LZ-RZ for submit@debbugs.gnu.org; Sun, 13 Apr 2025 15:52:49 -0400 Received: from hera.aquilenet.fr ([185.233.100.1]:51396) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u43Nl-0007LF-0M for 77707-done@debbugs.gnu.org; Sun, 13 Apr 2025 15:52:46 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 1F0594F; Sun, 13 Apr 2025 21:52:38 +0200 (CEST) Authentication-Results: hera.aquilenet.fr; none X-Virus-Scanned: Debian amavis at hera.aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavis, port 10024) with ESMTP id xzoXMAveULO2; Sun, 13 Apr 2025 21:52:37 +0200 (CEST) Received: from ribbon (91-160-117-201.subs.proxad.net [91.160.117.201]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 442B38E1; Sun, 13 Apr 2025 21:52:30 +0200 (CEST) From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Maxim Cournoyer Subject: Re: bug#77707: [shepherd] chdir and invoke do not work as intended in services In-Reply-To: <87r020xeiz.fsf@gmail.com> (Maxim Cournoyer's message of "Thu, 10 Apr 2025 23:44:04 +0900") References: <87r020xeiz.fsf@gmail.com> Date: Sun, 13 Apr 2025 21:52:29 +0200 Message-ID: <87mscjdeki.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 1F0594F X-Spamd-Result: default: False [-5.84 / 15.00]; NEURAL_HAM(-3.00)[-1.000]; BAYES_HAM(-2.74)[98.88%]; MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[] X-Rspamd-Action: no action X-Spamd-Bar: ----- X-Rspamd-Server: hera X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 77707-done Cc: 77707-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) Hi, Maxim Cournoyer skribis: > + (start #~(lambda _ > + (mkdir "/etc/testdir") > + (chdir "/etc/testdir") > + (invoke #$(file-append coreutils= "/bin/touch") > + "new-file.txt") [...] > You should see upon inspection that: > > root@komputilo ~# ls /new-file.txt=20 > /new-file.txt # wrong place > root@komputilo ~# ls /etc/testdir/ # empty That=E2=80=99s because =E2=80=98invoke=E2=80=99 uses =E2=80=98system*=E2=80= =99, which is in fact within the =E2=80=98shepherd=E2=80=99 process an alias for =E2=80=98spawn-command=E2= =80=99. This is fixed in 8d88024e0898dd7d4581c4e977c9786af734a855, which will be in 1.0.4. However generally speaking it=E2=80=99s a good idea to leave the current directory of the =E2=80=98shepherd=E2=80=99 process unchanged as bad things= could happen otherwise (though =E2=80=98with-directory-excursion=E2=80=99 from (shepherd= support) should be safe.) Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 13 20:31:23 2025 Received: (at 77707) by debbugs.gnu.org; 14 Apr 2025 00:31:23 +0000 Received: from localhost ([127.0.0.1]:44587 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u47jO-0005XJ-R8 for submit@debbugs.gnu.org; Sun, 13 Apr 2025 20:31:23 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:57419) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u47jJ-0005Ww-89 for 77707@debbugs.gnu.org; Sun, 13 Apr 2025 20:31:20 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-224100e9a5cso39939165ad.2 for <77707@debbugs.gnu.org>; Sun, 13 Apr 2025 17:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744590670; x=1745195470; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f+TKAOcui1Wq5XcWG/SlJxuwLjuEAg+bvHFqP3rElKM=; b=fZtAw5/WiSFGCKmZbeVnuP7p043W8Ik9ASCWZfFyFEfB+thmCwvQIgYwhkqDnoM574 KYl8RlWgOKx6B6AsRabHIhBgcUlsqKZZZ5deVqEaHK+y9UoEBCJ8pyM+K7Xjt5MlHl5p LnzwIXBxtIQA8CZOTpSoFkAHI5YMdqHKmPxifNGv3Mbuj2tPytZgojqCOh4vDz2iwUxU rJGj3UeBtE/HUrO5exQtIDnf3iS0H+3+j/jfeL02D0qKJSslya/ebqAWL3pntyzmXmE9 8mpEzZ00ojBCAebk6ieEiMH/LnA2q1xrw9hgEA5Ya1S2PExTzhKeaO1bkO6CJCMqWk2c SD6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744590670; x=1745195470; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=f+TKAOcui1Wq5XcWG/SlJxuwLjuEAg+bvHFqP3rElKM=; b=K0fHeeDKGHJvldZIYFE6mNaKrE72pxbtGMhIEHc9s4d9GrA1aRahDDRlFUHOPdTVV1 7k/CiefuoK7+R6jMPRfHlN7IH7hCCbAJiHhPLQbIa7tTC98rE3fAu1mmKamSecAbMhFa RFHkE+bu4w3V9R/7YQLvXMo9LzQ/FB4te121Vy/VIfEeqhl/3dDK8S6n6+9nKQssWrDL UMQd/+ry3vpvRd5lLD1MTcMTujpXgHczyyncHawhFC5vT47pvny1Q/u5+403LmtwDGj1 4viezwVCEYOiLvdv6Xr1avKyWz4JXh/2iSLwQE/kK5k2yRz4/W6rShxxbX/ddc+FNdno brNg== X-Gm-Message-State: AOJu0YwMJ5CKZjIDr3jONtJMrAJ1pTnrcJAkYDkeH6Q+4EEnUPKtoG5l SlIooTh0Vlyf204SeRd10CaWtAaCIC9KTinm423DI7rBy8IOPjjM1+hicA== X-Gm-Gg: ASbGncvDOxgO/WEJBj6F0p81fX/dt4F8dG5OXJuvVprFVY5f4qBGCcqLCtpUUamVqTJ CSP9mKD33w7iuuVM9HytpQpBLZ1jsulQW7DHZhTweIhbCQEIpJmJzCgSG3Ki10q0nC/W2wv0DN1 /FJjfb+GYVSy8lXcOUDun6F6wNqstZuv84UnA2h1jqqIpO4Y40KeoK7ZNdO1ekA8THWoivG7j3u H2zfBjVzPzSxK3TeE4Y+5ZmIOvNXr5IePSQikcEklvH5vgZLCO1ahgifGYJeCE+6VHngMkKqMRA 5zVvU/gWglwShr02jveV+HeMDDvEnTwX26F+IfU= X-Google-Smtp-Source: AGHT+IHY93yz4/ZpGQ5u+rQf/B2Ho692wXLtI1fKyqC5lrRPEYzracA882ph0W1ShszlkkkTl7Rktw== X-Received: by 2002:a17:903:98b:b0:224:1781:a950 with SMTP id d9443c01a7336-22bea4aba54mr141148915ad.14.1744590669872; Sun, 13 Apr 2025 17:31:09 -0700 (PDT) Received: from terra ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22ac7c97207sm87951615ad.129.2025.04.13.17.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Apr 2025 17:31:09 -0700 (PDT) From: Maxim Cournoyer To: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: Re: bug#77707: closed (Re: bug#77707: [shepherd] chdir and invoke do not work as intended in services) In-Reply-To: (GNU bug Tracking System's message of "Sun, 13 Apr 2025 19:53:02 +0000") References: <87mscjdeki.fsf@gnu.org> <87r020xeiz.fsf@gmail.com> Date: Mon, 14 Apr 2025 09:30:50 +0900 Message-ID: <87a58jy479.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77707 Cc: 77707@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Ludovic, [...] > That=E2=80=99s because =E2=80=98invoke=E2=80=99 uses =E2=80=98system*=E2= =80=99, which is in fact within the > =E2=80=98shepherd=E2=80=99 process an alias for =E2=80=98spawn-command=E2= =80=99. > > This is fixed in 8d88024e0898dd7d4581c4e977c9786af734a855, which will be > in 1.0.4. That was fast, kudos! --=20 Maxim From unknown Sat Aug 16 14:50:54 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 12 May 2025 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator