From patchwork Thu Apr 13 01:24:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 49131 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 7CEBC174F1; Thu, 13 Apr 2023 02:25:46 +0100 (BST) 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_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,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 60701172C2 for ; Thu, 13 Apr 2023 02:25:45 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmli1-0007qr-6G; Wed, 12 Apr 2023 21:25:09 -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 1pmlhz-0007nm-4y for guix-patches@gnu.org; Wed, 12 Apr 2023 21:25:07 -0400 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 1pmlhu-0004Rg-PO for guix-patches@gnu.org; Wed, 12 Apr 2023 21:25:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pmlhu-0008FW-A1 for guix-patches@gnu.org; Wed, 12 Apr 2023 21:25:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62802] [PATCH 1/4] services: syslog: Move configuration to /etc/syslog.conf. References: <20230413011530.1960-1-maxim.cournoyer@gmail.com> In-Reply-To: <20230413011530.1960-1-maxim.cournoyer@gmail.com> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 13 Apr 2023 01:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62802 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62802@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 62802-submit@debbugs.gnu.org id=B62802.168134907531632 (code B ref 62802); Thu, 13 Apr 2023 01:25:02 +0000 Received: (at 62802) by debbugs.gnu.org; 13 Apr 2023 01:24:35 +0000 Received: from localhost ([127.0.0.1]:42134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmlhS-0008E8-Nf for submit@debbugs.gnu.org; Wed, 12 Apr 2023 21:24:35 -0400 Received: from mail-qt1-f178.google.com ([209.85.160.178]:34370) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmlhQ-0008Dq-RP for 62802@debbugs.gnu.org; Wed, 12 Apr 2023 21:24:34 -0400 Received: by mail-qt1-f178.google.com with SMTP id l16so1935483qtv.1 for <62802@debbugs.gnu.org>; Wed, 12 Apr 2023 18:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681349067; x=1683941067; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ew1pgoEQpVf0pKQ2oVSsLSGqhjwKe5wiS97MIGUJkV8=; b=AzTxVPuWz7ffkAO0ngeVQLHXY0CyjJjBn3k4BZl15KLA4RqUrfZAikmwWnXgOW0wmN kFlIKGyG0Y2FEw0RyfMFwSXpa707gidspmsuDEYrqmMofcyTLLDO0zu/g4KuRJG5SYC0 CWdm3vsuBHasw62BFAgIdjf7k7ysfA6t+72tZeQkGakpVZJybrKoJezOKPorU6ID6sx/ PBIYkA57IBK5M7/5mNx9lIDbPvklVypX07AsoeTpUWmIRrpfSjbgUDnyKZ9nJl3m+p3n kIh+6Do7g/YaZeYpz5JKKVyARydfLRqJTL7SNEnT5Zwpowm7kNPDU+A5+7rfa7uvbmsK l/Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681349067; x=1683941067; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ew1pgoEQpVf0pKQ2oVSsLSGqhjwKe5wiS97MIGUJkV8=; b=mDLncE/GGthsadXKQ5khbPluXz/lZiRxji59WLbYbYWHUUPGxuVboc5rTCrzc+GJoY YIa+WktrZFKJFEVr16PGPDoZCB0HSU5iDsXTFDq2TGNk2+a44noea8EvRHn3kz4WNiQ1 F0JKUtXmigJtcdzdRUn2cFcd69DTTJ7hOKja2E2wpgqzgc+tyXlceN5/izaX1kJgFxSK vxBNAZShxgrRcwQir8uAZEUj1H5V0gwMRhX+n6ctThpjZ0wBc+QKaP8T6GdY4UH/x6WE JAhBtflHzWn3pI3pSjEl1NFzqA3wa3d/hapx4zcMwNWVXmI1D0y4tQ9QbxDweTSdEhm2 cPuA== X-Gm-Message-State: AAQBX9fjaSdfGnxwdY8oDZ40vbT3K63netbsCs6AufKNpL7cKgmnH6iT 6ysfys29HyYq+s+mAMzb3SAETYPMgk4= X-Google-Smtp-Source: AKy350Y+2FRnqDy6GCV2Ma/d5olgcRcioTmOxC34FkZUdAGvHv9z1KenDq15WuO1JEgfXkbEeSuWug== X-Received: by 2002:a05:622a:1801:b0:3e6:954a:3f9e with SMTP id t1-20020a05622a180100b003e6954a3f9emr700711qtc.60.1681349066695; Wed, 12 Apr 2023 18:24:26 -0700 (PDT) Received: from localhost.localdomain (dsl-152-224.b2b2c.ca. [66.158.152.224]) by smtp.gmail.com with ESMTPSA id l22-20020ac81496000000b003e4c6b2cc35sm142505qtj.24.2023.04.12.18.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 18:24:26 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 12 Apr 2023 21:24:04 -0400 Message-Id: <20230413012408.2759-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.39.2 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 Having the configuration live at a static location makes it possible to hot-reload it. * gnu/services/base.scm (syslog.conf): New variable. (syslog-etc, syslog-shepherd-service): New procedures. (syslog-service-type): Rewrite using the above new variable and procedures, extending etc-service-type with its configuration file. --- gnu/services/base.scm | 61 ++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 24 deletions(-) base-commit: 0fe2c78cac19acfb46c3bc365075293e51e0e5aa diff --git a/gnu/services/base.scm b/gnu/services/base.scm index e5c6bf5335..1ed874aa84 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -15,7 +15,7 @@ ;;; Copyright © 2020, 2021 Brice Waegeneire ;;; Copyright © 2021 qblade ;;; Copyright © 2021 Hui Lu -;;; Copyright © 2021, 2022 Maxim Cournoyer +;;; Copyright © 2021, 2022, 2023 Maxim Cournoyer ;;; Copyright © 2021 muradm ;;; Copyright © 2022 Guillaume Le Vaillant ;;; Copyright © 2022 Justin Veilleux @@ -1526,30 +1526,43 @@ (define-record-type* (config-file syslog-configuration-config-file (default %default-syslog.conf))) -(define syslog-service-type - (shepherd-service-type - 'syslog - (lambda (config) - (define config-file - (syslog-configuration-config-file config)) +;;; Note: a static file name is used for syslog.conf so that the reload action +;;; work as intended. +(define syslog.conf "/etc/syslog.conf") - (shepherd-service - (documentation "Run the syslog daemon (syslogd).") - (provision '(syslogd)) - (requirement '(user-processes)) - (actions (list (shepherd-configuration-action config-file))) - (start #~(let ((spawn (make-forkexec-constructor - (list #$(syslog-configuration-syslogd config) - "--rcfile" #$config-file) - #:pid-file "/var/run/syslog.pid"))) - (lambda () - ;; Set the umask such that file permissions are #o640. - (let ((mask (umask #o137)) - (pid (spawn))) - (umask mask) - pid)))) - (stop #~(make-kill-destructor)))) - (syslog-configuration) +(define (syslog-etc configuration) + (match-record configuration + (config-file) + (list `(,(basename syslog.conf) ,config-file)))) + +(define (syslog-shepherd-service config) + (define config-file + (syslog-configuration-config-file config)) + + (shepherd-service + (documentation "Run the syslog daemon (syslogd).") + (provision '(syslogd)) + (requirement '(user-processes)) + (actions (list (shepherd-configuration-action syslog.conf))) + (start #~(let ((spawn (make-forkexec-constructor + (list #$(syslog-configuration-syslogd config) + #$(string-append "--rcfile=" syslog.conf)) + #:pid-file "/var/run/syslog.pid"))) + (lambda () + ;; Set the umask such that file permissions are #o640. + (let ((mask (umask #o137)) + (pid (spawn))) + (umask mask) + pid)))) + (stop #~(make-kill-destructor)))) + +(define syslog-service-type + (service-type + (name 'syslog) + (default-value (syslog-configuration)) + (extensions (list (service-extension shepherd-root-service-type + (compose list syslog-shepherd-service)) + (service-extension etc-service-type syslog-etc))) (description "Run the syslog daemon, @command{syslogd}, which is responsible for logging system messages.")))