From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id ILYdG5huTWRpiAAASxT56A (envelope-from ) for ; Sat, 29 Apr 2023 21:23:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 2MA4GphuTWQwzAAAG6o9tA (envelope-from ) for ; Sat, 29 Apr 2023 21:23:04 +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 249B63E788 for ; Sat, 29 Apr 2023 21:23:03 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=TLqxHlAK; 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=1682796184; 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=LiV3js+T9Z7UcFYGft2OOApTn79wTpWfY7S5LUiK7X8=; b=kQLv06F0bJC8B0ZWOzf34axsBPeJnR+o3HpR58ifSxEZS3kH9/6HR4vX0JbuVYQHjk3JSK 6iNVfGYeUJDRp+8He4SSFSGShZfv+3WcQAAqdFMBzYwAt+zbyzJdepHuyQWmx3xCjN7JZd REgxKVXCY2pSu1btcewRmf7NwIINPIjRKmb2iNGGIMs9ZRWDD8kgtxuTHpUaV+U9fmmVWx uB5ZFaZsWhVa+qcnfwT6YyE/MQJVlIu/56x5sW5jlXnPxQPJezhX3zscrLZgUuc3OPGIcH MQN0anqvxQ16Z83vVJGmoc0UxCo05HlYklWc2KrSnOd4FiwgRuRb8oFclNgSwA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=TLqxHlAK; 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-Seal: i=1; s=key1; d=yhetil.org; t=1682796184; a=rsa-sha256; cv=none; b=TzZlH+6fjKWFSu6lMDTJYy9zjEXQewIOBRfYIST4uVo6eAos9Ki8Gkx7xUSllLr/5k6B8Q gYtW9p46SF9rCXIhXakWbSbOXN7g7RGBucAPZcTitlZKqDVgFXS93xUrSey5icHVVzaaFR kSeuOJEeWGUnHvRUOMg8fDT8ggOaVpuSMts+CO1NvauaKvdG7fxKn4mOO6SCgsgJC4MswH 2kEzNm8Qj+6rQxYmOSwoGewqXzs9h70o5F96cO8GZBgkG5LF3lUx+VmHLf8Jf77JyIIcuf GyyEsWlUF47w18WMFW3SU4/J3zHYSnhRJuVVVqwqE6duqOaFBLNLyMQ8uqlnug== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psoHs-00017e-Vd; Sat, 29 Apr 2023 13:23:08 -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 1psoHq-00014f-5Z for bug-guix@gnu.org; Sat, 29 Apr 2023 13:23:06 -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 1psoHp-0003NB-TM for bug-guix@gnu.org; Sat, 29 Apr 2023 13:23:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1psoHp-000082-Oe for bug-guix@gnu.org; Sat, 29 Apr 2023 13:23:05 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#63082: [PATCH v2 07/16] services: mpd: Log to syslog by default. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 29 Apr 2023 17:23: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.168278894132736 (code B ref 63082); Sat, 29 Apr 2023 17:23:05 +0000 Received: (at 63082) by debbugs.gnu.org; 29 Apr 2023 17:22:21 +0000 Received: from localhost ([127.0.0.1]:36566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psoH7-0008Vr-5H for submit@debbugs.gnu.org; Sat, 29 Apr 2023 13:22:21 -0400 Received: from mail-qv1-f52.google.com ([209.85.219.52]:54300) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psoH1-0008U5-8u for 63082@debbugs.gnu.org; Sat, 29 Apr 2023 13:22:15 -0400 Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-5f45fad3be1so10738896d6.0 for <63082@debbugs.gnu.org>; Sat, 29 Apr 2023 10:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682788929; x=1685380929; 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=LiV3js+T9Z7UcFYGft2OOApTn79wTpWfY7S5LUiK7X8=; b=TLqxHlAK/tZ83SFXcxnaa+/7un7Bz2WfuprITq0Go18sKrq/Cw49SuZLXG07zmgTeh qfwN/aWhkvvfZkfeJQXSlGWJtgbqm/5KpWtOBCWDa2WLD4JEqM6KXZ+wEzKdLjwl291D IwI/78gtH0YH0EPCTjoMj/Q0oD5EK9/AtxNDHwn4rNeIJ6ubQeNVn5+UGUtjO8qGDLye xVgXmvUxnOyFv+lBpYdaH877NENkh7+q0wBKoRslXeANm06vFPCxmYer1TvvV4SZKMzS GrHIdKuzDanvdCoqYAxroRnK6efowK0fBV1JMGiwAXsLji2q3cGnR5P5alDNht7ahbdN lHfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682788929; x=1685380929; 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=LiV3js+T9Z7UcFYGft2OOApTn79wTpWfY7S5LUiK7X8=; b=R0zPhskYaOT0AZKHA4MHefMF3w0hDrUIHdsy1M7fCCcTWaGCZFU8g7mwvlBcY6eBZ0 hOe/5FM7m+jlOVIc5KqRuorCQDBybPFXu35T69hNfmZM72qfj/oXk3CpDS0h9BfP4zVf 0NeH9imVJeCO2AZJ9IPL87o9Q26HmzV4kih9E3RvN9JypwBJWIgGwLljSnJySjngXi7i 3JR0scYE36Kn4bQuFRvKzWDwj7Rrn+a/aKtnX1rHFClG79AzYkPTgJLgsegH7Sk7aAox rg6xye1618ExntNPkWETKjgrf79uvF0xL9VJGDWuyBGdA1Rr7Mjg9HaH1hdESC0kFEi7 ltzA== X-Gm-Message-State: AC+VfDwP41WvkzsFDck/eKN95z5na1IKvlJUTrpTdhwM6k5K5DZATAlL 02xs+kDoG6MZGprtApzbp03W6euvPrU= X-Google-Smtp-Source: ACHHUZ5e0V+BK4jJmQ4F0b/UqcUGZXZePFpNfAIHpzUDO/BSNRm16zVMZzMr8cYsEjmv2hbpNZzZXw== X-Received: by 2002:a05:6214:124b:b0:5ef:83cf:91cc with SMTP id r11-20020a056214124b00b005ef83cf91ccmr15158148qvv.44.1682788929524; Sat, 29 Apr 2023 10:22:09 -0700 (PDT) Received: from localhost.localdomain (dsl-155-245.b2b2c.ca. [66.158.155.245]) by smtp.gmail.com with ESMTPSA id dm45-20020a05620a1d6d00b0074cf009f443sm7582489qkb.85.2023.04.29.10.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Apr 2023 10:22:09 -0700 (PDT) From: Maxim Cournoyer Date: Sat, 29 Apr 2023 13:21:44 -0400 Message-Id: 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-Flow: FLOW_IN X-Migadu-Country: UNKNOWN X-Migadu-Spam: Yes X-Migadu-Spam-Score: 8.95 X-Spam-Score: 8.95 X-Migadu-Queue-Id: 249B63E788 X-Migadu-Scanner: in3.migadu.com X-Spam: Yes X-TUID: ny2JrokeANmO 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 1aa8dc2809..e558e5bb18 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -33581,10 +33581,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 @@ -33855,11 +33855,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