From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 gMfTG95FHmQF0wAASxT56A (envelope-from ) for ; Sat, 25 Mar 2023 01:52:46 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id eFLEG95FHmSHDwEAauVa8A (envelope-from ) for ; Sat, 25 Mar 2023 01:52:46 +0100 Received: from lists.gnu.org (unknown [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 1EC6F28CAC for ; Sat, 25 Mar 2023 01:52:45 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1679705566; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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; bh=eU3Q0GGue8Iiv6Mv0Fw97HAp1FYmvZBx7RkJy9rO++c=; b=XbM4oc3VcHMUZZ/Xtn3zP4jLPt1D384pqFVGcVGkVBUxRvBXJt7KSKvSpuNCvFY6tmBL/P AEHi2PYGbfmXxqt+24asgItqGpvrhYXifQu5YyhJb5IOC8zweMrPxo8JL4ZpAyNNp4RPdl o+pFNtrQ8USX8PeMoY0GVeNiBE7m4uRaHcP11zsNyJRBRtkstx+mWtCRfyn4BJ9ggctAVW DLTGiPhZR+0reAEWfXeZ5q0MsxTMvWIdwL2RNhuSe1JXhbDHojrLglZZqicna25ESeWOT6 idnaq3I7lt4IZY/PiideWaXUAwlwQhSCY/kzHsbGO/4ODFm3gQ2rpE4qzLp/0w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679705566; a=rsa-sha256; cv=none; b=KP85dVxJGZoNf2N71zGshmsQC/qlAoagQUtiOpP6yN/s//B+aWZ+uxlS/+Cm5Up0skq81l 9MDNx5NVNYWautKTIV7I81qwWCpG9TA2ahBzE32zVAnXYlCMidqAZhFORKsGDunkZDGUmD kBIeF5K5CDv8UoVfLUtrY/jenKNGm0DriyFWlXLD3rKmEGqQqTOiSMA7Y3k5ke2cNOORfI bVFr5Eg0ezrqGFFc/QWnMutqBMkKMrrZyh7Lj584h10gy/XBbKEkeomD91lv/hvRVMnPhL asRe5nGFApTt8hQDsIGoFUocBAaKG4MfJUwUP5zFFwFQ5Emp9rFMThL9VzQTLw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfs8d-00017w-Jd; Fri, 24 Mar 2023 20:52:07 -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 1pfs8b-00017R-2O for guix-patches@gnu.org; Fri, 24 Mar 2023 20:52:05 -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 1pfs8a-0007JZ-Ac for guix-patches@gnu.org; Fri, 24 Mar 2023 20:52:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pfs8Z-0008Gy-7c for guix-patches@gnu.org; Fri, 24 Mar 2023 20:52:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62298] [PATCH v3 5/5] services: mympd: Use user-account (resp. user-group) for user (resp. group) fields. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 25 Mar 2023 00:52:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62298 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62298@debbugs.gnu.org Cc: ludo@gnu.org, Bruno Victal , liliana.prikler@gmail.com, maxim.cournoyer@gmail.com Received: via spool by 62298-submit@debbugs.gnu.org id=B62298.167970548531743 (code B ref 62298); Sat, 25 Mar 2023 00:52:03 +0000 Received: (at 62298) by debbugs.gnu.org; 25 Mar 2023 00:51:25 +0000 Received: from localhost ([127.0.0.1]:41773 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pfs7w-0008Fu-RN for submit@debbugs.gnu.org; Fri, 24 Mar 2023 20:51:25 -0400 Received: from smtpm3.myservices.hosting ([185.26.105.234]:54846) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pfs7l-0008FD-KN for 62298@debbugs.gnu.org; Fri, 24 Mar 2023 20:51:24 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm3.myservices.hosting (Postfix) with ESMTP id 5777A21102; Sat, 25 Mar 2023 01:51:12 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 099008009B; Sat, 25 Mar 2023 01:51:12 +0100 (CET) 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 H1GP8l842qYU; Sat, 25 Mar 2023 01:51:11 +0100 (CET) Received: from guix-nuc.home.arpa (bl9-119-177.dsl.telepac.pt [85.242.119.177]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 4C7008009A; Sat, 25 Mar 2023 01:51:11 +0100 (CET) From: Bruno Victal Date: Sat, 25 Mar 2023 00:46:48 +0000 Message-Id: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: X-Migadu-Queue-Id: 1EC6F28CAC X-Spam-Score: 1.77 X-Migadu-Spam-Score: 1.77 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-TUID: uhGgLEvooTiU * 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. --- doc/guix.texi | 4 +-- gnu/services/audio.scm | 75 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 10ce098a21..1e36ea5183 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 55749111ab..5faec5a0df 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -659,6 +659,53 @@ (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) + +(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. +(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'. + (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)))) +;;; + ;; XXX: The serialization procedures are insufficient since we require ;; access to multiple fields at once. @@ -677,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 @@ -818,7 +867,8 @@ (define (mympd-shepherd-service config) (match-record config (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 @@ -828,7 +878,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) @@ -838,8 +888,8 @@ (define (mympd-shepherd-service config) (make-forkexec-constructor `(#$(file-append package "/bin/mympd") - "--user" #$user - #$@(if (eqv? log-to 'syslog) '("--syslog") '()) + "--user" #$username + #$@(if (eq? log-to 'syslog) '("--syslog") '()) "--workdir" #$work-directory "--cachedir" #$cache-directory) #:environment-variables (list #$log-level*) @@ -848,14 +898,11 @@ (define (mympd-shepherd-service config) (define (mympd-accounts config) (match-record config (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. + (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 (log-to) -- 2.39.1