From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id sCJgNvuQbmP/FQEAbAwnHQ (envelope-from ) for ; Fri, 11 Nov 2022 19:14:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 4BRhNvuQbmNxbwEA9RJhRA (envelope-from ) for ; Fri, 11 Nov 2022 19:14:19 +0100 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 86EFE14F91 for ; Fri, 11 Nov 2022 19:14:19 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otYXW-00052x-6c; Fri, 11 Nov 2022 13:14:06 -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 1otYXT-00050b-8t for guix-patches@gnu.org; Fri, 11 Nov 2022 13:14:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otYXT-0002qD-0v for guix-patches@gnu.org; Fri, 11 Nov 2022 13:14:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1otYXS-0006FB-TB for guix-patches@gnu.org; Fri, 11 Nov 2022 13:14:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#59197] [PATCH 2/3] services: Add Shepherd 'configuration' action to various services. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 11 Nov 2022 18:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59197 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 59197@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 59197-submit@debbugs.gnu.org id=B59197.166819038823910 (code B ref 59197); Fri, 11 Nov 2022 18:14:02 +0000 Received: (at 59197) by debbugs.gnu.org; 11 Nov 2022 18:13:08 +0000 Received: from localhost ([127.0.0.1]:46712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otYWZ-0006DZ-K0 for submit@debbugs.gnu.org; Fri, 11 Nov 2022 13:13:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otYWX-0006Cg-LF for 59197@debbugs.gnu.org; Fri, 11 Nov 2022 13:13: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 1otYWR-0002Qj-IV; Fri, 11 Nov 2022 13:13:00 -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=EhbWe93zrttSgWVN9CG4sZbVWMgCKhry4dhbMEIS2Sk=; b=LZhzpTfMLvbSEJxjv2xD SRefoZBuOUwKTTMguuFavHq/ga+W2h8iAOCd5udO/s25/rBBwkgR9kzNDTSEBgpFtQNP6mSY1F3in 7F2ubEItnNh7i271Au5JwDz58XYdjq9+QQdQE25beUAfAhYP9JyA7wMxftdfSpLBAxXfhYhslf2ho 8eWnkbQc9zGVxmObG707pkn75V82VLqduC394VkGCrFXS64zYRnSsxKU7ZgPzqpMsvpZ0bcVKYw4H svkxOO/SSvzZUyQQj9oDmnMJyiWYUphMs4NRo5DIzsfAeYapoGgo9vGrrtlRyEPfp4sChrbSmTu+o zD0mnH7wYL1iCg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] 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 1otYWO-00032K-Qf; Fri, 11 Nov 2022 13:12:59 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 11 Nov 2022 19:12:45 +0100 Message-Id: <20221111181246.4217-2-ludo@gnu.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221111181246.4217-1-ludo@gnu.org> References: <20221111181246.4217-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1668190459; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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:dkim-signature; bh=EhbWe93zrttSgWVN9CG4sZbVWMgCKhry4dhbMEIS2Sk=; b=lwIKLpIrzsIOcryjutIOTImaLCfSFETNNm2wD+RxsQIkjRZbHWzw0EoALXnxNWKb5dPQf3 PKYma301N5ihYfQwdYz2QRub42uSKvfs09MIFC/rfIh4q2ySJcssxlHXYpOoaCQhqdn7Fr iso6YS4hC8uVXAa2yonPTGoezCpomSohffuGaDECCL/dpdshQ6lCLgtX//Yh5Iu4PtAxgD pF3DoxKmFVHQiiuYtJYxDkX2BpWz1S/SmPJTxUS7OfzPJP4Im0xZIwG46t6jYmTRvNSX7G q3ZufPtVdTbyhcU2jRHQeXhC2/aEIGtlr8KvEB/3iCmPe7dkjDMBOGfMCCNu1A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1668190459; a=rsa-sha256; cv=none; b=WeAyYzQlkZMNLYrXgQg/rgpK3FXSbKD8RZ+hKWdW/hQ7RbSoZPTX9CNfpa6XWNZMegC7ZD 8eK65a4i7NNUSBScqboKFS38C/82IH+RtQEMsl3KGNg/HmLVYRdaVzI6znIDLp1BjIMfNh t4wwudUNRa/6up9SuI9EDtjMZZAexelYuJ30/ZIFFDJkCh6pvksuLAXXje2/Xg2oFeIO2D 947lnU3/ai0I6HKBlDwxv8NC2LRwEXostFKmVTG1lZ80p4pH+NCkExmwyYxMMCIWpleBka 0JuXBw6Fc7OCmO7plSp3UPjvbF40cnUE1hA3N7uFyYgAG13swBDWVZc0mdLFYg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=LZhzpTfM; dmarc=pass (policy=none) header.from=gnu.org; 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" X-Migadu-Spam-Score: -2.93 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=LZhzpTfM; dmarc=pass (policy=none) header.from=gnu.org; 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" X-Migadu-Queue-Id: 86EFE14F91 X-Spam-Score: -2.93 X-Migadu-Scanner: scn0.migadu.com X-TUID: h0j3J7cI+ARC * gnu/services/avahi.scm (avahi-shepherd-service): Add 'actions' field. * gnu/services/base.scm (nscd-actions): Add call to 'shepherd-configuration-action'. * gnu/services/desktop.scm (upower-shepherd-service): Add 'actions' field. (elogind-shepherd-service): Likewise. * gnu/services/networking.scm (openntpd-shepherd-service): Likewise. (tor-shepherd-service): Likewise. * gnu/services/ssh.scm (openssh-shepherd-service): Likewise. * gnu/services/web.scm (nginx-shepherd-service): Likewise. * gnu/services/xorg.scm (gdm-shepherd-service): Likewise. * gnu/tests/base.scm (run-basic-test)["nscd configuration action"]: New test. * doc/guix.texi (Services): Document it. --- doc/guix.texi | 11 +++++++++++ gnu/services/avahi.scm | 5 +++-- gnu/services/base.scm | 5 +++-- gnu/services/desktop.scm | 12 ++++++++---- gnu/services/networking.scm | 4 +++- gnu/services/ssh.scm | 6 +++++- gnu/services/web.scm | 7 +++---- gnu/services/xorg.scm | 10 ++++++---- gnu/tests/base.scm | 6 ++++++ 9 files changed, 48 insertions(+), 18 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 3f76184495..6955108eed 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17643,6 +17643,17 @@ Service xorg-server has been stopped. Service xorg-server has been started. @end example +@cindex configuration, action for shepherd services +@cindex configuration file, of a shepherd service +For some services, @command{herd configuration} returns the name of the +service's configuration file, which can be handy to inspect its +configuration: + +@example +# herd configuration sshd +/gnu/store/@dots{}-sshd_config +@end example + The following sections document the available services, starting with the core services, that may be used in an @code{operating-system} declaration. diff --git a/gnu/services/avahi.scm b/gnu/services/avahi.scm index 3b8d0512c7..1c4220e490 100644 --- a/gnu/services/avahi.scm +++ b/gnu/services/avahi.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2014-2020, 2022 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -137,7 +137,8 @@ (define (avahi-shepherd-service config) #$@(if debug? #~("--debug") #~()) "-f" #$config) #:pid-file "/run/avahi-daemon/pid")) - (stop #~(make-kill-destructor)))))) + (stop #~(make-kill-destructor)) + (actions (list (shepherd-configuration-action config))))))) (define avahi-service-type (let ((avahi-package (compose list avahi-configuration-avahi))) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 3bf924b8f1..d99548573d 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -1327,10 +1327,11 @@ (define (nscd-action-procedure nscd config option) (loop))))))) (define (nscd-actions nscd config) - "Return Shepherd actions for NSCD." + "Return Shepherd actions for NSCD using CONFIG its config file." ;; Make this functionality available as actions because that's a simple way ;; to run the right 'nscd' binary with the right config file. - (list (shepherd-action + (list (shepherd-configuration-action config) + (shepherd-action (name 'statistics) (documentation "Display statistics about nscd usage.") (procedure (nscd-action-procedure nscd config "--statistics"))) diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index 1b087635d1..ac29e8d38a 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -273,7 +273,8 @@ (define (upower-shepherd-service config) #:environment-variables (list (string-append "UPOWER_CONF_FILE_NAME=" #$config)))) - (stop #~(make-kill-destructor)))))) + (stop #~(make-kill-destructor)) + (actions (list (shepherd-configuration-action config))))))) (define upower-service-type (let ((upower-package (compose list upower-configuration-upower))) @@ -1168,6 +1169,9 @@ (module (file-append (elogind-package config) (define (elogind-shepherd-service config) "Return a Shepherd service to start elogind according to @var{config}." + (define config-file + (elogind-configuration-file config)) + (list (shepherd-service (requirement '(dbus-system)) (provision '(elogind)) @@ -1176,9 +1180,9 @@ (define (elogind-shepherd-service config) "/libexec/elogind/elogind")) #:environment-variables (list (string-append "ELOGIND_CONF_FILE=" - #$(elogind-configuration-file - config))))) - (stop #~(make-kill-destructor))))) + #$config-file)))) + (stop #~(make-kill-destructor)) + (actions (list (shepherd-configuration-action config-file)))))) (define elogind-service-type (service-type (name 'elogind) diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 19aba8c266..18d1eb5b8c 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -652,7 +652,8 @@ (define ntpd.conf ;; while running, leading shepherd to disable it. To ;; prevent spamming stderr, redirect output to logfile. #:log-file "/var/log/ntpd.log")) - (stop #~(make-kill-destructor)))))) + (stop #~(make-kill-destructor)) + (actions (list (shepherd-configuration-action ntpd.conf))))))) (define (openntpd-service-activation config) "Return the activation gexp for CONFIG." @@ -1032,6 +1033,7 @@ (define (tor-shepherd-service config) (list #$tor "-f" #$torrc) #:user "tor" #:group "tor")) (stop #~(make-kill-destructor)) + (actions (list (shepherd-configuration-action torrc))) (documentation "Run the Tor anonymous network overlay.")))))))) (define (tor-activation config) diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm index 72e7183590..7b038e6ac6 100644 --- a/gnu/services/ssh.scm +++ b/gnu/services/ssh.scm @@ -524,9 +524,12 @@ (define port-number (define max-connections (openssh-configuration-max-connections config)) + (define config-file + (openssh-config-file config)) + (define openssh-command #~(list (string-append #$(openssh-configuration-openssh config) "/sbin/sshd") - "-D" "-f" #$(openssh-config-file config))) + "-D" "-f" #$config-file)) (define inetd-style? ;; Whether to use 'make-inetd-constructor'. That procedure appeared in @@ -568,6 +571,7 @@ (define ipv6-support? (stop #~(if #$inetd-style? (make-inetd-destructor) (make-kill-destructor))) + (actions (list (shepherd-configuration-action config-file))) (auto-start? (openssh-auto-start? config))))) (define (openssh-pam-services config) diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 2023119037..bf321f8f1b 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -790,13 +790,11 @@ (define (nginx-shepherd-service config) (nginx file run-directory shepherd-requirement) (let* ((nginx-binary (file-append nginx "/sbin/nginx")) (pid-file (in-vicinity run-directory "pid")) + (config-file (or file (default-nginx-config config))) (nginx-action (lambda args #~(lambda _ - (invoke #$nginx-binary "-c" - #$(or file - (default-nginx-config config)) - #$@args) + (invoke #$nginx-binary "-c" #$config-file #$@args) (match '#$args (("-s" . _) #f) (_ @@ -817,6 +815,7 @@ (define (nginx-shepherd-service config) (stop (nginx-action "-s" "stop")) (actions (list + (shepherd-configuration-action config-file) (shepherd-action (name 'reload) (documentation "Reload nginx configuration file and restart worker processes. diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm index 7f1f0bb581..5f073d05d3 100644 --- a/gnu/services/xorg.scm +++ b/gnu/services/xorg.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Andy Wingo -;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès +;;; Copyright © 2013-2017, 2019-2020, 2022 Ludovic Courtès ;;; Copyright © 2015 Sou Bunnbu ;;; Copyright © 2018, 2019 Timothy Sample ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen @@ -1083,6 +1083,9 @@ (module "pam_permit.so"))))) (gdm-configuration-allow-empty-passwords? config)))) (define (gdm-shepherd-service config) + (define config-file + (gdm-configuration-file config)) + (list (shepherd-service (documentation "Xorg display server (GDM)") (provision '(xorg-server)) @@ -1095,9 +1098,7 @@ (define (gdm-shepherd-service config) (list #$@(if (gdm-configuration-auto-suspend? config) #~() #~("DCONF_PROFILE=/etc/dconf/profile/gdm")) - (string-append - "GDM_CUSTOM_CONF=" - #$(gdm-configuration-file config)) + (string-append "GDM_CUSTOM_CONF=" #$config-file) (string-append "GDM_DBUS_DAEMON=" #$(gdm-configuration-dbus-daemon config)) @@ -1129,6 +1130,7 @@ (define (gdm-shepherd-service config) "GDM_WAYLAND_SESSION=" #$(gdm-configuration-wayland-session config)))))) (stop #~(make-kill-destructor)) + (actions (list (shepherd-configuration-action config-file))) (respawn? #t)))) (define gdm-polkit-rules diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index 64cd6a911a..7200a28606 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm @@ -424,6 +424,12 @@ (define (entry->list entry) (x (pk 'failure x #f)))) + (test-assert "nscd configuration action" + (marionette-eval '(with-shepherd-action 'nscd ('configuration) + results + (file-exists? (car results))) + marionette)) + (test-equal "nscd invalidate action" '(#t) ;one value, #t (marionette-eval '(with-shepherd-action 'nscd ('invalidate "hosts") -- 2.38.0