From patchwork Sat Mar 22 18:23:36 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: 40651 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 C2D6C27BBE2; Sat, 22 Mar 2025 18:25:33 +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 7F4E027BBEA for ; Sat, 22 Mar 2025 18:25:32 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tw3Wr-0003MP-Bm; Sat, 22 Mar 2025 14:25:05 -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 1tw3Wp-0003KQ-89 for guix-patches@gnu.org; Sat, 22 Mar 2025 14:25:03 -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 1tw3Wo-0007U5-Sd for guix-patches@gnu.org; Sat, 22 Mar 2025 14:25:02 -0400 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=gq5AfWz82gt/hVmDKhQeG1+wYJ7OfmOVitOCKeZF2Ec=; b=P9HFbJR2Z1XuaWKkAfGOTo8lb+nNIt9xTA++CsDZM8CMV09OUoyd4tyi6fwa0eaT+YS5GES2yXK+dNd+QGkGg626YCzvryh61CRTcU74iEcGoTHaaueb1Bb6icTe1z/XkIRMgEBLdYCa7fcwvFUZEPJdQp+n1g0BTduYmu/xbebn6uRHj1dLMPiq2JlKmE315RddZRPVWXyAbLieWDrJRmbn3Zbew4LKsH8689WJWyb4TU3w3OyBdSfzceLKjub0ZcxgX+QczY8F0KnxUEtSjBWcseh2ilixyVFV9Mj7cOBWPTte1mpnYAzy4EgaJsxeOm1JmYQcy7yzAo8myWQigw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tw3Wo-0007vf-Nf for guix-patches@gnu.org; Sat, 22 Mar 2025 14:25:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77189] [PATCH 3/3] services: guix: Socket-activate =?utf-8?b?4oCYZ3VpeC1kYWVtb27igJku?= Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 22 Mar 2025 18:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77189 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77189@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 77189-submit@debbugs.gnu.org id=B77189.174266785330264 (code B ref 77189); Sat, 22 Mar 2025 18:25:02 +0000 Received: (at 77189) by debbugs.gnu.org; 22 Mar 2025 18:24:13 +0000 Received: from localhost ([127.0.0.1]:45408 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tw3W0-0007s0-LX for submit@debbugs.gnu.org; Sat, 22 Mar 2025 14:24:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40240) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tw3Vx-0007rJ-KG for 77189@debbugs.gnu.org; Sat, 22 Mar 2025 14:24:10 -0400 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 1tw3Vs-0007NH-BW; Sat, 22 Mar 2025 14:24:04 -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=gq5AfWz82gt/hVmDKhQeG1+wYJ7OfmOVitOCKeZF2Ec=; b=d/ayB/1TzdeWvzz6nGk7 QbsCb0eC29GRzPvgn2ZkbqPl2Ajkm+lyI9bo6Vrp0NTeZO/gDTYCZE45ZZjy799/UYQHclgQBIyE7 8RRU7XTE/OZbHH44/1nfnHxFsMhqEAL8n4CDItD6yRoG3AZcHDYF5Az3k9leA+kL7ShJZOmNhJTYP d/DDfZ9djHPQRSNIXNC14lKRiD6gyCTc+TwEjU2WJ0sMXmv8kD2KU8LUKBkWq65IbRmMwaiQkcM6m v7ISMLd4fazvq1Cgb+8OHRmBqaVYGG5qRd2BirujYaELp0ejDq5ngmoRrioyIctpCGcSUOdxXw9ZM +A//rbHQI3gokg==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sat, 22 Mar 2025 19:23:36 +0100 Message-ID: <61aa1ba0be9a26f3789962e78e91b6cbe91105da.1742667082.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 * gnu/services/base.scm (guix-shepherd-service): Change ‘start’ to use ‘make-systemd-constructor’ in the default case. Remove now-redundant code creating /var/guix/daemon-socket/. Adjust ‘stop’ method to use ‘make-systemd-destructor’ when appropriate. Change-Id: I3572670c90f65509fbad01dcf13a60f772a86839 --- gnu/services/base.scm | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index c7abc9b422..9a9dfdb304 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -2118,40 +2118,46 @@ (define (guix-shepherd-service config) '()) '#$environment)) - (mkdir-p "/var/guix") ;; Ensure that a fresh directory is used, in case the old ;; one was more permissive and processes have a file ;; descriptor referencing it hanging around, ready to use ;; with openat. (false-if-exception (delete-file-recursively "/var/guix/daemon-socket")) - (let ((perms #$(logand socket-directory-permissions - (lognot #o022)))) - (mkdir "/var/guix/daemon-socket" perms) - ;; Override umask - (chmod "/var/guix/daemon-socket" perms)) - - (let* ((user #$socket-directory-user) - (uid (if user (passwd:uid (getpwnam user)) -1)) - (group #$socket-directory-group) - (gid (if group (group:gid (getgrnam group)) -1))) - (chown "/var/guix/daemon-socket" uid gid)) (match args (((= string->number (? integer? pid))) ;; Start the guix-daemon in the same mnt namespace as ;; PID. This is necessary when running the installer. + ;; Assume /var/guix/daemon-socket was created by a + ;; previous 'start' call without arguments. (fork+exec-command/container daemon-command #:pid pid #:environment-variables environment-variables #:log-file #$log-file)) (() - (fork+exec-command daemon-command - #:environment-variables - environment-variables - #:log-file #$log-file)))))) - (stop #~(make-kill-destructor)))))) + ;; Default to socket activation. + (let ((socket (endpoint + (make-socket-address + AF_UNIX + "/var/guix/daemon-socket/socket") + #:name "socket" + #:socket-owner + (or #$socket-directory-user 0) + #:socket-group + (or #$socket-directory-group 0) + #:socket-directory-permissions + #$socket-directory-permissions))) + ((make-systemd-constructor daemon-command + (list socket) + #:environment-variables + environment-variables + #:log-file #$log-file)))))))) + (stop #~(lambda (value) + (if (or (process? value) (integer? value)) + ((make-kill-destructor) value) + ((make-systemd-destructor) value)))))))) (define (guix-accounts config) "Return the user accounts and user groups for CONFIG."