From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 63082@debbugs.gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: bug#63082: [PATCH v2 09/16] services: mpd: Let Shepherd effect the user/group change.
Date: Sat, 29 Apr 2023 13:21:46 -0400 [thread overview]
Message-ID: <9425ba1d3c110df4e840b334ce70c9e71af9d03c.1682788743.git.maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <cover.1682788743.git.maxim.cournoyer@gmail.com>
Relates to <https://issues.guix.gnu.org/63082>.
Quoting a MPD developer, regarding MPD's feature to switch user itself:
"that's legacy for the dark ages when proper service managers did not exist"
:-).
* gnu/services/audio.scm (mpd-serialize-user-account)
(mpd-serialize-user-group): Delete procedures.
* gnu/services/audio.scm (mpd-configuration) [user]: Do not serialize.
[group]: Likewise.
(mpd-shepherd-service): Provide the #:user, #:group and #:supplementary-groups
arguments.
(mympd-shepherd-service): Likewise, and remove the '--user' argument.
* doc/guix.texi (Audio Services): Update doc.
(mympd-configuration) [port]: Change default value to 8080.
[ssl-port]: Change default value to 443.
* gnu/tests/audio.scm (run-mympd-test): Adjust accordingly.
---
doc/guix.texi | 12 +++++-----
gnu/services/audio.scm | 52 +++++++++++++++++++++++++-----------------
gnu/tests/audio.scm | 4 ++--
3 files changed, 39 insertions(+), 29 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index e558e5bb18..e4dc4fdd17 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -33569,7 +33569,7 @@ Audio Services
The MPD package.
@item @code{user} (type: user-account)
-The user to run mpd as.
+The user to run @command{mpd} as.
@item @code{group} (default: @code{#f}) (type: boolean)
Obsolete. Do not use.
@@ -33613,7 +33613,7 @@ Audio Services
The location of the sticker database.
@item @code{default-port} (default: @code{6600}) (type: maybe-port)
-The default port to run mpd on.
+The default port to run @command{mpd} on.
@item @code{endpoints} (type: maybe-list-of-strings)
The addresses that mpd will bind to. A port different from
@@ -33798,13 +33798,13 @@ Audio Services
@uref{https://jcorporation.github.io/myMPD/, myMPD} is a web server
frontend for MPD that provides a mobile friendly web client for MPD.
-The following example shows a myMPD instance listening on port 80,
+The following example shows a myMPD instance listening on port 8080,
with album cover caching disabled.
@lisp
(service mympd-service-type
(mympd-configuration
- (port 80)
+ (port 8080)
(covercache-ttl 0)))
@end lisp
@@ -33848,7 +33848,7 @@ Audio Services
@item @code{host} (default: @code{"[::]"}) (type: string)
Host name to listen on.
-@item @code{port} (default: @code{80}) (type: maybe-port)
+@item @code{port} (default: @code{8080}) (type: maybe-port)
HTTP port to listen on.
@item @code{log-level} (default: @code{5}) (type: integer)
@@ -33874,7 +33874,7 @@ Audio Services
@item @code{ssl?} (default: @code{#f}) (type: boolean)
SSL/TLS support.
-@item @code{ssl-port} (default: @code{443}) (type: maybe-port)
+@item @code{ssl-port} (default: @code{4443}) (type: maybe-port)
Port to listen for HTTPS.
@item @code{ssl-cert} (type: maybe-string)
diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm
index 7fb4b8ccf7..f470ca20e0 100644
--- a/gnu/services/audio.scm
+++ b/gnu/services/audio.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2022–2023 Bruno Victal <mirai@makinata.eu>
+;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -165,9 +166,6 @@ (define mpd-serialize-boolean mpd-serialize-field)
(define (mpd-serialize-list-of-strings field-name value)
#~(string-append #$@(map (cut mpd-serialize-string field-name <>) value)))
-(define (mpd-serialize-user-account field-name value)
- (mpd-serialize-string field-name (user-account-name value)))
-
(define-maybe string (prefix mpd-))
(define-maybe list-of-strings (prefix mpd-))
(define-maybe boolean (prefix mpd-))
@@ -390,10 +388,14 @@ (define-configuration mpd-configuration
"The MPD package."
empty-serializer)
+ ;; Note: The user and its group are not serialized, otherwise MPD would
+ ;; attempt to switch the user/group itself. The task of switching the
+ ;; user/group is left to Shepherd instead.
(user
(user-account %mpd-user)
- "The user to run mpd as."
- (sanitizer mpd-user-sanitizer))
+ "The user to run @command{mpd} as."
+ (sanitizer mpd-user-sanitizer)
+ empty-serializer)
(group
(boolean #f)
@@ -458,7 +460,7 @@ (define-configuration mpd-configuration
(default-port
(maybe-port 6600)
- "The default port to run mpd on.")
+ "The default port to run @command{mpd} on.")
(endpoints
maybe-list-of-strings
@@ -611,7 +613,11 @@ (define (mpd-shepherd-service config)
(make-forkexec-constructor
(list #$(file-append package "/bin/mpd") "--no-daemon"
#$config-file)
- #:environment-variables '#$environment-variables))))
+ #:environment-variables '#$environment-variables
+ #:user #$username
+ #:group #$(user-account-group user)
+ #:supplementary-groups
+ '#$(user-account-supplementary-groups user)))))
(stop #~(make-kill-destructor))
(actions
(list (shepherd-configuration-action config-file)
@@ -654,7 +660,7 @@ (define mpd-service-type
(service-extension account-service-type
mpd-accounts)
(service-extension rottlog-service-type
- (compose list mpd-log-rotation))))
+ mpd-log-rotation)))
(default-value (mpd-configuration))))
\f
@@ -770,7 +776,7 @@ (define-configuration/no-serialization mympd-configuration
"Host name to listen on.")
(port
- (maybe-port 80)
+ (maybe-port 8080)
"HTTP port to listen on.")
(log-level
@@ -805,7 +811,7 @@ (define-configuration/no-serialization mympd-configuration
"SSL/TLS support.")
(ssl-port
- (maybe-port 443)
+ (maybe-port 4443)
"Port to listen for HTTPS.")
(ssl-cert
@@ -901,17 +907,21 @@ (define (mympd-shepherd-service config)
'#$(map dirname (filter-map maybe-value
(list log-to
work-directory
- cache-directory)))))
-
- (make-forkexec-constructor
- `(#$(file-append package "/bin/mympd")
- "--user" #$username
- #$@(if (eq? log-to 'syslog) '("--syslog") '())
- "--workdir" #$work-directory
- "--cachedir" #$cache-directory)
- #:environment-variables
- (list #$(format #f "MYMPD_LOGLEVEL=~a" log-level))
- #:log-file #$(maybe-value log-to)))))))))
+ cache-directory))))
+
+ (make-forkexec-constructor
+ `(#$(file-append package "/bin/mympd")
+ "--user" #$username
+ #$@(if (eq? log-to 'syslog) '("--syslog") '())
+ "--workdir" #$work-directory
+ "--cachedir" #$cache-directory)
+ #:environment-variables
+ (list #$(format #f "MYMPD_LOGLEVEL=~a" log-level))
+ #:log-file #$(maybe-value log-to)
+ #:user #$username
+ #:group #$(user-account-group user)
+ #:supplementary-groups
+ '#$(user-account-supplementary-groups user))))))))))
(define (mympd-accounts config)
(match-record config <mympd-configuration>
diff --git a/gnu/tests/audio.scm b/gnu/tests/audio.scm
index acb91293e8..efa07b5ba9 100644
--- a/gnu/tests/audio.scm
+++ b/gnu/tests/audio.scm
@@ -89,7 +89,7 @@ (define (run-mympd-test)
(define vm
(virtual-machine
(operating-system os)
- (port-forwardings '((8080 . 80)))))
+ (port-forwardings '((8080 . 8080)))))
(define test
(with-imported-modules '((gnu build marionette))
@@ -113,7 +113,7 @@ (define (run-mympd-test)
marionette))
(test-assert "HTTP port ready"
- (wait-for-tcp-port 80 marionette))
+ (wait-for-tcp-port 8080 marionette))
(test-equal "http-head"
200
--
2.39.2
next prev parent reply other threads:[~2023-04-29 17:56 UTC|newest]
Thread overview: 105+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 2:58 bug#63082: mpd defaul configuration does not work ('No database' error) Maxim Cournoyer
2023-04-26 3:11 ` Maxim Cournoyer
2023-04-26 18:28 ` Liliana Marie Prikler
2023-04-28 14:26 ` bug#63082: [PATCH 00/17] Improve out-of-the-box experience with mpd-service-type Maxim Cournoyer
2023-04-28 14:26 ` bug#63082: [PATCH 01/17] services: mpd: Add an 'update' action to trigger a database update Maxim Cournoyer
2023-04-28 14:26 ` bug#63082: [PATCH 02/17] services: mpd: Streamline mpd-user-sanitizer and mympd-user-sanitizer Maxim Cournoyer
2023-04-28 14:26 ` bug#63082: [PATCH 03/17] services: mpd: Rename %set-user-group to set-user-group Maxim Cournoyer
2023-04-28 14:26 ` bug#63082: [PATCH 04/17] services: mpd: Obsolete the 'group' field Maxim Cournoyer
2023-04-28 21:50 ` Bruno Victal
2023-04-29 1:15 ` Maxim Cournoyer
2023-04-29 12:12 ` Bruno Victal
2023-04-29 17:12 ` Maxim Cournoyer
2023-04-29 6:26 ` Liliana Marie Prikler
2023-04-29 6:35 ` Liliana Marie Prikler
2023-04-29 17:09 ` Maxim Cournoyer
2023-04-29 17:16 ` Maxim Cournoyer
2023-04-29 22:07 ` Liliana Marie Prikler
2023-05-01 1:07 ` Maxim Cournoyer
2023-05-01 6:13 ` Liliana Marie Prikler
2023-05-03 1:53 ` Maxim Cournoyer
2023-04-28 14:26 ` bug#63082: [PATCH 05/17] services: mpd: List log-level in decreasing verbosity order in doc Maxim Cournoyer
2023-04-28 14:26 ` bug#63082: [PATCH 06/17] services: mympd: Fix log file name Maxim Cournoyer
2023-04-28 21:53 ` Bruno Victal
2023-04-29 1:49 ` Maxim Cournoyer
2023-04-29 1:56 ` Bruno Victal
2023-04-28 14:27 ` bug#63082: [PATCH 07/17] services: mpd: Log to syslog by default Maxim Cournoyer
2023-04-28 22:02 ` Bruno Victal
2023-04-29 16:06 ` Maxim Cournoyer
2023-04-28 14:27 ` bug#63082: [PATCH 08/17] services: mpd: Only rotate log when a log file is specified Maxim Cournoyer
2023-04-28 14:27 ` bug#63082: [PATCH 09/17] services: mpd: Let Shepherd effect the user/group change Maxim Cournoyer
2023-04-28 22:11 ` Bruno Victal
2023-04-29 16:52 ` Maxim Cournoyer
2023-04-28 14:27 ` bug#63082: [PATCH 10/17] system: accounts: Export <user-account> Maxim Cournoyer
2023-04-28 14:27 ` bug#63082: [PATCH 11/17] services: mpd: Warn when the MPD user is not in the "audio" group Maxim Cournoyer
2023-04-29 6:29 ` Liliana Marie Prikler
2023-04-29 17:10 ` Maxim Cournoyer
2023-04-28 14:27 ` bug#63082: [PATCH 12/17] services: mpd: Auto-detect mpd-output mixer type by default Maxim Cournoyer
2023-04-28 14:27 ` bug#63082: [PATCH 13/17] services: mpd: Fix indentation Maxim Cournoyer
2023-04-28 14:27 ` bug#63082: [PATCH 14/17] services: mpd: Obsolete 'environment-variables' field Maxim Cournoyer
2023-04-28 22:17 ` Bruno Victal
2023-04-29 17:04 ` Maxim Cournoyer
2023-04-29 17:23 ` Bruno Victal
2023-05-03 1:44 ` Maxim Cournoyer
2023-05-04 16:21 ` Bruno Victal
2023-05-05 14:44 ` Maxim Cournoyer
2023-04-28 14:27 ` bug#63082: [PATCH 15/17] services: mpd: Provision a default cache directory and set HOME Maxim Cournoyer
2023-04-28 22:22 ` Bruno Victal
2023-04-29 17:07 ` Maxim Cournoyer
2023-04-28 14:27 ` bug#63082: [PATCH 16/17] services: mpd: Update basic example Maxim Cournoyer
2023-04-28 14:27 ` bug#63082: [PATCH 17/17] services: Avoid 'delete' overrides warning in audio module Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 00/16] Improve out-of-the-box experience with mpd-service-type Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 01/16] services: mpd: Add an 'update' action to trigger a database update Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 02/16] services: mpd: Streamline mpd-user-sanitizer and mympd-user-sanitizer Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 03/16] services: mpd: Rename %set-user-group to set-user-group Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 04/16] services: mpd: Obsolete the 'group' field Maxim Cournoyer
2023-05-05 0:38 ` Bruno Victal
2023-05-05 15:09 ` bug#63082: mpd defaul configuration does not work ('No database' error) Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 05/16] services: mpd: List log-level in decreasing verbosity order in doc Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 06/16] services: mpd; Refactor start slot directory initialization Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 07/16] services: mpd: Log to syslog by default Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 08/16] services: mpd: Do not rotate logs when using syslog Maxim Cournoyer
2023-04-29 17:21 ` Maxim Cournoyer [this message]
2023-04-29 17:21 ` bug#63082: [PATCH v2 10/16] system: accounts: Export <user-account> Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 11/16] services: mpd: Warn when the MPD user is not in the "audio" group Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 12/16] services: mpd: Auto-detect mpd-output mixer type by default Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 13/16] services: mpd: Obsolete 'environment-variables' field Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 14/16] services: mpd: Provision a default cache directory and set HOME Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 15/16] services: mpd: Update basic example Maxim Cournoyer
2023-04-29 17:21 ` bug#63082: [PATCH v2 16/16] services: Avoid 'delete' overrides warning in audio module Maxim Cournoyer
2023-05-05 18:28 ` bug#63082: [PATCH v3 00/16] Improve out-of-the-box experience with mpd-service-type Maxim Cournoyer
2023-05-05 18:28 ` bug#63082: [PATCH v3 01/16] services: mpd: Add auto-update? field to mpd-configuration Maxim Cournoyer
2023-05-05 18:28 ` bug#63082: [PATCH v3 02/16] services: mpd: Add an 'update' action to trigger a database update Maxim Cournoyer
2023-05-24 16:00 ` Bruno Victal
2023-07-25 20:48 ` bug#63082: mpd defaul configuration does not work ('No database' error) Maxim Cournoyer
2023-07-26 14:02 ` Bruno Victal
2023-07-26 16:12 ` Maxim Cournoyer
2023-05-05 18:28 ` bug#63082: [PATCH v3 03/16] services: mpd: Streamline mpd-user-sanitizer and mympd-user-sanitizer Maxim Cournoyer
2023-05-05 18:28 ` bug#63082: [PATCH v3 04/16] services: mpd: Rename %set-user-group to set-user-group Maxim Cournoyer
2023-05-05 19:42 ` Liliana Marie Prikler
2023-05-07 2:37 ` Maxim Cournoyer
2023-05-24 16:09 ` Bruno Victal
2023-05-05 18:29 ` bug#63082: [PATCH v3 05/16] services: mpd: Obsolete the 'group' field Maxim Cournoyer
2023-05-05 19:51 ` Liliana Marie Prikler
2023-05-07 2:55 ` Maxim Cournoyer
2023-05-07 5:35 ` Liliana Marie Prikler
2023-05-07 18:12 ` Maxim Cournoyer
2023-05-07 18:31 ` Liliana Marie Prikler
2023-05-08 1:05 ` Maxim Cournoyer
2023-05-08 17:21 ` Liliana Marie Prikler
2023-05-05 18:29 ` bug#63082: [PATCH v3 06/16] services: mpd: List log-level in decreasing verbosity order in doc Maxim Cournoyer
2023-05-05 18:29 ` bug#63082: [PATCH v3 07/16] services: mpd; Refactor start slot directory initialization Maxim Cournoyer
2023-05-24 16:26 ` Bruno Victal
2023-07-25 20:07 ` bug#63082: mpd defaul configuration does not work ('No database' error) Maxim Cournoyer
2023-05-05 18:29 ` bug#63082: [PATCH v3 08/16] services: mpd: Log to syslog by default Maxim Cournoyer
2023-05-05 18:29 ` bug#63082: [PATCH v3 09/16] services: mpd: Do not rotate logs when using syslog Maxim Cournoyer
2023-05-05 18:29 ` bug#63082: [PATCH v3 10/16] services: mpd: Let Shepherd effect the user/group change Maxim Cournoyer
2023-05-24 16:41 ` Bruno Victal
2023-07-25 19:39 ` bug#63082: mpd defaul configuration does not work ('No database' error) Maxim Cournoyer
2023-07-26 15:54 ` bug#63082: [PATCH v3 10/16] services: mpd: Let Shepherd effect the user/group change Maxim Cournoyer
2023-05-05 18:29 ` bug#63082: [PATCH v3 11/16] system: accounts: Export <user-account> Maxim Cournoyer
2023-05-05 18:29 ` bug#63082: [PATCH v3 12/16] services: mpd: Warn when the MPD user is not in the "audio" group Maxim Cournoyer
2023-05-05 18:29 ` bug#63082: [PATCH v3 13/16] services: mpd: Auto-detect mpd-output mixer type by default Maxim Cournoyer
2023-05-05 18:29 ` bug#63082: [PATCH v3 14/16] services: mpd: Provision a default cache directory and set HOME Maxim Cournoyer
2023-05-05 18:29 ` bug#63082: [PATCH v3 15/16] services: mpd: Update basic example Maxim Cournoyer
2023-05-05 18:29 ` bug#63082: [PATCH v3 16/16] services: Avoid 'delete' overrides warning in audio module Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9425ba1d3c110df4e840b334ce70c9e71af9d03c.1682788743.git.maxim.cournoyer@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=63082@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).