From unknown Thu Jun 19 14:32:25 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#40878 <40878@debbugs.gnu.org> To: bug#40878 <40878@debbugs.gnu.org> Subject: Status: [PATCH] services: mpd: Allow authentication and permissions to be configured. Reply-To: bug#40878 <40878@debbugs.gnu.org> Date: Thu, 19 Jun 2025 21:32:25 +0000 retitle 40878 [PATCH] services: mpd: Allow authentication and permissions t= o be configured. reassign 40878 guix-patches submitter 40878 pinoaffe@airmail.cc severity 40878 normal tag 40878 patch wontfix thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 26 16:16:18 2020 Received: (at submit) by debbugs.gnu.org; 26 Apr 2020 20:16:18 +0000 Received: from localhost ([127.0.0.1]:35015 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jSnhK-0005B1-CM for submit@debbugs.gnu.org; Sun, 26 Apr 2020 16:16:18 -0400 Received: from lists.gnu.org ([209.51.188.17]:40177) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jSnhI-0005Au-Rp for submit@debbugs.gnu.org; Sun, 26 Apr 2020 16:16:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54174) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSnhI-0003NQ-98 for guix-patches@gnu.org; Sun, 26 Apr 2020 16:16:16 -0400 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_PSBL,T_SPF_PERMERROR, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jSnhE-0007KT-EV for guix-patches@gnu.org; Sun, 26 Apr 2020 16:16:15 -0400 Received: from mail.cock.li ([37.120.193.124]:60356) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jSnhC-0007IS-AZ for guix-patches@gnu.org; Sun, 26 Apr 2020 16:16:12 -0400 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=airmail.cc; s=mail; t=1587932165; bh=/r7fHuMelKOPk7mNh4a4NhSNBoApnUdkdlMKdP/EPP8=; h=Date:From:To:Subject:From; b=qR6bdScKgIRhYLzqMrCdGKFmmjbkGx5hHeHpnP1nRTeP/WzsEiBvgmeCnmbOJiFoC TbvydCGgeCRiOVPkh2XMsXc2jcPYHdd2XAwugQDlysMqsUT6bTIumz2V3xcWNeL4OI gJp3Mh4EbMEhExWas6enLAJtP9AWLRU2sHDeqLbQBNBYU1ExqirPx6xkXEg68Xovpb 0dxNKeJIowN26v4aGAfbFFC3bRHm7UwtsjRuUbHsDEZsp1s9Y8kTf9sPZcU3iIlheK tFArPp09ZGJOt8lRs4YjjsSopaC5K0NTYHNNvR1XvLzeLY/l/JKGnzeM/qhvglKBay bDvJVHZAbmrGQ== Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 26 Apr 2020 20:16:05 +0000 From: pinoaffe@airmail.cc To: guix-patches@gnu.org Subject: [PATCH] services: mpd: Allow authentication and permissions to be configured. Message-ID: <1ee4ef44362d20518fe69da7b6c37df5@airmail.cc> X-Sender: pinoaffe@airmail.cc User-Agent: Roundcube Webmail/1.3.10 Received-SPF: permerror client-ip=37.120.193.124; envelope-from=pinoaffe@airmail.cc; helo=mail.cock.li X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/26 16:16:05 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Received-From: 37.120.193.124 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * gnu/services/audio.scm (mpd-credential): New public variable. * gnu/services/audio.scm (mpd-configuration): Add credentials and permissions. --- doc/guix.texi | 23 ++++++++++++ gnu/services/audio.scm | 79 ++++++++++++++++++++++++++++++------------ 2 files changed, 80 insertions(+), 22 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 6613a4af13..1693d938f1 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -23271,12 +23271,35 @@ an absolute path can be specified here. @item @code{outputs} (default: @code{"(list (mpd-output))"}) The audio outputs that MPD can use. By default this is a single output using pulseaudio. +@item @code{default-permissions} (default: @code{'(read add control admin)}) +The permissions a user that connected to the mpd server without a password should enjoy. +Should be a subset of @code{'(read add control admin)}. + +@item @code{credentials} (default: @code{'()}) +The list of credentials one can use to sign in to mpd and gain extra permissions. By +default this is an empty list. + @end table @end deftp +@deftp {Data Type} mpd-credential +Data type representing an @command{mpd} password/permissions pair. + @deftp {Data Type} mpd-output Data type representing an @command{mpd} audio output. +@table @asis +@item @code{password} (default: @code{""}) +The password used to authenticate. The password may not contain "@". + +@item @code{permissions} (default: @code{'()}) +The permissions one gains after authenticating to the server using @code{password}. +This should be a subset of @code{'(read add control admin)}, as in +@code{default-permissions}. + +@end table +@end deftp + @table @asis @item @code{name} (default: @code{"MPD"}) The name of the audio output. diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index 345d8225b2..9a6dc8db94 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -26,6 +26,8 @@ #:use-module (ice-9 match) #:export (mpd-output mpd-output? + mpd-credential + mpd-credential? mpd-configuration mpd-configuration? mpd-service-type)) @@ -36,6 +38,16 @@ ;;; ;;; Code: +(define-record-type* + mpd-credential make-mpd-credential + mpd-credential? + (password mpd-credential-password + ;; valid: any string that does not contain #\@ + (default "")) + (permissions mpd-credential-permissions + ;; valid: any subset of read, add, control and admin + (default '()))) + (define-record-type* mpd-output make-mpd-output mpd-output? @@ -58,24 +70,41 @@ (define-record-type* mpd-configuration make-mpd-configuration mpd-configuration? - (user mpd-configuration-user - (default "mpd")) - (music-dir mpd-configuration-music-dir - (default "~/Music")) - (playlist-dir mpd-configuration-playlist-dir - (default "~/.mpd/playlists")) - (db-file mpd-configuration-db-file - (default "~/.mpd/tag_cache")) - (state-file mpd-configuration-state-file - (default "~/.mpd/state")) - (sticker-file mpd-configuration-sticker-file - (default "~/.mpd/sticker.sql")) - (port mpd-configuration-port - (default "6600")) - (address mpd-configuration-address - (default "any")) - (outputs mpd-configuration-outputs - (default (list (mpd-output))))) + (user mpd-configuration-user + (default "mpd")) + (music-dir mpd-configuration-music-dir + (default "~/Music")) + (playlist-dir mpd-configuration-playlist-dir + (default "~/.mpd/playlists")) + (db-file mpd-configuration-db-file + (default "~/.mpd/tag_cache")) + (state-file mpd-configuration-state-file + (default "~/.mpd/state")) + (sticker-file mpd-configuration-sticker-file + (default "~/.mpd/sticker.sql")) + (port mpd-configuration-port + (default "6600")) + (address mpd-configuration-address + (default "any")) + (credentials mpd-configuration-credentials + (default '())) + (default-permissions mpd-configuration-default-permissions + (default '(read add control admin))) + (outputs mpd-configuration-outputs + (default (list (mpd-output))))) + +(define (mpd-permissions->string permissions) + (string-join (map symbol->string + permissions) + ",")) + +(define (mpd-credential->string credential) + "Convert the USER of type to a configuration file snippet." + (format #f + "password \"~a@~a\"\n" + (mpd-credential-password credential) + (mpd-permissions->string + (mpd-credential-permissions credential)))) (define (mpd-output->string output) "Convert the OUTPUT of type to a configuration file snippet." @@ -110,8 +139,14 @@ audio_output { (apply mixed-text-file "mpd.conf" "pid_file \"" (mpd-file-name config "pid") "\"\n" + "default_permissions \"" + (mpd-permissions->string + (mpd-configuration-default-permissions config)) + "\"\n" (append (map mpd-output->string (mpd-configuration-outputs config)) + (map mpd-credential->string + (mpd-configuration-credentials config)) (map (match-lambda ((config-name config-val) (string-append config-name " \"" (config-val config) "\"\n"))) @@ -143,10 +178,10 @@ audio_output { #:environment-variables ;; Required to detect PulseAudio when run under a user account. '(#$(string-append - "XDG_RUNTIME_DIR=/run/user/" - (number->string - (passwd:uid - (getpwnam (mpd-configuration-user config)))))) + "XDG_RUNTIME_DIR=/run/user/" + (number->string + (passwd:uid + (getpwnam (mpd-configuration-user config)))))) #:log-file #$(mpd-file-name config "log"))) (stop #~(make-kill-destructor)))) -- 2.26.2 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 28 07:30:12 2020 Received: (at 40878) by debbugs.gnu.org; 28 Apr 2020 11:30:12 +0000 Received: from localhost ([127.0.0.1]:39169 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jTORH-0004Iy-IP for submit@debbugs.gnu.org; Tue, 28 Apr 2020 07:30:12 -0400 Received: from mail.cock.li ([37.120.193.124]:58996) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jTORE-00047T-2p for 40878@debbugs.gnu.org; Tue, 28 Apr 2020 07:30:10 -0400 Date: Tue, 28 Apr 2020 13:29:59 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=airmail.cc; s=mail; t=1588073402; bh=r4uAFeK2sZBPceJA9JOMw7DgOEhntiwmGkUPjCwnG/4=; h=Date:From:To:Subject:From; b=hRG/Np3HWR49roSmPtlZbBbeiEuHXZFkRxa5wCqUE9oV1rqd5Zr++ChjtouWQXED7 /2ZxYjhz3Fs7YknilzEojtLspKsmYP8Zxavddvwa8rM3fuJagMJLkA7An+RagSxHxR vHfkqVM96JM3AdCCAbMQHsJtL50zymjxHiw0xDStfydLQ4ojR4AfV/xccnX7ozmEQv Ug92wJyWXoytlCBxGA7fDDcnd3U6oiw8gUhkmfz1cRFK9T6VRrk2DVxdZD3IgSupaj GVdc24qBDPYQNvy5D2hF75fLrcb58m0UxZx15T1qgdp9kBr2QCdw3mxEMbDTw15SvN PExeONVoUmRsQ== From: pinoaffe To: 40878@debbugs.gnu.org Subject: [PATCH (hopefully not garbled this time)] services: mpd: Allow authentication and permissions to be configured. Message-ID: <20200426223555.2a5793bb@airmail.cc> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Score: 2.7 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * gnu/services/audio.scm (mpd-credential): New public variable. * gnu/services/audio.scm (mpd-configuration): Add credentials and permissions. --- doc/guix.texi | 23 ++++++++++++ gnu/services/audio.sc [...] Content analysis details: (2.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: airmail.cc] 2.7 RCVD_IN_PSBL RBL: Received via a relay in PSBL [37.120.193.124 listed in psbl.surriel.com] 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Debbugs-Envelope-To: 40878 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.7 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * gnu/services/audio.scm (mpd-credential): New public variable. * gnu/services/audio.scm (mpd-configuration): Add credentials and permissions. --- doc/guix.texi | 23 ++++++++++++ gnu/services/audio.sc [...] Content analysis details: (1.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: airmail.cc] 2.7 RCVD_IN_PSBL RBL: Received via a relay in PSBL [37.120.193.124 listed in psbl.surriel.com] 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * gnu/services/audio.scm (mpd-credential): New public variable. * gnu/services/audio.scm (mpd-configuration): Add credentials and permissions. --- doc/guix.texi | 23 ++++++++++++ gnu/services/audio.scm | 79 ++++++++++++++++++++++++++++++------------ 2 files changed, 80 insertions(+), 22 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 6613a4af13..1693d938f1 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -23271,12 +23271,35 @@ an absolute path can be specified here. @item @code{outputs} (default: @code{"(list (mpd-output))"}) The audio outputs that MPD can use. By default this is a single output using pulseaudio. +@item @code{default-permissions} (default: @code{'(read add control admin)}) +The permissions a user that connected to the mpd server without a password should enjoy. +Should be a subset of @code{'(read add control admin)}. + +@item @code{credentials} (default: @code{'()}) +The list of credentials one can use to sign in to mpd and gain extra permissions. By +default this is an empty list. + @end table @end deftp +@deftp {Data Type} mpd-credential +Data type representing an @command{mpd} password/permissions pair. + @deftp {Data Type} mpd-output Data type representing an @command{mpd} audio output. +@table @asis +@item @code{password} (default: @code{""}) +The password used to authenticate. The password may not contain "@". + +@item @code{permissions} (default: @code{'()}) +The permissions one gains after authenticating to the server using @code{password}. +This should be a subset of @code{'(read add control admin)}, as in +@code{default-permissions}. + +@end table +@end deftp + @table @asis @item @code{name} (default: @code{"MPD"}) The name of the audio output. diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index 345d8225b2..9a6dc8db94 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -26,6 +26,8 @@ #:use-module (ice-9 match) #:export (mpd-output mpd-output? + mpd-credential + mpd-credential? mpd-configuration mpd-configuration? mpd-service-type)) @@ -36,6 +38,16 @@ ;;; ;;; Code: +(define-record-type* + mpd-credential make-mpd-credential + mpd-credential? + (password mpd-credential-password + ;; valid: any string that does not contain #\@ + (default "")) + (permissions mpd-credential-permissions + ;; valid: any subset of read, add, control and admin + (default '()))) + (define-record-type* mpd-output make-mpd-output mpd-output? @@ -58,24 +70,41 @@ (define-record-type* mpd-configuration make-mpd-configuration mpd-configuration? - (user mpd-configuration-user - (default "mpd")) - (music-dir mpd-configuration-music-dir - (default "~/Music")) - (playlist-dir mpd-configuration-playlist-dir - (default "~/.mpd/playlists")) - (db-file mpd-configuration-db-file - (default "~/.mpd/tag_cache")) - (state-file mpd-configuration-state-file - (default "~/.mpd/state")) - (sticker-file mpd-configuration-sticker-file - (default "~/.mpd/sticker.sql")) - (port mpd-configuration-port - (default "6600")) - (address mpd-configuration-address - (default "any")) - (outputs mpd-configuration-outputs - (default (list (mpd-output))))) + (user mpd-configuration-user + (default "mpd")) + (music-dir mpd-configuration-music-dir + (default "~/Music")) + (playlist-dir mpd-configuration-playlist-dir + (default "~/.mpd/playlists")) + (db-file mpd-configuration-db-file + (default "~/.mpd/tag_cache")) + (state-file mpd-configuration-state-file + (default "~/.mpd/state")) + (sticker-file mpd-configuration-sticker-file + (default "~/.mpd/sticker.sql")) + (port mpd-configuration-port + (default "6600")) + (address mpd-configuration-address + (default "any")) + (credentials mpd-configuration-credentials + (default '())) + (default-permissions mpd-configuration-default-permissions + (default '(read add control admin))) + (outputs mpd-configuration-outputs + (default (list (mpd-output))))) + +(define (mpd-permissions->string permissions) + (string-join (map symbol->string + permissions) + ",")) + +(define (mpd-credential->string credential) + "Convert the USER of type to a configuration file snippet." + (format #f + "password \"~a@~a\"\n" + (mpd-credential-password credential) + (mpd-permissions->string + (mpd-credential-permissions credential)))) (define (mpd-output->string output) "Convert the OUTPUT of type to a configuration file snippet." @@ -110,8 +139,14 @@ audio_output { (apply mixed-text-file "mpd.conf" "pid_file \"" (mpd-file-name config "pid") "\"\n" + "default_permissions \"" + (mpd-permissions->string + (mpd-configuration-default-permissions config)) + "\"\n" (append (map mpd-output->string (mpd-configuration-outputs config)) + (map mpd-credential->string + (mpd-configuration-credentials config)) (map (match-lambda ((config-name config-val) (string-append config-name " \"" (config-val config) "\"\n"))) @@ -143,10 +178,10 @@ audio_output { #:environment-variables ;; Required to detect PulseAudio when run under a user account. '(#$(string-append - "XDG_RUNTIME_DIR=/run/user/" - (number->string - (passwd:uid - (getpwnam (mpd-configuration-user config)))))) + "XDG_RUNTIME_DIR=/run/user/" + (number->string + (passwd:uid + (getpwnam (mpd-configuration-user config)))))) #:log-file #$(mpd-file-name config "log"))) (stop #~(make-kill-destructor)))) -- 2.26.2 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 28 11:00:36 2020 Received: (at 40878) by debbugs.gnu.org; 28 Apr 2020 15:00:36 +0000 Received: from localhost ([127.0.0.1]:41082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jTRiu-0003PG-3T for submit@debbugs.gnu.org; Tue, 28 Apr 2020 11:00:36 -0400 Received: from mail.cock.li ([37.120.193.124]:53126) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jTRir-0003P1-4S for 40878@debbugs.gnu.org; Tue, 28 Apr 2020 11:00:34 -0400 Date: Tue, 28 Apr 2020 17:00:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=airmail.cc; s=mail; t=1588086026; bh=KJKUIjeQkKGxIoZfDFg4N8mF8/Mc9Ku+kbKfgTMa9XE=; h=Date:From:To:Subject:From; b=WAakHi3NGNRbgpjTjEIN8Q9vT6hO79DfDRig2XGebbsYBgtR4EN+Avxx9KEeQLuF9 crD5mBk3YyyVSKGibe6N+SbWMgAvWUb4xh4C5amuIoOLP3olXMWXaO2KYPeiKT0uWm seMXa7WmgLHTFPUipGV/jwoz3Wimk0UG5UmR6rgQF87acbCf4iHdVh0R6u0Sa8wvWw TM3iNtleU+NmIWUI0sCZD5SpyiTA/WHYTr9aLU7pZbGG32w6fUuwVzrtFd1XZb5Qt8 yL9Aghj5Aaw3bG6n9CY6YGSaEBJu+Rvb8zMrj3mvAAoTt1pX8YC4jJRnLd8QyO2M6J SEkwQn2QRoh/Q== From: pinoaffe To: 40878@debbugs.gnu.org Subject: [PATCH v2] services: mpd: Allow authentication and permissions to be configured. Message-ID: <20200428170023.3304924a@airmail.cc> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Score: 2.7 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * gnu/services/audio.scm (mpd-credential): New public variable. * gnu/services/audio.scm (mpd-configuration): Add credentials and permissions. --- doc/guix.texi | 26 ++++++++++++++ gnu/services/audio. [...] Content analysis details: (2.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: airmail.cc] 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.7 RCVD_IN_PSBL RBL: Received via a relay in PSBL [37.120.193.124 listed in psbl.surriel.com] X-Debbugs-Envelope-To: 40878 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.7 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * gnu/services/audio.scm (mpd-credential): New public variable. * gnu/services/audio.scm (mpd-configuration): Add credentials and permissions. --- doc/guix.texi | 26 ++++++++++++++ gnu/services/audio. [...] Content analysis details: (1.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: airmail.cc] 2.7 RCVD_IN_PSBL RBL: Received via a relay in PSBL [37.120.193.124 listed in psbl.surriel.com] 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * gnu/services/audio.scm (mpd-credential): New public variable. * gnu/services/audio.scm (mpd-configuration): Add credentials and permissions. --- doc/guix.texi | 26 ++++++++++++++ gnu/services/audio.scm | 79 ++++++++++++++++++++++++++++++------------ 2 files changed, 83 insertions(+), 22 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 6613a4af13..6a5038fd37 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -23271,6 +23271,32 @@ an absolute path can be specified here. @item @code{outputs} (default: @code{"(list (mpd-output))"}) The audio outputs that MPD can use. By default this is a single output using pulseaudio. +@item @code{default-permissions} (default: @code{'(read add control admin)}) +The permissions a user that connected to the mpd server without a password should enjoy. +Should be a subset of @code{'(read add control admin)}. + +@item @code{credentials} (default: @code{'()}) +The list of credentials one can use to sign in to mpd and gain extra permissions. By +default this is an empty list. + +@end table +@end deftp + +@deftp {Data Type} mpd-credential +Data type representing an @command{mpd} password/permissions pair. + +@table @asis +@item @code{password} (default: @code{""}) +The password used to authenticate. The password may not contain "@". +Warning: due to limitations of the mpd configuration system, the generated mpd config +(which is stored in the guix store and is readable to all users) will include a +plaintext copy of the provided password(s). + +@item @code{permissions} (default: @code{'()}) +The permissions one gains after authenticating to the server using @code{password}. +This should be a subset of @code{'(read add control admin)}, as in +@code{default-permissions}. + @end table @end deftp diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index 345d8225b2..9a6dc8db94 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -26,6 +26,8 @@ #:use-module (ice-9 match) #:export (mpd-output mpd-output? + mpd-credential + mpd-credential? mpd-configuration mpd-configuration? mpd-service-type)) @@ -36,6 +38,16 @@ ;;; ;;; Code: +(define-record-type* + mpd-credential make-mpd-credential + mpd-credential? + (password mpd-credential-password + ;; valid: any string that does not contain #\@ + (default "")) + (permissions mpd-credential-permissions + ;; valid: any subset of read, add, control and admin + (default '()))) + (define-record-type* mpd-output make-mpd-output mpd-output? @@ -58,24 +70,41 @@ (define-record-type* mpd-configuration make-mpd-configuration mpd-configuration? - (user mpd-configuration-user - (default "mpd")) - (music-dir mpd-configuration-music-dir - (default "~/Music")) - (playlist-dir mpd-configuration-playlist-dir - (default "~/.mpd/playlists")) - (db-file mpd-configuration-db-file - (default "~/.mpd/tag_cache")) - (state-file mpd-configuration-state-file - (default "~/.mpd/state")) - (sticker-file mpd-configuration-sticker-file - (default "~/.mpd/sticker.sql")) - (port mpd-configuration-port - (default "6600")) - (address mpd-configuration-address - (default "any")) - (outputs mpd-configuration-outputs - (default (list (mpd-output))))) + (user mpd-configuration-user + (default "mpd")) + (music-dir mpd-configuration-music-dir + (default "~/Music")) + (playlist-dir mpd-configuration-playlist-dir + (default "~/.mpd/playlists")) + (db-file mpd-configuration-db-file + (default "~/.mpd/tag_cache")) + (state-file mpd-configuration-state-file + (default "~/.mpd/state")) + (sticker-file mpd-configuration-sticker-file + (default "~/.mpd/sticker.sql")) + (port mpd-configuration-port + (default "6600")) + (address mpd-configuration-address + (default "any")) + (credentials mpd-configuration-credentials + (default '())) + (default-permissions mpd-configuration-default-permissions + (default '(read add control admin))) + (outputs mpd-configuration-outputs + (default (list (mpd-output))))) + +(define (mpd-permissions->string permissions) + (string-join (map symbol->string + permissions) + ",")) + +(define (mpd-credential->string credential) + "Convert the USER of type to a configuration file snippet." + (format #f + "password \"~a@~a\"\n" + (mpd-credential-password credential) + (mpd-permissions->string + (mpd-credential-permissions credential)))) (define (mpd-output->string output) "Convert the OUTPUT of type to a configuration file snippet." @@ -110,8 +139,14 @@ audio_output { (apply mixed-text-file "mpd.conf" "pid_file \"" (mpd-file-name config "pid") "\"\n" + "default_permissions \"" + (mpd-permissions->string + (mpd-configuration-default-permissions config)) + "\"\n" (append (map mpd-output->string (mpd-configuration-outputs config)) + (map mpd-credential->string + (mpd-configuration-credentials config)) (map (match-lambda ((config-name config-val) (string-append config-name " \"" (config-val config) "\"\n"))) @@ -143,10 +178,10 @@ audio_output { #:environment-variables ;; Required to detect PulseAudio when run under a user account. '(#$(string-append - "XDG_RUNTIME_DIR=/run/user/" - (number->string - (passwd:uid - (getpwnam (mpd-configuration-user config)))))) + "XDG_RUNTIME_DIR=/run/user/" + (number->string + (passwd:uid + (getpwnam (mpd-configuration-user config)))))) #:log-file #$(mpd-file-name config "log"))) (stop #~(make-kill-destructor)))) -- 2.26.2 From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 30 18:23:47 2023 Received: (at 40878) by debbugs.gnu.org; 30 Mar 2023 22:23:47 +0000 Received: from localhost ([127.0.0.1]:59674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pi0gN-0001pe-7J for submit@debbugs.gnu.org; Thu, 30 Mar 2023 18:23:47 -0400 Received: from smtpm2.myservices.hosting ([185.26.105.233]:54760) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pi0gH-0001pM-Gc for 40878@debbugs.gnu.org; Thu, 30 Mar 2023 18:23:45 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm2.myservices.hosting (Postfix) with ESMTP id 3B85D20EC5; Fri, 31 Mar 2023 00:23:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id B63F08009C; Fri, 31 Mar 2023 00:23:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 8oE-npkwHU25; Fri, 31 Mar 2023 00:23:38 +0200 (CEST) Received: from [192.168.1.239] (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 596948009B; Fri, 31 Mar 2023 00:23:38 +0200 (CEST) Message-ID: Date: Thu, 30 Mar 2023 23:23:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [bug#40878] [PATCH] services: mpd: Allow authentication and permissions to be configured. Content-Language: en-US To: pinoaffe@airmail.cc References: <1ee4ef44362d20518fe69da7b6c37df5@airmail.cc> From: Bruno Victal In-Reply-To: <1ee4ef44362d20518fe69da7b6c37df5@airmail.cc> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 40878 Cc: 40878@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) Hi, On 2020-04-26 21:16, pinoaffe@airmail.cc wrote: > * gnu/services/audio.scm (mpd-credential): New public variable. > * gnu/services/audio.scm (mpd-configuration): Add credentials > and permissions. > --- >  doc/guix.texi          | 23 ++++++++++++ >  gnu/services/audio.scm | 79 ++++++++++++++++++++++++++++++------------ >  2 files changed, 80 insertions(+), 22 deletions(-) > > diff --git a/doc/guix.texi b/doc/guix.texi > index 6613a4af13..1693d938f1 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -23271,12 +23271,35 @@ an absolute path can be specified here. >  @item @code{outputs} (default: @code{"(list (mpd-output))"}) >  The audio outputs that MPD can use.  By default this is a single output using pulseaudio. > > +@item @code{default-permissions} (default: @code{'(read add control admin)}) > +The permissions a user that connected to the mpd server without a password should enjoy. > +Should be a subset of @code{'(read add control admin)}. > + > +@item @code{credentials} (default: @code{'()}) > +The list of credentials one can use to sign in to mpd and gain extra permissions.  By > +default this is an empty list. > + >  @end table >  @end deftp > > +@deftp {Data Type} mpd-credential > +Data type representing an @command{mpd} password/permissions pair. > + >  @deftp {Data Type} mpd-output >  Data type representing an @command{mpd} audio output. > > +@table @asis > +@item @code{password} (default: @code{""}) > +The password used to authenticate.  The password may not contain "@". > + > +@item @code{permissions} (default: @code{'()}) > +The permissions one gains after authenticating to the server using @code{password}. > +This should be a subset of @code{'(read add control admin)}, as in > +@code{default-permissions}. > + > +@end table > +@end deftp > + >  @table @asis >  @item @code{name} (default: @code{"MPD"}) >  The name of the audio output. > diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm > index 345d8225b2..9a6dc8db94 100644 > --- a/gnu/services/audio.scm > +++ b/gnu/services/audio.scm > @@ -26,6 +26,8 @@ >    #:use-module (ice-9 match) >    #:export (mpd-output >              mpd-output? > +            mpd-credential > +            mpd-credential? >              mpd-configuration >              mpd-configuration? >              mpd-service-type)) > @@ -36,6 +38,16 @@ >  ;;; >  ;;; Code: > > +(define-record-type* > +  mpd-credential make-mpd-credential > +  mpd-credential? > +  (password    mpd-credential-password > +               ;; valid: any string that does not contain #\@ > +               (default "")) > +  (permissions mpd-credential-permissions > +               ;; valid: any subset of read, add, control and admin > +               (default '()))) > + >  (define-record-type* >    mpd-output make-mpd-output >    mpd-output? > @@ -58,24 +70,41 @@ >  (define-record-type* >    mpd-configuration make-mpd-configuration >    mpd-configuration? > -  (user         mpd-configuration-user > -                (default "mpd")) > -  (music-dir    mpd-configuration-music-dir > -                (default "~/Music")) > -  (playlist-dir mpd-configuration-playlist-dir > -                (default "~/.mpd/playlists")) > -  (db-file      mpd-configuration-db-file > -                (default "~/.mpd/tag_cache")) > -  (state-file   mpd-configuration-state-file > -                (default "~/.mpd/state")) > -  (sticker-file mpd-configuration-sticker-file > -                (default "~/.mpd/sticker.sql")) > -  (port         mpd-configuration-port > -                (default "6600")) > -  (address      mpd-configuration-address > -                (default "any")) > -  (outputs      mpd-configuration-outputs > -                (default (list (mpd-output))))) > +  (user                mpd-configuration-user > +                       (default "mpd")) > +  (music-dir           mpd-configuration-music-dir > +                       (default "~/Music")) > +  (playlist-dir        mpd-configuration-playlist-dir > +                       (default "~/.mpd/playlists")) > +  (db-file             mpd-configuration-db-file > +                       (default "~/.mpd/tag_cache")) > +  (state-file          mpd-configuration-state-file > +                       (default "~/.mpd/state")) > +  (sticker-file        mpd-configuration-sticker-file > +                       (default "~/.mpd/sticker.sql")) > +  (port                mpd-configuration-port > +                       (default "6600")) > +  (address             mpd-configuration-address > +                       (default "any")) > +  (credentials         mpd-configuration-credentials > +                       (default '())) > +  (default-permissions mpd-configuration-default-permissions > +                       (default '(read add control admin))) > +  (outputs             mpd-configuration-outputs > +                       (default (list (mpd-output))))) > + > +(define (mpd-permissions->string permissions) > +  (string-join (map symbol->string > +                    permissions) > +               ",")) > + > +(define (mpd-credential->string credential) > +  "Convert the USER of type to a configuration file snippet." > +  (format #f > +          "password \"~a@~a\"\n" > +          (mpd-credential-password credential) > +          (mpd-permissions->string > +           (mpd-credential-permissions credential)))) > >  (define (mpd-output->string output) >    "Convert the OUTPUT of type to a configuration file snippet." > @@ -110,8 +139,14 @@ audio_output { >    (apply >     mixed-text-file "mpd.conf" >     "pid_file \"" (mpd-file-name config "pid") "\"\n" > +   "default_permissions \"" > +   (mpd-permissions->string > +    (mpd-configuration-default-permissions config)) > +   "\"\n" >     (append (map mpd-output->string >                  (mpd-configuration-outputs config)) > +           (map mpd-credential->string > +                (mpd-configuration-credentials config)) >             (map (match-lambda >                    ((config-name config-val) >                     (string-append config-name " \"" (config-val config) "\"\n"))) > @@ -143,10 +178,10 @@ audio_output { >               #:environment-variables >               ;; Required to detect PulseAudio when run under a user account. >               '(#$(string-append > -                   "XDG_RUNTIME_DIR=/run/user/" > -                   (number->string > -                     (passwd:uid > -                       (getpwnam (mpd-configuration-user config)))))) > +                  "XDG_RUNTIME_DIR=/run/user/" > +                  (number->string > +                   (passwd:uid > +                    (getpwnam (mpd-configuration-user config)))))) >               #:log-file #$(mpd-file-name config "log"))) >     (stop  #~(make-kill-destructor)))) > I know it's rather late to reply to this patch, yet I believe it's worth stating: 1. mpd-service-type has gone through extensive refactoring, which makes this patch no longer apply. 2. This kind of change poses a problem, your credentials will get stored under /gnu/store, which is world readable. Hardly the place you want to use to store secrets like credential data. As such, the best course of action is to use a "include …" directive, which you can via the 'extra-options' field, and point it at a file containing the credentials (which you have to provision manually). Cheers, Bruno From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 30 18:26:37 2023 Received: (at control) by debbugs.gnu.org; 30 Mar 2023 22:26:37 +0000 Received: from localhost ([127.0.0.1]:59678 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pi0j7-0001vj-57 for submit@debbugs.gnu.org; Thu, 30 Mar 2023 18:26:37 -0400 Received: from smtpm3.myservices.hosting ([185.26.105.234]:37698) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pi0j5-0001va-3m for control@debbugs.gnu.org; Thu, 30 Mar 2023 18:26:35 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm3.myservices.hosting (Postfix) with ESMTP id 8425920F4F for ; Fri, 31 Mar 2023 00:26:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id E493B80097 for ; Fri, 31 Mar 2023 00:26:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wHdpperkEHwe for ; Fri, 31 Mar 2023 00:26:33 +0200 (CEST) Received: from [192.168.1.239] (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 9584D80079 for ; Fri, 31 Mar 2023 00:26:33 +0200 (CEST) Message-ID: Date: Thu, 30 Mar 2023 23:26:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Content-Language: en-US In-Reply-To: To: control From: Bruno Victal Subject: control-msg Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 40878 wontfix close 40878 quit From unknown Thu Jun 19 14:32:25 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 28 Apr 2023 11:24:16 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator