From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 0JanNzjcS2QXOQAASxT56A (envelope-from ) for ; Fri, 28 Apr 2023 16:46:17 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id EMSBNjjcS2TApQAAG6o9tA (envelope-from ) for ; Fri, 28 Apr 2023 16:46:16 +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 216BD2DA6C for ; Fri, 28 Apr 2023 16:46:16 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psP5G-00082t-3D; Fri, 28 Apr 2023 10:28:26 -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 1psP4y-0007br-J9 for bug-guix@gnu.org; Fri, 28 Apr 2023 10:28:12 -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 1psP4w-00060A-7d for bug-guix@gnu.org; Fri, 28 Apr 2023 10:28:08 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1psP4v-000598-VJ for bug-guix@gnu.org; Fri, 28 Apr 2023 10:28:06 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#63082: [PATCH 07/17] services: mpd: Log to syslog by default. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 28 Apr 2023 14:28: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.168269206319647 (code B ref 63082); Fri, 28 Apr 2023 14:28:05 +0000 Received: (at 63082) by debbugs.gnu.org; 28 Apr 2023 14:27:43 +0000 Received: from localhost ([127.0.0.1]:34149 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psP4Z-00056c-30 for submit@debbugs.gnu.org; Fri, 28 Apr 2023 10:27:43 -0400 Received: from mail-qk1-f180.google.com ([209.85.222.180]:60868) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1psP4Q-00054P-BG for 63082@debbugs.gnu.org; Fri, 28 Apr 2023 10:27:34 -0400 Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-74e3c84e689so804443785a.1 for <63082@debbugs.gnu.org>; Fri, 28 Apr 2023 07:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682692048; x=1685284048; 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=XQigCdqi5DT1gXN0dtWr4qs1oGNNKVmAhzjl6bpTitM=; b=N7aWROgCjjLHC/JCSFHOttXjdyG8zTblO43KlXcV+8x8fplxUocWfak1YEHanfzXQ6 goJsr3EhkJVmGH1mTckqXbdTjwkmN+SdOWGD6hEnHtJGxQ8v2i84xC/y9C7FvYwndwpy 8ZJ5SHyUrwOeLExkqRFv1ZpWkpY5BhR6cYpWYFnhQjz51I1etIVKKdGGUf+VzkvikWON Q/W+BYN/5TZCdkMPVIyd/Wp/2YCD+3Aerv3LF2Ch+4iyc7Ewfi8Q5KQHMB0WgpwDnp/7 FxE+bEQuRklJQH7o8c/o7NQzvCrM9FaisYKSS3Z5nK/87cRlC8Zn6bHcKatJtQthFCRN 3bPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682692048; x=1685284048; 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=XQigCdqi5DT1gXN0dtWr4qs1oGNNKVmAhzjl6bpTitM=; b=CFblUmXfwLUSCgtv1dzxf+qbcbSkzYKVZaxGRyDCgaX09b34x1q/re5uSlry4bDBOg cNt/G4Of/+P1ZQ7OPFsUpTYOMNasRqCXZEBEozW/xRw4fySASMA362cIGTBg6/IRyKc4 EYVD7Bq76NXwYma32xQ+dPFbMEIQpeDsvPZDvEIjR/WJ1V/G8/oy8JZ4AQ0pBbiCeSF8 MS+Fi6qFG2DQwZ9FVnVx1tM5CLD4rd77I+HDeUoszcFUKJD0rAuI8T94dmCyWIZ3jIrg ocqORTCJpersFh+bo84kzBl8NCmIL8qJPoelyfrEsbAKOumWqd6ikxaVxhrWhVhJ1eYt sSyQ== X-Gm-Message-State: AC+VfDzECFHF7iP+FWAbto7fHw46FWT2XOIynanhOiSW1c9zyxXQ8VSf 8Mk9abt3/jDX2sl18qz4ZxQtKRHwObs= X-Google-Smtp-Source: ACHHUZ43aJEqlOaQcHXg7EZe/SD5HsMGF+oYSQFzRbpDN5HwXtf9idWoxeb9aInI1Cv4TfZMHpYaVQ== X-Received: by 2002:ad4:5f0d:0:b0:5e8:979f:2e49 with SMTP id fo13-20020ad45f0d000000b005e8979f2e49mr10050064qvb.41.1682692048710; Fri, 28 Apr 2023 07:27:28 -0700 (PDT) Received: from localhost.localdomain ([2607:fad8:4:3::1000]) by smtp.gmail.com with ESMTPSA id d8-20020a0cfe88000000b005ff569bca72sm6176940qvs.93.2023.04.28.07.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Apr 2023 07:27:28 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 28 Apr 2023 10:27:00 -0400 Message-Id: <44c9a5cf9836a71db9bf78c2eba005a40a006fff.1682690696.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=1682693176; a=rsa-sha256; cv=none; b=lKCsyDjp7aEBddQnB+0JBXPiHcUaTj5lD65zXbw5t3R8iqwhBm8I1CxSh2fC4+42THR3lr XGBy3yv36GY74nzb7H+CH2jepwj342uV5oRC4nauS6aJ4YWtAbcP2kGzzoCvRF2/VjmgK3 19gVjPgoLxpit86582n9DcX0BbvhGB0oFOwfxc+/wsFvhQIs44fGBXRfgZv8xT45E51g74 necXx6Q0/ODFRSKtE/1afRW8jwHRv2Kh5vQmVKA8TTYvtQqrvbWvA1cMc7dvimtp9ol9kO AZmR1DfYNPHgYMm1hpFVjAbw0lItpcg+G6IX/uLWwWhAMf7m8ySidrSR4etdAA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=N7aWROgC; 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=1682693176; 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=XQigCdqi5DT1gXN0dtWr4qs1oGNNKVmAhzjl6bpTitM=; b=TydGoNMQvV1M40bIbH2pkIulqnZ5XYNLl1V138RMSiIWHZC2HUZBXf9j2dM/T7QW2wWrhQ dWPwj8ctycoSuD4Jjh7lmAQQU5Epg9GCipZwdPwU8h05sSyHuW2s3vzRQeLgEh6REUvUzO Hk6AWBt0WKjVOURHMwpnyEgSEw5KZUqrKCozWuTuHYxefhfPrAhjO4vIJUu+AMRKzJsuFO Qi4KYdtuT7z19c2iYmiK19yV50KfZ85zfn3CnSzvqKRhnuVHyovOwlGyPGsIZWSuAFHm71 1zRaV01IrVtW2TDJ5Xw3d5mTOiNfLkK0JKt2JmchKDhWmnLo5ntmn3AsMK5Q1A== X-Migadu-Spam-Score: -0.31 X-Spam-Score: -0.31 X-Migadu-Queue-Id: 216BD2DA6C 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=N7aWROgC; 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: bUWjWiB9yTPh 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. * doc/guix.texi (Audio Services): Update doc. --- doc/guix.texi | 7 +++---- gnu/services/audio.scm | 29 ++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 1aa8dc2809..a71a05bcf3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -33581,10 +33581,9 @@ 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, the logs are collected +by the local syslog daemon. @item @code{log-level} (type: maybe-string) Supress any messages below this threshold. The available values, in diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index 0b7a25d9ef..a1d1a3d2fe 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -228,7 +228,17 @@ (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 'user value)))) ;; Generic MPD plugin record, lists only the most prevalent fields. (define-configuration mpd-plugin @@ -401,10 +411,10 @@ (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, the logs are collected by +the local syslog daemon." + (sanitizer mpd-log-file-sanitizer)) (log-level maybe-string @@ -563,17 +573,18 @@ (define (mpd-shepherd-service config) (requirement `(user-processes loopback ,@shepherd-requirement)) (provision '(mpd)) (start #~(begin - (and=> #$(maybe-value log-file) - (compose mkdir-p dirname)) - (let ((user (getpw #$username))) (for-each (lambda (x) - (when (and x (not (file-exists? x))) + ;; Take action on absolute file names, to filter out + ;; the 'syslog' special value. + (when (and x (string-prefix? "/" x) + (not (file-exists? x))) (mkdir-p x) (chown x (passwd:uid user) (passwd:gid user)))) (list #$(maybe-value playlist-directory) (and=> #$(maybe-value db-file) dirname) + (and=> #$(maybe-value log-file) dirname) (and=> #$(maybe-value state-file) dirname) (and=> #$(maybe-value sticker-file) dirname)))) -- 2.39.2