From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Bruno Victal <mirai@makinata.eu>
Cc: 62298@debbugs.gnu.org, ludo@gnu.org, liliana.prikler@gmail.com
Subject: [bug#62298] [PATCH v2 8/8] services: mympd: Use user-account (resp. user-group) for user (resp. group) fields.
Date: Fri, 24 Mar 2023 12:03:09 -0400 [thread overview]
Message-ID: <877cv6yw5e.fsf@gmail.com> (raw)
In-Reply-To: <364a2fe961ddce2c4668c0c8b78f46bffe2c2096.1679583701.git.mirai@makinata.eu> (Bruno Victal's message of "Thu, 23 Mar 2023 15:02:18 +0000")
Hello,
Bruno Victal <mirai@makinata.eu> writes:
> services: mympd: Use user-account (resp. user-group) for user (resp. group) fields.
>
> * gnu/services/audio.scm (%mympd-user, %mympd-group): New variable.
> (mympd-user-sanitizer, mympd-group-sanitizer): New procedure.
> (mympd-configuration)[user, group]: Set value type to user-account (resp. user-group).
> (mympd-serialize-configuration): Adapt for user-account values in user field.
> (mympd-accounts): Adapt for user-account (resp. user-group) in user (resp. group) field.
Please configure your editor for the 80 characters mark.
> ---
> doc/guix.texi | 4 +--
> gnu/services/audio.scm | 74 ++++++++++++++++++++++++++++++++++--------
> 2 files changed, 63 insertions(+), 15 deletions(-)
>
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 520a65b0b1..ee1e66b3ff 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -33732,10 +33732,10 @@ Audio Services
> This is a list of symbols naming Shepherd services that this service
> will depend on.
>
> -@item @code{user} (default: @code{"mympd"}) (type: string)
> +@item @code{user} (type: maybe-user-account)
> Owner of the @command{mympd} process.
>
> -@item @code{group} (default: @code{"nogroup"}) (type: string)
> +@item @code{group} (type: maybe-user-group)
> Owner group of the @command{mympd} process.
>
> @item @code{work-directory} (default: @code{"/var/lib/mympd"}) (type: string)
> diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm
> index c168d1481c..f7f430039e 100644
> --- a/gnu/services/audio.scm
> +++ b/gnu/services/audio.scm
> @@ -659,6 +659,54 @@ (define-configuration/no-serialization mympd-ip-acl
> (define-maybe/no-serialization integer)
> (define-maybe/no-serialization mympd-ip-acl)
>
> +;; XXX: These will shadow the previous definition used by mpd
> +;; and cause warnings to be shown. Maybe split the file
> +;; into audio/mpd.scm and audio/mympd.scm ?
> +#;(define-maybe/no-serialization user-account)
> +#;(define-maybe/no-serialization user-group)
I'd rather keeping them together if possible; could the prefix trick be
used with them? No need for a hanging indent for continued text, here
and for the other occurrences.
The expressions commented; should they be? On another note, '#;'
appears undocumented, I'd avoid it until it is (and it's not necessary
here).
> +(define %mympd-user
> + (user-account
> + (name "mympd")
> + (group "mympd")
> + (system? #t)
> + (comment "myMPD user")
> + (home-directory "/var/empty")
> + (shell (file-append shadow "/sbin/nologin"))))
> +
> +(define %mympd-group
> + (user-group
> + (name "mympd")
> + (system? #t)))
> +
> +;;; TODO: procedures for unsupported value types, to be removed.
^ Procedures
> +(define (mympd-user-sanitizer value)
> + (cond ((user-account? value) value)
> + ((string? value)
> + (warning (G_ "string value for 'user' is not supported, use \
> +user-account instead~%"))
> + (user-account
> + (inherit %mympd-user)
> + (name value)
> + ;; XXX: this is to be lazily substituted in (…-accounts)
> + ;; with the value from 'group'.
Extraneous hanging indent :-).
> + (group %lazy-group)))
> + (else
> + (configuration-field-error #f 'user value))))
> +
> +(define (mympd-group-sanitizer value)
> + (cond ((user-group? value) value)
> + ((string? value)
> + (warning (G_ "string value for 'group' is not supported, use \
> +user-group instead~%"))
> + (user-group
> + (inherit %mympd-group)
> + (name value)))
> + (else
> + (configuration-field-error #f 'group value))))
> +;;;
Was this ';;;' added by mistake?
> ;; XXX: The serialization procedures are insufficient since we require
> ;; access to multiple fields at once.
> ;; Fields marked with empty-serializer are never serialized and are
> @@ -676,13 +724,15 @@ (define-configuration/no-serialization mympd-configuration
> empty-serializer)
>
> (user
> - (string "mympd")
> + (maybe-user-account %mympd-user)
> "Owner of the @command{mympd} process."
> + (sanitizer mympd-user-sanitizer)
> empty-serializer)
>
> (group
> - (string "nogroup")
> + (maybe-user-group %mympd-group)
> "Owner group of the @command{mympd} process."
> + (sanitizer mympd-group-sanitizer)
> empty-serializer)
>
> (work-directory
> @@ -817,7 +867,8 @@ (define (mympd-shepherd-service config)
> (match-record config <mympd-configuration> (package shepherd-requirement
> user work-directory
> cache-directory log-level log-to)
> - (let ((log-level* (format #f "MYMPD_LOGLEVEL=~a" log-level)))
> + (let ((log-level* (format #f "MYMPD_LOGLEVEL=~a" log-level))
> + (username (user-account-name user)))
> (shepherd-service
> (documentation "Run the myMPD daemon.")
> (requirement `(loopback user-processes
> @@ -825,7 +876,7 @@ (define (mympd-shepherd-service config)
> ,@shepherd-requirement))
> (provision '(mympd))
> (start #~(begin
> - (let* ((pw (getpwnam #$user))
> + (let* ((pw (getpwnam #$username))
> (uid (passwd:uid pw))
> (gid (passwd:gid pw)))
> (for-each (lambda (dir)
> @@ -835,7 +886,7 @@ (define (mympd-shepherd-service config)
>
> (make-forkexec-constructor
> `(#$(file-append package "/bin/mympd")
> - "--user" #$user
> + "--user" #$username
> #$@(if (eqv? log-to 'syslog) '("--syslog") '())
> "--workdir" #$work-directory
> "--cachedir" #$cache-directory)
> @@ -845,14 +896,11 @@ (define (mympd-shepherd-service config)
>
> (define (mympd-accounts config)
> (match-record config <mympd-configuration> (user group)
> - (list (user-group (name group)
> - (system? #t))
> - (user-account (name user)
> - (group group)
> - (system? #t)
> - (comment "myMPD user")
> - (home-directory "/var/empty")
> - (shell (file-append shadow "/sbin/nologin"))))))
> + ;; TODO: deprecation code, to be removed
Please use a full sentence.
> + (let ((user (if (eq? (user-account-group user) %lazy-group)
> + (inject-group-into-user user group)
> + user)))
> + (list user group))))
>
> (define (mympd-log-rotation config)
> (match-record config <mympd-configuration> (log-to)
LGTM, with the comments from Liliana taken into account.
--
Thanks,
Maxim
next prev parent reply other threads:[~2023-03-24 22:02 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-20 16:45 [bug#62298] [PATCH 0/8] Extensible define-configuration & mpd/mympd service fixes Bruno Victal
2023-03-20 17:07 ` [bug#62298] [PATCH 1/8] services: configuration: Add user-defined sanitizer support Bruno Victal
2023-03-20 19:43 ` Liliana Marie Prikler
2023-03-20 17:07 ` [bug#62298] [PATCH 2/8] services: replace bare serializers with (serializer ...) Bruno Victal
2023-03-20 17:07 ` [bug#62298] [PATCH 3/8] services: audio: remove redundant list-of-string? predicate Bruno Victal
2023-03-20 17:07 ` [bug#62298] [PATCH 4/8] services: mympd: Require 'syslog service when configured to log to syslog Bruno Victal
2023-03-20 17:07 ` [bug#62298] [PATCH 5/8] services: mpd: Fix unintentional API breakage for mixer-type field Bruno Victal
2023-03-20 17:07 ` [bug#62298] [PATCH 6/8] services: mpd: Set PulseAudio related variables as default value for environment-variables field Bruno Victal
2023-03-20 17:07 ` [bug#62298] [PATCH 7/8] services: mpd: Use user-account (resp. user-group) for user (resp. group) fields Bruno Victal
2023-03-20 19:33 ` Liliana Marie Prikler
2023-03-21 2:10 ` Bruno Victal
2023-03-21 5:30 ` Liliana Marie Prikler
2023-03-20 17:07 ` [bug#62298] [PATCH 8/8] services: mympd: " Bruno Victal
2023-03-20 19:33 ` Liliana Marie Prikler
2023-03-23 15:02 ` [bug#62298] [PATCH v2 1/8] services: configuration: Add user-defined sanitizer support Bruno Victal
2023-03-23 15:02 ` [bug#62298] [PATCH v2 2/8] services: replace bare serializers with (serializer ...) Bruno Victal
2023-03-24 14:28 ` Maxim Cournoyer
2023-03-23 15:02 ` [bug#62298] [PATCH v2 3/8] services: audio: remove redundant list-of-string? predicate Bruno Victal
2023-03-23 15:02 ` [bug#62298] [PATCH v2 4/8] services: mympd: Require 'syslog service when configured to log to syslog Bruno Victal
2023-03-24 14:32 ` Maxim Cournoyer
2023-03-23 15:02 ` [bug#62298] [PATCH v2 5/8] services: mpd: Fix unintentional API breakage for mixer-type field Bruno Victal
2023-03-23 15:02 ` [bug#62298] [PATCH v2 6/8] services: mpd: Set PulseAudio related variables as default value for environment-variables field Bruno Victal
2023-03-24 18:10 ` bug#62298: " Maxim Cournoyer
2023-03-23 15:02 ` [bug#62298] [PATCH v2 7/8] services: mpd: Use user-account (resp. user-group) for user (resp. group) fields Bruno Victal
2023-03-23 18:03 ` Liliana Marie Prikler
2023-03-24 15:31 ` Maxim Cournoyer
2023-03-23 15:02 ` [bug#62298] [PATCH v2 8/8] services: mympd: " Bruno Victal
2023-03-23 19:19 ` Liliana Marie Prikler
2023-03-25 0:39 ` Bruno Victal
2023-03-24 16:03 ` Maxim Cournoyer [this message]
2023-03-25 0:33 ` Bruno Victal
2023-03-25 5:21 ` Liliana Marie Prikler
2023-03-23 19:47 ` [bug#62298] [PATCH v2 1/8] services: configuration: Add user-defined sanitizer support Liliana Marie Prikler
2023-03-24 14:25 ` Maxim Cournoyer
2023-03-24 18:03 ` Liliana Marie Prikler
2023-03-26 2:01 ` Maxim Cournoyer
2023-03-25 0:46 ` [bug#62298] [PATCH v3 1/5] " Bruno Victal
2023-03-25 0:46 ` [bug#62298] [PATCH v3 2/5] services: replace bare serializers with (serializer ...) Bruno Victal
2023-03-25 0:46 ` [bug#62298] [PATCH v3 3/5] services: mpd: Fix unintentional API breakage for mixer-type field Bruno Victal
2023-03-25 0:46 ` [bug#62298] [PATCH v3 4/5] services: mpd: Use user-account (resp. user-group) for user (resp. group) fields Bruno Victal
2023-03-25 0:46 ` [bug#62298] [PATCH v3 5/5] services: mympd: " Bruno Victal
2023-03-26 18:41 ` [bug#62298] [PATCH v4 1/5] services: configuration: Add user-defined sanitizer support Bruno Victal
2023-03-26 18:41 ` [bug#62298] [PATCH v4 2/5] services: replace bare serializers with (serializer ...) Bruno Victal
2023-03-26 18:41 ` [bug#62298] [PATCH v4 3/5] services: mpd: Fix unintentional API breakage for mixer-type field Bruno Victal
2023-03-26 18:41 ` [bug#62298] [PATCH v4 4/5] services: mpd: Use user-account (resp. user-group) for user (resp. group) fields Bruno Victal
2023-03-26 18:41 ` [bug#62298] [PATCH v4 5/5] services: mympd: " Bruno Victal
2023-04-02 10:46 ` bug#62298: [PATCH v4 1/5] services: configuration: Add user-defined sanitizer support Liliana Marie Prikler
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=877cv6yw5e.fsf@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=62298@debbugs.gnu.org \
--cc=liliana.prikler@gmail.com \
--cc=ludo@gnu.org \
--cc=mirai@makinata.eu \
/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).