From patchwork Sun Mar 13 21:54:53 2022 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: 37782 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 DA61727BBEA; Sun, 13 Mar 2022 21:56:35 +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=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS autolearn=unavailable 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 A168727BBE9 for ; Sun, 13 Mar 2022 21:56:35 +0000 (GMT) Received: from localhost ([::1]:45892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTWCY-0002FI-QQ for patchwork@mira.cbaines.net; Sun, 13 Mar 2022 17:56:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTWC2-0002CL-Ut for guix-patches@gnu.org; Sun, 13 Mar 2022 17:56:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nTWC2-0007TG-Mj for guix-patches@gnu.org; Sun, 13 Mar 2022 17:56:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nTWC2-0007rY-ME for guix-patches@gnu.org; Sun, 13 Mar 2022 17:56:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54377] [PATCH 2/3] linux-container: Add #:guest-uid and #:guest-gid to 'eval/container'. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 13 Mar 2022 21:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54377 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54377@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 54377-submit@debbugs.gnu.org id=B54377.164720851130146 (code B ref 54377); Sun, 13 Mar 2022 21:56:02 +0000 Received: (at 54377) by debbugs.gnu.org; 13 Mar 2022 21:55:11 +0000 Received: from localhost ([127.0.0.1]:43468 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nTWBC-0007q9-TA for submit@debbugs.gnu.org; Sun, 13 Mar 2022 17:55:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58666) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nTWB9-0007pO-73 for 54377@debbugs.gnu.org; Sun, 13 Mar 2022 17:55:07 -0400 Received: from [2001:470:142:3::e] (port=34776 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTWB3-00079a-T6; Sun, 13 Mar 2022 17:55:01 -0400 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=9+tFWJSQvSObmGAVOflTp472fIIrYqU8MzHz1aYfnyw=; b=my/x0ZgIIORku8KUYoGe H8VmB4Alvv13SfBoo1/4qMP0yMfniHQhCEIlBDwCXHNmCFElJ2zxnnV9mKnTCkFb8UpYGNm9xeRps 36C/MFYtRUipH1zV8yL+UV8kaokI6Mpx6acYFaLwdgjX96WC68EtGnfLT8dq89jKdtQLMwHmEz2Jv NrWifjwcGEG/SyuQyTZGRXv2fir2atGz60mFU1rOFO/Qed/4bsxA1BFM8ZaNDw0w4mKokrDFGE8ha L8nxokVk7AGgB3th8TjRO6k9/R/VWSOmd+8w8OMDA7wJ4JCe1lstOkW+L7U/56E8honOHfpX4N0xV rTQo/rSyvbgu9A==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:62695 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nTWB3-0003Co-FS; Sun, 13 Mar 2022 17:55:01 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sun, 13 Mar 2022 22:54:53 +0100 Message-Id: <20220313215454.9576-2-ludo@gnu.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220313215454.9576-1-ludo@gnu.org> References: <20220313215454.9576-1-ludo@gnu.org> 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" X-getmail-retrieved-from-mailbox: Patches * gnu/system/linux-container.scm (eval/container): Add #:guest-uid and #:guest-gid and honor them. --- gnu/system/linux-container.scm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm index 415d6b9775..eeb0f68c02 100644 --- a/gnu/system/linux-container.scm +++ b/gnu/system/linux-container.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 David Thompson -;;; Copyright © 2016, 2017, 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2016-2017, 2019-2022 Ludovic Courtès ;;; Copyright © 2019 Arun Isaac ;;; Copyright © 2020 Efraim Flashner ;;; Copyright © 2020 Google LLC @@ -248,11 +248,13 @@ (define (explain pid) (define* (eval/container exp #:key (mappings '()) - (namespaces %namespaces)) + (namespaces %namespaces) + (guest-uid 0) (guest-gid 0)) "Evaluate EXP, a gexp, in a new process executing in separate namespaces as listed in NAMESPACES. Add MAPPINGS, a list of , to the -set of directories visible in the process's mount namespace. Return the -process' exit status as a monadic value. +set of directories visible in the process's mount namespace. Inside the +namespaces, run code as GUEST-UID and GUEST-GID. Return the process' exit +status as a monadic value. This is useful to implement processes that, unlike derivations, are not entirely pure and need to access the outside world or to perform side @@ -292,4 +294,6 @@ (define items (list "-c" (object->string (lowered-gexp-sexp lowered)))))) - #:namespaces namespaces)))))) + #:namespaces namespaces + #:guest-uid guest-uid + #:guest-gid guest-gid))))))