From patchwork Tue Nov 14 14:09:18 2023 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: 56456 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 1194E27BBEB; Tue, 14 Nov 2023 14:10:50 +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=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 737CF27BBE2 for ; Tue, 14 Nov 2023 14:10:49 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2u7d-00009r-QP; Tue, 14 Nov 2023 09:10:33 -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 1r2u7U-0008WM-SG for guix-patches@gnu.org; Tue, 14 Nov 2023 09:10:26 -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 1r2u7S-00029H-RX for guix-patches@gnu.org; Tue, 14 Nov 2023 09:10:24 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r2u88-0005ds-Ux for guix-patches@gnu.org; Tue, 14 Nov 2023 09:11:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67175] [PATCH 9/9] shepherd: Remove =?utf-8?q?=E2=80=98make-fo?= =?utf-8?q?rkexec-constructor/container=E2=80=99=2E?= Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 14 Nov 2023 14:11:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67175 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67175@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 67175-submit@debbugs.gnu.org id=B67175.169997105021603 (code B ref 67175); Tue, 14 Nov 2023 14:11:04 +0000 Received: (at 67175) by debbugs.gnu.org; 14 Nov 2023 14:10:50 +0000 Received: from localhost ([127.0.0.1]:60601 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2u7u-0005cH-74 for submit@debbugs.gnu.org; Tue, 14 Nov 2023 09:10:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60984) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2u7n-0005aa-Fb for 67175@debbugs.gnu.org; Tue, 14 Nov 2023 09:10:44 -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 1r2u72-0001tD-0x; Tue, 14 Nov 2023 09:09:56 -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=8UUzoZ8WYkWViLnVfuRZp0DdKyxtHcDjT7hKIVtIjT0=; b=TWvlOFPIARVAQmovpMsQ eoswQvflA3wIMKhdbc77S0O6R6W9DEOD3vOlsppTsnHzsZ7XijlgDkKu6HHCfjrPAWPnL+KMgMCwK 2QLhus7GTfWfe7NhQBXowqQ2HcXo/DBCpmwzP5DJ8wZ3SRboXY9VU0ohSDysIPXQXD1ZjakjwPSOx uDxMo6bOdclSNmN9LFDk2foY1G3054GO9uDmhP7CE79sEdI09QzDeu96d83GKyXMyZNmnNhHwYK1C 2FniOdnWco19w9LaJzVjh01LEbFIQrZwVPIoripTE87DjE2l8HXmKupaWwTcR2enPags9JTTf5DpB 1TQDWpBEwunARg==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 14 Nov 2023 15:09:18 +0100 Message-ID: <814e03ee68566de3912c5962a43e2241b1775b52.1699970930.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 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 This was superseded by ‘least-authority-wrapper’. * gnu/build/shepherd.scm (read-pid-file/container) (make-forkexec-constructor/container): Remove. Change-Id: I6acccdff2609a35807608f865a4d381146113a88 --- gnu/build/shepherd.scm | 90 ------------------------------------------ 1 file changed, 90 deletions(-) diff --git a/gnu/build/shepherd.scm b/gnu/build/shepherd.scm index 9d9bfcfbc0..4ead27be0b 100644 --- a/gnu/build/shepherd.scm +++ b/gnu/build/shepherd.scm @@ -33,7 +33,6 @@ (define-module (gnu build shepherd) %precious-signals) #:autoload (shepherd system) (unblock-signals) #:export (default-mounts - make-forkexec-constructor/container fork+exec-command/container)) ;;; Commentary: @@ -101,27 +100,6 @@ (define* (default-mounts #:key (namespaces (default-namespaces '()))) (file-exists? (file-system-mapping-source mapping))) mappings))))) -(define* (read-pid-file/container pid pid-file #:key (max-delay 5)) - "Read PID-FILE in the container namespaces of PID, which exists in a -separate mount and PID name space. Return the \"outer\" PID. " - (match (container-excursion* pid - (lambda () - ;; XXX: Trick for Shepherd 0.9: prevent 'read-pid-file' from - ;; using (@ (fibers) sleep), which would try to suspend the - ;; current task, which doesn't work in this extra process. - (with-continuation-barrier - (lambda () - (read-pid-file pid-file - #:max-delay max-delay))))) - (#f - ;; Send SIGTERM to the whole process group. - (catch-system-error (kill (- pid) SIGTERM)) - #f) - ((? integer? container-pid) - ;; XXX: When COMMAND is started in a separate PID namespace, its - ;; PID is always 1, but that's not what Shepherd needs to know. - pid))) - (define* (exec-command* command #:key user group log-file pid-file (supplementary-groups '()) (directory "/") (environment-variables (environ))) @@ -144,74 +122,6 @@ (define* (exec-command* command #:key user group log-file pid-file #:directory directory #:environment-variables environment-variables)) -(define* (make-forkexec-constructor/container command - #:key - (namespaces - (default-namespaces args)) - (mappings '()) - (user #f) - (group #f) - (supplementary-groups '()) - (log-file #f) - pid-file - (pid-file-timeout 5) - (directory "/") - (environment-variables - (environ)) - #:rest args) - "This is a variant of 'make-forkexec-constructor' that starts COMMAND in -NAMESPACES, a list of Linux namespaces such as '(mnt ipc). MAPPINGS is the -list of to make in the case of a separate mount -namespace, in addition to essential bind-mounts such /proc." - (define container-directory - (match command - ((program _ ...) - (string-append "/var/run/containers/" (basename program))))) - - (define auto-mappings - `(,@(if log-file - (list (file-system-mapping - (source log-file) - (target source) - (writable? #t))) - '()))) - - (define mounts - (append (map file-system-mapping->bind-mount - (append auto-mappings mappings)) - (default-mounts #:namespaces namespaces))) - - (lambda args - (mkdir-p container-directory) - - (when log-file - ;; Create LOG-FILE so we can map it in the container. - (unless (file-exists? log-file) - (close (open log-file (logior O_CREAT O_APPEND O_CLOEXEC) #o640)) - (when user - (let ((pw (getpwnam user))) - (chown log-file (passwd:uid pw) (passwd:gid pw)))))) - - (let ((pid (run-container container-directory - mounts namespaces 1 - (lambda () - (exec-command* command - #:user user - #:group group - #:supplementary-groups - supplementary-groups - #:pid-file pid-file - #:log-file log-file - #:directory directory - #:environment-variables - environment-variables))))) - (if pid-file - (if (or (memq 'mnt namespaces) (memq 'pid namespaces)) - (read-pid-file/container pid pid-file - #:max-delay pid-file-timeout) - (read-pid-file pid-file #:max-delay pid-file-timeout)) - pid)))) - (define* (fork+exec-command/container command #:key pid #:allow-other-keys