From patchwork Fri Feb 21 13:05:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 38908 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1A3B527BBEA; Fri, 21 Feb 2025 13:10:26 +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=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 B394327BBE9 for ; Fri, 21 Feb 2025 13:10:25 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tlSnJ-0005zI-Bv; Fri, 21 Feb 2025 08:10:18 -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 1tlSn7-0005ws-LO for guix-patches@gnu.org; Fri, 21 Feb 2025 08:10:06 -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 ) id 1tlSn7-000589-B5 for guix-patches@gnu.org; Fri, 21 Feb 2025 08:10:05 -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=fWWXPGKmocenmkwm2NuKznHSEy4eXcjP6Tuf4/xJCg8=; b=C7UG9FlW8PloEZu7R8JhqOW6XjWo2S4b5rBbsb/lNi1hTSvLwmifNqfcPQHW1fJWAf3UIXGVpe9dI56ZXBcB9o8rjWBDl9LJjaj5ompc8IznxdGxdRDnw150Hf4Ix2db5y/O36xZGrBADygP19hlJJ65051yQnhN4TIfEaK8a5LVBMgGSvQ02nnIWQGs5P3ASq754WJTQ0iNZnSJj8+B/TzrRm1kw77DEyqigu6cWbEHnTVjr2wGZ9s7bW6GvujXGFEl3OI7alxUP84FLh+K8l4uJXrcraMqxU0DMa/EjSNbhfTv1Gl8ppy9LA7YARqG/r++c7F4ytv5J+JfQWPLoA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tlSn7-0005wt-5Z for guix-patches@gnu.org; Fri, 21 Feb 2025 08:10:05 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75810] [PATCH v3 10/11] etc: systemd services: Run =?utf-8?b?4oCYZ3VpeC1kYWVtb27igJk=?= as an unprivileged user. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 21 Feb 2025 13:10:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75810 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75810@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 75810-submit@debbugs.gnu.org id=B75810.174014335322380 (code B ref 75810); Fri, 21 Feb 2025 13:10:05 +0000 Received: (at 75810) by debbugs.gnu.org; 21 Feb 2025 13:09:13 +0000 Received: from localhost ([127.0.0.1]:56701 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tlSmF-0005oS-1C for submit@debbugs.gnu.org; Fri, 21 Feb 2025 08:09:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60070) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tlSk1-0005PX-6T for 75810@debbugs.gnu.org; Fri, 21 Feb 2025 08:07:06 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tlSjv-0004Zn-Kv; Fri, 21 Feb 2025 08:06:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=fWWXPGKmocenmkwm2NuKznHSEy4eXcjP6Tuf4/xJCg8=; b=auRDK2ruMfc5RD6arP5j uAoAGuI/i8HBtnCV1YMc+pHZhD50PWpZL0Cd+6NfC9sjY7+bE0PaTiHYa40V91ebluZPd+S1gEr+x 7nRLF0HGI3R/3fXmVz/KAId8u141GkMc850QccaCLIFCvh79glR+ufs+Wljfo+YBAkCroLLHckpaX emo25BEufl6UYHmRBeWyCMF6F2/GOKc8WCKf0SAd0mxOUlmozJUnTwFC+WrosnzpegcPgvfUDSGCJ zrTfrniVZJixMEvB4hMS0ptlaVUb2ENXOOdGkHvMarwP8HnsilQLz//bgq/oeSI8kjr0sNbLcGyCN 74i2NoInvcaevQ==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 21 Feb 2025 14:05:58 +0100 Message-ID: <32992bd69bfc6c3ff386c67ccfc2edeeb9fe7fd4.1740142328.git.ludo@gnu.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 * etc/guix-daemon.service.in (ExecStart): Remove ‘--build-users-group’. (Before, User, AmbientCapabilities, PrivateMounts, BindPaths): New fields. * etc/gnu-store.mount.in (Before): Remove. (WantedBy): Change to ‘multi-user.target’. Change-Id: Id826b8ab535844b6024d777f6bd15fd49db6d65e --- etc/gnu-store.mount.in | 3 +-- etc/guix-daemon.service.in | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/etc/gnu-store.mount.in b/etc/gnu-store.mount.in index c94f2db72be..f9918c9e52e 100644 --- a/etc/gnu-store.mount.in +++ b/etc/gnu-store.mount.in @@ -2,10 +2,9 @@ Description=Read-only @storedir@ for GNU Guix DefaultDependencies=no ConditionPathExists=@storedir@ -Before=guix-daemon.service [Install] -WantedBy=guix-daemon.service +WantedBy=multi-user.target [Mount] What=@storedir@ diff --git a/etc/guix-daemon.service.in b/etc/guix-daemon.service.in index 5c43d9b7f1b..a04cf1f2f0f 100644 --- a/etc/guix-daemon.service.in +++ b/etc/guix-daemon.service.in @@ -5,11 +5,29 @@ [Unit] Description=Build daemon for GNU Guix +# Start before 'gnu-store.mount' to get a writable view of the store. +Before=gnu-store.mount + [Service] ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \ - --build-users-group=guixbuild --discover=no \ + --discover=no \ --substitute-urls='@GUIX_SUBSTITUTE_URLS@' Environment='GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale' LC_ALL=en_US.utf8 + +# Run under a dedicated unprivileged user account. +User=guix-daemon + +# Bind-mount the store read-write in a private namespace, to counter the +# effect of 'gnu-store.mount'. +PrivateMounts=true +BindPaths=@storedir@ + +# Provide the CAP_CHOWN capability so that guix-daemon cran create and chown +# /var/guix/profiles/per-user/$USER and also chown failed build directories +# when using '--keep-failed'. Note that guix-daemon explicitly drops ambient +# capabilities before executing build processes so they don't inherit them. +AmbientCapabilities=CAP_CHOWN + StandardOutput=journal StandardError=journal