From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id gDO8HFtLVWRd/wAASxT56A (envelope-from ) for ; Fri, 05 May 2023 20:30:51 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id UGu6G1tLVWQJ3QAAG6o9tA (envelope-from ) for ; Fri, 05 May 2023 20:30:51 +0200 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 2B8EA2CAAE for ; Fri, 5 May 2023 20:30:51 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pv0CB-0005J1-Vf; Fri, 05 May 2023 14:30:19 -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 1pv0By-0005Bb-0W for bug-guix@gnu.org; Fri, 05 May 2023 14:30: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 1pv0Bx-000620-O0 for bug-guix@gnu.org; Fri, 05 May 2023 14:30:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pv0Bx-0003BC-KY for bug-guix@gnu.org; Fri, 05 May 2023 14:30:05 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#63082: [PATCH v3 08/16] services: mpd: Log to syslog by default. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 05 May 2023 18:30:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63082 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63082@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 63082-submit@debbugs.gnu.org id=B63082.168331138512014 (code B ref 63082); Fri, 05 May 2023 18:30:05 +0000 Received: (at 63082) by debbugs.gnu.org; 5 May 2023 18:29:45 +0000 Received: from localhost ([127.0.0.1]:57490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv0Bc-00037T-Ds for submit@debbugs.gnu.org; Fri, 05 May 2023 14:29:45 -0400 Received: from mail-qk1-f182.google.com ([209.85.222.182]:49307) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv0BZ-00036E-31 for 63082@debbugs.gnu.org; Fri, 05 May 2023 14:29:41 -0400 Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-74e0180b7d3so106171085a.2 for <63082@debbugs.gnu.org>; Fri, 05 May 2023 11:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683311375; x=1685903375; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SYOyLx5I9AwcCCLA/vHuBkk6D+m+Rx3g9rzMFJBD/Yk=; b=M2bimNBPlzsyGLrG+U5MhRWdoM67xparv2swgHR53+9pD0Di9HyxmuQur94oNh8alS Ao8LJTmfvwAHIRa+fzH+KUy9l9EkSDF4tF4ZTcGxpjwI1uZE90JqE2FoGfFKfXRoCqJR CBFAPD04EHAlzbUsgtaOTNbC7JtaGyPUVnniDbf2RWdkWTJNsStbFI/ijfFtirCTnHyc nGsCDc0M0UoMFm2r8UwHJa3vWzwSOl1/oQMTxW2bAALC5rXFOcYL4nT1tiaV9euY5y3J TzoXDORfddgNxROdCq1nrTHCD7mdWNRnVwEncNZE1S+qeReKmzO1nVzF41ouRPWgjNo1 mFmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683311375; x=1685903375; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SYOyLx5I9AwcCCLA/vHuBkk6D+m+Rx3g9rzMFJBD/Yk=; b=CoFC0eR2n2foFd57wzePfOu5oD1MJQZHtENBswFxMDmWawzGR0y+GJ+3WLZeq4eFa2 fmOeUiQ5BYCVetq+iHHmaZ3bMg4a+ZSLhX8yi3hD+ls75uKMbKRn1AoQBiwJNKMPxZTl Z2HW2yRUiXcSpcjUK7ZUm1oVaaPZ8m256vLG9qD5XUxKbNd1u9PouiCSFEt5ADuAor4J f5YwZIUC0BH9xOuq9G13l9j3PuoLigQT/hHexatd7v7dA+vKQqc/pCGJOSgCzMViYZLd DrRS2vQZV/72xF51J6suxbIukcZbPTTTbCmxVvb9RZKlEW9tw4K9Ugny+/SMuOZaj4pY Npzg== X-Gm-Message-State: AC+VfDwjDrOWfquP6VuxySIj7ikfFXFtr103vZJJ0H0i1FD/wwB8Uel5 yxWRWzpCxKGGaUs5GPD5HzT/DloogTg= X-Google-Smtp-Source: ACHHUZ5oVX/yNG/qbJItacyxRbYyXaEcvP+FOsfZKLNvwzvCW3JaJrm92sPA23j4nll7082MPsBH8g== X-Received: by 2002:ac8:7f4b:0:b0:3d9:b59f:1ba9 with SMTP id g11-20020ac87f4b000000b003d9b59f1ba9mr4288329qtk.12.1683311375264; Fri, 05 May 2023 11:29:35 -0700 (PDT) Received: from localhost.localdomain (dsl-205-236-230-162.b2b2c.ca. [205.236.230.162]) by smtp.gmail.com with ESMTPSA id c1-20020ac81e81000000b003e97fe68511sm834399qtm.3.2023.05.05.11.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 11:29:34 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 5 May 2023 14:29:03 -0400 Message-Id: <6f7567fe5433abc84119626c93a6504ba581bdf7.1683299529.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1683311451; a=rsa-sha256; cv=none; b=Jzsm0KXVzlFUz4DnjbCsFYVkUrs4jK0OTc4H2D+pVGLHK6ytOho2HZ6Bn8yGVAEKp1wGtL wyvdkGhCqxpt2iTG5Iy49jb7SSiiXeHdA95GLJGP1W8W5jDIFL3SOF85t5rTeP51GvO7LY 5zXp3vuHxG8sUqoKILxiWjXfVGJiCsgwBQUY3Ex/amaX4EUA+kLpcxO4bK4iaFoplxXIF9 ceUJhqojVd4OwSTtQVJM/2Cb338D0+zo+bYjRts0+/UuFM3o/YCLJitwTRYINLqKKWZI4m QxFGjdl53UJckabEqS8y/GJlgo37/wTx4aPi9tHr60as6U5X4zIdnxhECDcw6Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=M2bimNBP; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1683311451; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=SYOyLx5I9AwcCCLA/vHuBkk6D+m+Rx3g9rzMFJBD/Yk=; b=CDVErgh0EOa3qmsAhbhjcJmjc7hLG5A3CfCg9SaBrNeiNl30LBWGsEfl2AUCozq0BHNWmU zVsUw1bw95tyL2urDs2CO3EKrkUPP3QWNw3Epdw4EjFkp2pm3O2cc1jyLN/+Ihri7wGGPz 2n5hZdNpVERLOzGJ/2QqRHeaepwZ9PVY8/dqFwH6wtVRmweO+Wz835m6XERqp6VXQsGxAx u8jsw0IfsCgnMQcZWL8Xxzs+lT4jFmkV9B9l5d6wsh/bdhVbX/56F/Qg6vafclEkJVPFsU 6e6iXl9CswbKBhjW/Xo99DxrW3U4cvvXKfkgupD/5AzXAi32lzGCFcPaca6f5w== X-Migadu-Spam-Score: -1.11 X-Spam-Score: -1.11 X-Migadu-Queue-Id: 2B8EA2CAAE X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=M2bimNBP; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-TUID: 9VScgU/Bvzri Rationale: the tristate value was awkward to deal with, the default log file name was odd (/var/log/mpd/log) and it required special attention to create the 'mpd' parent directory as root and chowning it to the MPD user. It also didn't match the default behavior of MPD, which is to log to systemd or syslog unless a log file is specified. * gnu/services/audio.scm (mpd-log-file-sanitizer): New procedure. (mpd-configuration) [log-file]: Remove default maybe value. Add sanitizer. (mpd-shepherd-service): Validate the log file parent directory exists and has the right permissions. Conditionally add syslogd to requirements. (mympd-log-to-sanitizer): New procedure. (mympd-configuration) [log-to]: Change type to maybe-string. Update doc and add sanitizer. (mympd-shepherd-service) [requirement]: Fix to use syslogd. Adjust accordingly. [start] Adjust accordingly. (mympd-log-rotation): Check log-to via maybe-value-set?. * doc/guix.texi (Audio Services): Update doc. --- doc/guix.texi | 17 +++++----- gnu/services/audio.scm | 74 ++++++++++++++++++++++++++++-------------- 2 files changed, 57 insertions(+), 34 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 200f6d019c..253b8f113b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -33610,10 +33610,10 @@ Audio Services @item @code{environment-variables} (default: @code{("PULSE_CLIENTCONFIG=/etc/pulse/client.conf" "PULSE_CONFIG=/etc/pulse/daemon.conf")}) (type: list-of-strings) A list of strings specifying environment variables. -@item @code{log-file} (default: @code{"/var/log/mpd/log"}) (type: maybe-string) -The location of the log file. Set to @code{syslog} to use the local -syslog daemon or @code{%unset-value} to omit this directive from the -configuration file. +@item @code{log-file} (type: maybe-string) +The location of the log file. Unless specified, logs are sent to the +local syslog daemon. Alternatively, a log file name can be specified, +for example @file{/var/log/mpd.log}. @item @code{log-level} (type: maybe-string) Supress any messages below this threshold. The available values, in @@ -33884,11 +33884,10 @@ Audio Services How much detail to include in logs, possible values: @code{0} to @code{7}. -@item @code{log-to} (default: @code{"/var/log/mympd/log"}) (type: string-or-symbol) -Where to send logs. By default, the service logs to -@file{/var/log/mympd.log}. The alternative is @code{'syslog}, which -sends output to the running syslog service under the @samp{daemon} -facility. +@item @code{log-to} (type: maybe-string) +Where to send logs. Unless specified, the service logs to the local +syslog service under the @samp{daemon} facility. Alternatively, a log +file name can be specified, for example @file{/var/log/mympd.log}. @item @code{lualibs} (default: @code{"all"}) (type: maybe-string) See diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index 6e57bf5cba..c1295837b6 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -229,6 +229,18 @@ (define (mpd-group-sanitizer value) (warning (G_ "'group' in is obsolete; ignoring~%"))) #f) +(define (mpd-log-file-sanitizer value) + (match value + (%unset-value + ;; XXX: While leaving the 'sys_log' option out of the mpd.conf file is + ;; supposed to cause logging to happen via systemd (elogind provides a + ;; compatible interface), this doesn't work (nothing gets logged); use + ;; syslog instead. + "syslog") + ((? string?) + value) + (_ (configuration-field-error #f 'log-file value)))) + ;;; ;; Generic MPD plugin record, lists only the most prevalent fields. @@ -402,10 +414,11 @@ (define-configuration mpd-configuration empty-serializer) (log-file - (maybe-string "/var/log/mpd/log") - "The location of the log file. Set to @code{syslog} to use the -local syslog daemon or @code{%unset-value} to omit this directive -from the configuration file.") + maybe-string + "The location of the log file. Unless specified, logs are sent to the +local syslog daemon. Alternatively, a log file name can be specified, for +example @file{/var/log/mpd.log}." + (sanitizer mpd-log-file-sanitizer)) (log-level maybe-string @@ -562,7 +575,11 @@ (define (mpd-shepherd-service config) (username (user-account-name user))) (shepherd-service (documentation "Run the MPD (Music Player Daemon)") - (requirement `(user-processes loopback ,@shepherd-requirement)) + (requirement `(user-processes loopback + ,@(if (string=? "syslog" log-file) + '(syslogd) + '()) + ,@shepherd-requirement)) (provision '(mpd)) (start (with-imported-modules (source-module-closure @@ -683,6 +700,15 @@ (define (mympd-group-sanitizer value) (warning (G_ "'group' in is obsolete; ignoring~%"))) #f) +(define (mympd-log-to-sanitizer value) + (match value + ('syslog + (warning (G_ "syslog symbol value for 'log-to' is deprecated~%")) + %unset-value) + ((or %unset-value (? string?)) + value) + (_ (configuration-field-error #f 'log-to value)))) + ;;; @@ -749,10 +775,11 @@ (define-configuration/no-serialization mympd-configuration "How much detail to include in logs, possible values: @code{0} to @code{7}.") (log-to - (string-or-symbol "/var/log/mympd/log") - "Where to send logs. By default, the service logs to -@file{/var/log/mympd.log}. The alternative is @code{'syslog}, which -sends output to the running syslog service under the @samp{daemon} facility." + maybe-string + "Where to send logs. Unless specified, the service logs to the local +syslog service under the @samp{daemon} facility. Alternatively, a log file +name can be specified, for example @file{/var/log/mympd.log}." + (sanitizer mympd-log-to-sanitizer) empty-serializer) (lualibs @@ -849,9 +876,9 @@ (define (mympd-shepherd-service config) (shepherd-service (documentation "Run the myMPD daemon.") (requirement `(loopback user-processes - ,@(if (eq? log-to 'syslog) - '(syslog) - '()) + ,@(if (maybe-value-set? log-to) + '() + '(syslogd)) ,@shepherd-requirement)) (provision '(mympd)) (start @@ -867,16 +894,12 @@ (define (mympd-shepherd-service config) (unless (file-exists? directory) (mkdir-p/perms directory user #o755))) - (for-each - init-directory - '#$(map dirname - ;; XXX: Delete the potential 'syslog log-file value, - ;; which is not a directory. - (delete 'syslog - (filter-map maybe-value - (list log-to - work-directory - cache-directory)))))) + (for-each init-directory + '#$(map dirname (filter-map maybe-value + (list log-to + work-directory + cache-directory))))) + (make-forkexec-constructor `(#$(file-append package "/bin/mympd") "--user" #$username @@ -885,7 +908,7 @@ (define (mympd-shepherd-service config) "--cachedir" #$cache-directory) #:environment-variables (list #$(format #f "MYMPD_LOGLEVEL=~a" log-level)) - #:log-file #$(if (string? log-to) log-to #f))))))))) + #:log-file #$(maybe-value log-to))))))))) (define (mympd-accounts config) (match-record config @@ -893,8 +916,9 @@ (define (mympd-accounts config) (list user))) (define (mympd-log-rotation config) - (match-record config (log-to) - (if (string? log-to) + (match-record config + (log-to) + (if (maybe-value-set? log-to) (list (log-rotation (files (list log-to)))) '()))) -- 2.39.2