From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id iEG6OoQCiGYlSQAA62LTzQ:P1 (envelope-from ) for ; Fri, 05 Jul 2024 14:26:13 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id iEG6OoQCiGYlSQAA62LTzQ (envelope-from ) for ; Fri, 05 Jul 2024 16:26:13 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1720189572; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: 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; bh=ZCu//R4lABGNSWKhpF7MVlw4VVELIvvqagqRCcQqaKM=; b=TdGOxl+SWwAr+HcDVdBUXxFtSVB3gtC1GqYdDl4/I3EB3aG2CGcQ1Tv9gD5Q0IgKj40T1J p5ienSWrg3nIXdjCSObOoHMwbAMBCSNXSz9I9zDCbAXUpA+c9nQ2GRdFgRGUxTHfO3VfIs Xh//rm+8N0LsOR1EnReMbpbhVcGlFe0rNlapbOZvu+Vngr3HwR8yNSlxZlvOnIy8G4eJZo ZQyX2qzP1ayNNmSW11WN9oH4NOmdOjp3k5wSCX3pxDi/0dUE11LJ6nakMrIkfPafzCavPI ufhUTDMc1kJrDvcRLD0CARe2bmOUOulGRLVafCAl2acjHpnuoFOcgh/BIxd1HQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1720189572; a=rsa-sha256; cv=none; b=ZtDrv6Sn0S4gCYgCRkqj3hMBiz9ZjpMbHzbsUAvsvxRfkXPFKn0Qw7b1cGCKuSZnVAbZFU S5EWz7y9ZbqbILncBX5p6sL4Lx2qHYvzcZs4gjYdtyw5bz4iJhduTrnmt1v3U7nx/ACqJG gVzCiXixP5PW6yJJ+VCFfLaXKja6d5AH6RuMd2fMXVK4KDelx0Ii3yljqEocfNgxUQ2zlv VaiZRJZVYj1Y+5hrOkN41RMP/aHE6i9CGB6PdA0qVNqXXgJbQEXGpM9hDW7KCnt5H+LGhk i64S1sEo1vHUPf1rbQIXnXXbDZSSkZwcY2fVRDro+LahH3h33odpYMKobHq0tA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" 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 A28A81F4D9 for ; Fri, 5 Jul 2024 16:26:12 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sPjsv-0001GS-JA; Fri, 05 Jul 2024 10:26:01 -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 1sPjst-0001G1-CF for guix-patches@gnu.org; Fri, 05 Jul 2024 10:25:59 -0400 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 1sPjst-0000Jd-3I for guix-patches@gnu.org; Fri, 05 Jul 2024 10:25:59 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sPjsw-0000bC-2L for guix-patches@gnu.org; Fri, 05 Jul 2024 10:26:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70933] Patch References: <67f49b23cfe3755c6802e2fc3351ef3cf0dcdfda.1715687434.git.andreas@enge.fr> In-Reply-To: <67f49b23cfe3755c6802e2fc3351ef3cf0dcdfda.1715687434.git.andreas@enge.fr> Resent-From: Andreas Enge Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 05 Jul 2024 14:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70933 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70933@debbugs.gnu.org Received: via spool by 70933-submit@debbugs.gnu.org id=B70933.17201895082236 (code B ref 70933); Fri, 05 Jul 2024 14:26:02 +0000 Received: (at 70933) by debbugs.gnu.org; 5 Jul 2024 14:25:08 +0000 Received: from localhost ([127.0.0.1]:44686 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPjs3-0000Zz-EH for submit@debbugs.gnu.org; Fri, 05 Jul 2024 10:25:08 -0400 Received: from hera.aquilenet.fr ([185.233.100.1]:54914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPjry-0000ZO-V4 for 70933@debbugs.gnu.org; Fri, 05 Jul 2024 10:25:05 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 9428B154F; Fri, 5 Jul 2024 16:24:53 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at hera.aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cw-MoDeMlzFm; Fri, 5 Jul 2024 16:24:52 +0200 (CEST) Received: from jurong (nat-eduroam-36-gw-01-bso.bordeaux.inria.fr [194.199.1.36]) by hera.aquilenet.fr (Postfix) with ESMTPSA id BC2B828B; Fri, 5 Jul 2024 16:24:52 +0200 (CEST) Date: Fri, 5 Jul 2024 16:24:51 +0200 From: Andreas Enge Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="/7Ov7ZJY37K5Xdxl" Content-Disposition: inline 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: A28A81F4D9 X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -5.89 X-Spam-Score: -5.89 X-TUID: Gf7d2ZgRDPCw --/7Ov7ZJY37K5Xdxl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Here is a suggestion for a patch implementing the chroot? parameter. I have tested it by reconfiguring a real machine and still need to test it in containers. Andreas --/7Ov7ZJY37K5Xdxl Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: attachment; filename="0001-gnu-guix-configuration-Add-a-chroot-parameter.patch" Content-Transfer-Encoding: 8bit >From 8629decf975576447c8662355a35ec0f20e892cf Mon Sep 17 00:00:00 2001 Message-ID: <8629decf975576447c8662355a35ec0f20e892cf.1720189422.git.andreas@enge.fr> From: Andreas Enge Date: Fri, 5 Jul 2024 15:47:13 +0200 Subject: [PATCH] gnu: guix-configuration: Add a chroot? parameter. The parameter should take the values #t, #f or 'default. In a container environment, 'default amounts to #f, otherwise it amounts to #t. * gnu/services/base.scm (guix-configuration): New field. (guix-shepherd-service): If chroot? is #f, add "--disable-chroot". If it is #t or 'default, do nothing. * gnu/system/linux-container.scm (containerized-operating-system): If chroot? is 'default, replace it by #f. * doc/guix.texi: Document the parameter. Change-Id: I8b9c3f46ad8650fa6ed4acee947b4ae5d002d03d --- doc/guix.texi | 7 ++++++ gnu/services/base.scm | 9 ++++++- gnu/system/linux-container.scm | 43 ++++++++++++++++++---------------- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 8bfb342253..92db7ddcf5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -19609,6 +19609,13 @@ Base Services @item @code{build-accounts} (default: @code{10}) Number of build user accounts to create. +@item @code{chroot?} (default: @code{'default}) +The value should be one of @code{#t} or @code{#f}, in which +case chroot is enabled or disabled, respectively; +or it should be @code{'default}, which amounts to @code{#f} in +Docker containers (so that they can be run in non-privileged mode) +or @code{#t} otherwise. + @item @code{authorize-key?} (default: @code{#t}) @cindex substitutes, authorization thereof Whether to authorize the substitute keys listed in diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 4b5b103cc3..a3e23035ca 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -21,6 +21,7 @@ ;;; Copyright © 2022 Justin Veilleux ;;; Copyright © 2022 ( ;;; Copyright © 2023 Bruno Victal +;;; Copyright © 2024 Andreas Enge ;;; ;;; This file is part of GNU Guix. ;;; @@ -213,6 +214,7 @@ (define-module (gnu services base) guix-configuration-build-group guix-configuration-build-accounts guix-configuration-build-machines + guix-configuration-chroot? guix-configuration-authorize-key? guix-configuration-authorized-keys guix-configuration-use-substitutes? @@ -1848,6 +1850,8 @@ (define-record-type* (default "guixbuild")) (build-accounts guix-configuration-build-accounts ;integer (default 10)) + (chroot? guix-configuration-chroot? ;Boolean | 'default + (default 'default)) (authorize-key? guix-configuration-authorize-key? ;Boolean (default #t)) (authorized-keys guix-configuration-authorized-keys ;list of gexps @@ -1942,7 +1946,7 @@ (define (guix-shepherd-service config) glibc-utf8-locales))) (match-record config - (guix build-group build-accounts authorize-key? authorized-keys + (guix build-group build-accounts chroot? authorize-key? authorized-keys use-substitutes? substitute-urls max-silent-time timeout log-compression discover? extra-options log-file http-proxy tmpdir chroot-directories environment) @@ -1989,6 +1993,9 @@ (define (guix-shepherd-service config) "--substitute-urls" #$(string-join substitute-urls) #$@extra-options + #$@(if chroot? + '() + '("--disable-chroot")) ;; Add CHROOT-DIRECTORIES and all their dependencies ;; (if these are store items) to the chroot. (append-map diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm index c780b68fba..c1705f491c 100644 --- a/gnu/system/linux-container.scm +++ b/gnu/system/linux-container.scm @@ -7,6 +7,7 @@ ;;; Copyright © 2022 Ricardo Wurmus ;;; Copyright © 2023 Pierre Langlois ;;; Copyright © 2024 Leo Nikkilä +;;; Copyright © 2024 Andreas Enge ;;; ;;; This file is part of GNU Guix. ;;; @@ -151,26 +152,28 @@ (define* (containerized-operating-system os mappings (swap-devices '()) ; disable swap (services (append services-to-add - (filter-map (lambda (s) - (cond ((memq (service-kind s) services-to-drop) - #f) - ((eq? nscd-service-type (service-kind s)) - (service nscd-service-type - (nscd-configuration - (inherit (service-value s)) - (caches %nscd-container-caches)))) - ((eq? guix-service-type (service-kind s)) - ;; Pass '--disable-chroot' so that - ;; guix-daemon can build thing even in - ;; Docker without '--privileged'. - (service guix-service-type - (guix-configuration - (inherit (service-value s)) - (extra-options - (cons "--disable-chroot" - (guix-configuration-extra-options - (service-value s))))))) - (else s))) + (filter-map + (lambda (s) + (let ((kind (service-kind s)) + (value (service-value s))) + (cond ((memq kind services-to-drop) + #f) + ((eq? nscd-service-type kind) + (service nscd-service-type + (nscd-configuration + (inherit value) + (caches %nscd-container-caches)))) + ((and (eq? guix-service-type kind) + (eq? (guix-configuration-chroot? value) + 'default)) + ;; If chroot? is 'default, it should become #f + ;; so that guix-daemon can build things even in + ;; Docker without '--privileged'. + (service guix-service-type + (guix-configuration + (inherit value) + (chroot? #f)))) + (else s)))) (operating-system-user-services os)))) (file-systems (append (map mapping->fs (if shared-network? base-commit: b91685abdecdb42c0ac2e30e5cb5032b11b5d269 -- 2.45.2 --/7Ov7ZJY37K5Xdxl--