From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 8/luCNiitV7DSAAA0tVLHw (envelope-from ) for ; Fri, 08 May 2020 18:20:08 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id cPCJM+SitV5hbQAA1q6Kng (envelope-from ) for ; Fri, 08 May 2020 18:20:20 +0000 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 30408940997 for ; Fri, 8 May 2020 18:20:18 +0000 (UTC) Received: from localhost ([::1]:33870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX7be-0001sU-Sm for larch@yhetil.org; Fri, 08 May 2020 14:20:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX7bO-0001qV-Rq for bug-guix@gnu.org; Fri, 08 May 2020 14:20:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jX7bO-0001DF-Ho for bug-guix@gnu.org; Fri, 08 May 2020 14:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jX7bO-0000mP-DD for bug-guix@gnu.org; Fri, 08 May 2020 14:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#41028: Channel/inferior error with core-updates: Unbound variable: call-with-new-thread Resent-From: Marius Bakke Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 08 May 2020 18:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41028 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Christopher Baines , Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 41028-done@debbugs.gnu.org id=D41028.15889619582914 (code D ref 41028); Fri, 08 May 2020 18:20:02 +0000 Received: (at 41028-done) by debbugs.gnu.org; 8 May 2020 18:19:18 +0000 Received: from localhost ([127.0.0.1]:46284 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jX7ag-0000ku-30 for submit@debbugs.gnu.org; Fri, 08 May 2020 14:19:18 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:40243) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jX7aZ-0000ka-4c for 41028-done@debbugs.gnu.org; Fri, 08 May 2020 14:19:16 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E40AA5C01CE; Fri, 8 May 2020 14:19:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 08 May 2020 14:19:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=fm2; bh=j0logTrPFjRqywXBSAFwafcnfu hvO5496pE6PyeEMoI=; b=Ihov7WdwvteQ5U7HJDd6iH6PdHyuPNLY9bjqegpjqF s4LlB4C5yLbNW80zOfPEINq9MphYHHeRiOqvVq3EYj3oolXeY2FcLwelMlSQdhJS R7nWL267HqiYyPHu11tEdv2mEHvUwNGjC3pP8Fwihb0L10qZj0SSg3K3WBasnfCS iUkGZ4TCmSfEEma8j4nn7W5/CP44ZQ8SefA9sksK7pQsuuqK3n3iLMS5dipqPPwd ettVz/lPDEqU+s+QpY9/OQYMlJnHoWkSx6HkfikKvmaK1eiKc9wc18+IMOULJfG4 LtjU4EzhiSYTCPpX/L391Src4woPCoijAzb7dvKb20Lw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=j0logT rPFjRqywXBSAFwafcnfuhvO5496pE6PyeEMoI=; b=dGKkLtU1baTDd0H9YGcZ6T qi03wGEejxGPlJ6e2bp/3WPQh/fc/8DPFIE+5Mjo0yvl8J03jmgTJZeq1AGOW+c2 N4c6sOOvjBoJwDC7Nm+9qj4jLCCjnlKtDOwzPptUt4mVDJoIzkud7dYTmWHerYPr vqd9FSuVyJkMydeCdDD9rISrsXnV7ftDw+2BJXCSMmOliGT+CvCDJLr2gCBHD1+i x8dbedF1zhqxu5gmxmp6MhjLEGWzDNWH+3tr9vaB2pWGz7VSNLyw6Pr6HER/k/0I ebdVYbYBi22T8Ga6qDGSQ2HHnMZ7u0xnWPvHiccNVPT6chYTcAcjUiAYfNfkxSmQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrkeefgdehjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffujghffgffkfggtgesghdtreertderjeenucfhrhhomhepofgrrhhiuhhs uceurghkkhgvuceomhgsrghkkhgvsehfrghsthhmrghilhdrtghomheqnecuggftrfgrth htvghrnhepudekhfdvffeivedvffeiffejveejuddtvdeigfekjeegtdeguefhieekgfel iefgnecuffhomhgrihhnpehgnhhurdhorhhgnecukfhppeekgedrvddtvddrieekrdejhe enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmsggr khhkvgesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Received: from localhost (ti0006q161-2604.bb.online.no [84.202.68.75]) by mail.messagingengine.com (Postfix) with ESMTPA id 5D0053280065; Fri, 8 May 2020 14:19:05 -0400 (EDT) From: Marius Bakke In-Reply-To: <875zd6336j.fsf@devup.no> References: <87h7wymj8a.fsf@cbaines.net> <87a72kg2qd.fsf@gnu.org> <87k11oduzx.fsf@gnu.org> <87sggag42e.fsf@cbaines.net> <875zd6336j.fsf@devup.no> User-Agent: Notmuch/0.29.3 (https://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Fri, 08 May 2020 20:19:03 +0200 Message-ID: <87368a2stk.fsf@devup.no> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.7 (-) X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 41028-done@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Scanner: scn0 X-Spam-Score: -2.01 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=fastmail.com header.s=fm2 header.b=Ihov7Wdw; dkim=fail (rsa verify failed) header.d=messagingengine.com header.s=fm2 header.b=dGKkLtU1; dmarc=fail reason="SPF not aligned (relaxed)" header.from=fastmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Scan-Result: default: False [-2.01 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.54038569696594]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; FREEMAIL_FROM(0.00)[fastmail.com]; DWL_DNSWL_FAIL(0.00)[209.51.188.17:server fail]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.10), country: US(-0.00), ip: 209.51.188.17(-0.54)]; R_DKIM_REJECT(1.00)[fastmail.com:s=fm2,messagingengine.com:s=fm2]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; DKIM_TRACE(0.00)[fastmail.com:-,messagingengine.com:-]; MAILLIST(-0.20)[mailman]; SIGNED_PGP(-2.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[mbakke@fastmail.com,bug-guix-bounces@gnu.org]; ARC_NA(0.00)[]; URIBL_BLOCKED(0.00)[gnu.org:url,cbaines.net:email,fastmail.com:email]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; HAS_LIST_UNSUB(-0.01)[]; DNSWL_BLOCKED(0.00)[209.51.188.17:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.51.188.17:from]; RCVD_COUNT_SEVEN(0.00)[10]; FORGED_SENDER_MAILLIST(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[fastmail.com : SPF not aligned (relaxed),none] X-TUID: lns42H2odSqH --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Marius Bakke writes: > Christopher Baines writes: > >> One even more niche issue is that because I'm using this channel in my >> system configuration, the patching happens as root, but it's the cached >> channel in my users home directory that's patched. This means that >> build-self.scm becomes owned by root. >> >> I noticed this when I went to pull: >> >> =E2=86=92 guix pull --branch=3Dcore-updates >> Updating channel 'guix' from Git repository at 'https://git.savannah.g= nu.org/git/guix.git'... >> guix pull: error: Git error: could not open '/home/chris/.cache/guix/c= heckouts/pjmkglp4t7znuugeurpurzikxq3tnlaywmisyr27shj7apsnalwq/build-aux/bui= ld-self.scm' for writing: Permission denied >> >> >> I'm not sure what the neat way of addressing this is, but maybe the file >> ownership can be recorded prior to patching, and reset afterwards if >> it's changed. > > I took a stab at exactly this: > > From 993dd0d36ba8e67af5c60d73cb1f9d60741f5418 Mon Sep 17 00:00:00 2001 > From: Marius Bakke > Date: Fri, 8 May 2020 16:23:55 +0200 > Subject: [PATCH] channels: Preserve permissions when patching > . > > * guix/channels.scm (%bug-41028-patch): Record permissions before invoking > SUBSTITUTE* and reset afterwards if file permissions differ from the curr= ent user. > --- > guix/channels.scm | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/guix/channels.scm b/guix/channels.scm > index 0fa036446c..a102d5bc35 100644 > --- a/guix/channels.scm > +++ b/guix/channels.scm > @@ -393,10 +393,21 @@ to '%package-module-path'." > (not (string-contains content "(ice-9 threads)")))) >=20=20 > (define (add-missing-ice-9-threads-import source) > - ;; Add (ice-9 threads) import in the gexp of 'compute-guix-derivat= ion'. > - (substitute* (string-append source "/" %self-build-file) > - (("^ +\\(use-modules \\(ice-9 match\\)\\)") > - (object->string '(use-modules (ice-9 match) (ice-9 threads)))))) > + (let* ((self-build-file (string-append source "/" %self-build-file= )) > + ;; Record permissions so that we can reset it afterwards in= case > + ;; we run this as the root user (see ). > + ;; TODO: Ideally SUBSTITUTE* would preserve permissions its= elf. > + (stat (stat self-build-file)) > + (owner (stat:uid stat)) > + (group (stat:gid stat))) > + > + ;; Add (ice-9 threads) import in the gexp of 'compute-guix-deriv= ation'. > + (substitute* self-build-file > + (("^ +\\(use-modules \\(ice-9 match\\)\\)") > + (object->string '(use-modules (ice-9 match) (ice-9 threads)))= )) > + > + (unless (and (eq? (getuid) owner) (eq? (getgid) group)) > + (chown self-build-file owner group)))) >=20=20 > (patch missing-ice-9-threads-import? add-missing-ice-9-threads-import= ))) Ludovic pointed out on IRC that 'sudo guix system build foo.scm' with an inferior will update the cached checkout (typically ~/.cache/guix/checkouts/pjmkglp4t7znuugeurpurzikxq3tnlaywmisyr27shj7apsnalw= q) as root, and break subsequent unprivileged 'guix pull' operations anyway. Which is partially correct: .git/index and .git/refs/heads/master will be owned by root in that case, but you are still allowed to unlink() and rename() such files as long as you own the directory, so libgit2 will successfully reset permissions on the checkout even after pulling as root! It fails to do that for build-self.scm because it does not know it has changed, and tries opening it directly with O_WRONLY (which fails). I can confirm that this patch solves that problem, and unprivileged 'guix pull' works again even after previously using sudo. Now, users are likely to run into other issues when using inferiors with sudo (e.g. if new directories are added), so I'm not sure if this patch is worth the effort. Perhaps the Guix git cache should be per-uid, but that requires more intrusive changes. Thoughts? --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAl61opcACgkQoqBt8qM6 VPq/DQf/VpxtgyPipXlZiHtWs222a/Ojzh/A59h3wH7ZisDkxd4/bgkK4OpFeMQt M+tEXtAvlnzI5ViTSNKaFQI+TijT4PuHKApnJAYhELPoRCVpFk13GBphP5hdXUN4 NadA8ZpK3IpTjbD3+Od/gxzqv43OYCwp8N1hEuxZFUkieE4gD/mmJ401ujUNdUHI Xcb/f64vWt7YUevKEpxn8zVDILUGIQmREoxWsJmVBnGb4hJPzpvrjW/TnjIOBee1 Lo8dFA4wMHRSYxTV+LK2/qhT+9L9Nq8hqIvKZwxeOSVMfBfnbg19WnX44IIDXhhm vaveKOeUgrmGwF9bNlTKMODuSq6huQ== =d7Wa -----END PGP SIGNATURE----- --=-=-=--