From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id QDZENkNLVWTjCgEASxT56A (envelope-from ) for ; Fri, 05 May 2023 20:30:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id IP0BNkNLVWToXwEA9RJhRA (envelope-from ) for ; Fri, 05 May 2023 20:30:27 +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 486EF1211B for ; Fri, 5 May 2023 20:30:27 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pv0C3-0005FG-1Q; Fri, 05 May 2023 14:30:11 -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 1pv0By-0005Bd-UH for bug-guix@gnu.org; Fri, 05 May 2023 14:30:07 -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 1pv0By-00062I-Ko for bug-guix@gnu.org; Fri, 05 May 2023 14:30:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pv0By-0003BR-EA for bug-guix@gnu.org; Fri, 05 May 2023 14:30:06 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#63082: [PATCH v3 10/16] services: mpd: Let Shepherd effect the user/group change. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 05 May 2023 18:30:06 +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.168331138712042 (code B ref 63082); Fri, 05 May 2023 18:30:06 +0000 Received: (at 63082) by debbugs.gnu.org; 5 May 2023 18:29:47 +0000 Received: from localhost ([127.0.0.1]:57496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv0Be-000388-RC for submit@debbugs.gnu.org; Fri, 05 May 2023 14:29:47 -0400 Received: from mail-qt1-f172.google.com ([209.85.160.172]:47575) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv0Bb-00036n-JF for 63082@debbugs.gnu.org; Fri, 05 May 2023 14:29:44 -0400 Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-3eef63eff7eso10574911cf.3 for <63082@debbugs.gnu.org>; Fri, 05 May 2023 11:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683311378; x=1685903378; 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=jhZei39fokEgi8P9CjvAuGJB2a6CjG3QCZtl9A0F+2U=; b=XGmPOXsk7rq38bmjnLtJI1aXdRTarcu0+g6tFOv4zNuM4c3LuEaNqS+HnEyaGfEm6H S1CJOrO8T9tZanmQJYTUz8e+U9BUD0xJSt700Ul2Rc1Hir5o6aYzTLoIaoVGnjJLm5Ss Lf3A0XmDgsD1UOVsk7aPQp4kZR8/Y8yfwNDBjlrGFB2BO7N4auiAlHj9novoQILTmQZs VT7+3cXIN+JREKnH1JFBlY22/F5yFmSO46qr5asZyYV0iD+eVTBfmLyEZ3ecKomt3SjA brWEmQo9Dl87SfaXmMoaKEfKm8GJFvolOu9z4bG+owLT7uVYNJP4u1gAxdTCah+Yhhkr z9Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683311378; x=1685903378; 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=jhZei39fokEgi8P9CjvAuGJB2a6CjG3QCZtl9A0F+2U=; b=OJI5Y/2n7RyClk1bMs0iLoxfvY7iFiaDm4z3vVxUsWUBrFQeuf4NjEOSfQt/EcEzSR TH7SG9kz/tLygB8aDekzMhok+k03pdLvpJwZGqv+7nrlhaFb1mM/aSI5ddrSxLv7i+fq ObFM2Jw1Sz1m5M87ZkvBBJd3EtftwBpXOjoA0de1c/JGIEbA+LdtjU07rP2T0vVu3Kvj 2R2h2spwZdVGkpKW3Rn5J8BXrrWfwhpnDNKaPA1/GVnBv4Wcd9T3wG+2tn/NMMlYGmai Sws9Z+5/lfiLeWnVzYdKWPQcKZ9D/o6oBVj/sw/9AntEO490DWa8cF37lO4U1FKO5bfo +XIA== X-Gm-Message-State: AC+VfDzMsPX7QeM9PV0GchVl3vgKB0MVjLyDKNaIjr7uqAXJCjpIV2Bx nkNr9VL/IsmLj+9f4GQbrhhhr/fV5c0= X-Google-Smtp-Source: ACHHUZ4P/FYK5Rd4soNwYJ5frdS4l7MqN65Q4czUmywT+KqBH14+FljKBhVg426OND4Dlrd3AZZ8iA== X-Received: by 2002:ac8:5745:0:b0:3ef:3960:a1b4 with SMTP id 5-20020ac85745000000b003ef3960a1b4mr4046063qtx.10.1683311377826; Fri, 05 May 2023 11:29:37 -0700 (PDT) Received: from localhost.localdomain (dsl-205-236-230-162.b2b2c.ca. [205.236.230.162]) by smtp.gmail.com with ESMTPSA id c1-20020ac81e81000000b003e97fe68511sm834399qtm.3.2023.05.05.11.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 11:29:37 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 5 May 2023 14:29:05 -0400 Message-Id: <5c6d38ec1621cf031175df6e05c027285d0acaae.1683299529.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.39.2 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: 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=1683311427; a=rsa-sha256; cv=none; b=okPSY1CZ93vJxRCz8FxF5BCzPJL72m83IvBqA6gnoTB/S1C13mJigKBJEAE7zE1tiQ3pjR 2kTDGhG63ZiIRtnIAbSArsWWeWFqmvaqAxlAON2SfP4gcLnH6ktsiGBWIj4QVPCvTpuOtX cC/138pvfvsnUuDi7seAqSB8z0tIAZmKkAZBO+qUs01KEl14jehrEuPZTykxQOQNtLtLQm MYIOFJIzZJv10iUqPL4Lwm2i3dNuiDwxIy9C2m0htxQiewSbML+8XAekb3whhwMpgToZnw JawVWyqRAmS1jRTnGqNvCEhmAnWYIepXGKk6fNiTC8RDdes1wI8qHvo9da8Y0w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20221208 header.b=XGmPOXsk; 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=1683311427; 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:dkim-signature; bh=7+4abTyul5XIWnoN++UR7AsDlHsXMAGT2RGJOM71mcQ=; b=tu1PSRfM3QNC3VQiVXFyMKrC+Z7dZRQRPOtJMpDUpspPay019K7AIci5MOb4dmbs+TfBYq 3stWk/sXhQbSAL6y0T73EAe55NBs37yUxqv28dXAKX1o7HP0smXj2yhXZHr8/5lf78/GJf Nic4T8FWtl+nqBGjVO4preitv+NGSQCC4Rxr709FV2i4aNDCxEh5mNcsd0my0Nl64XR8o7 2fXjHPW2K6ugKaaWUxKB0V90LjdoT6CmpZwAY3pejZITHFNpP8hQ1f4dRt1O7uwvk7Id4M e5SULsPC8kpFT4g2uu4cI7B3btu15P+tu4cyWVmF05fxClrpWT8Y8/h3HTpdvA== X-Migadu-Spam-Score: -1.61 X-Spam-Score: -1.61 X-Migadu-Queue-Id: 486EF1211B X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20221208 header.b=XGmPOXsk; 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: ER3AneXnyvBk Relates to . 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 253b8f113b..cdc1f4dedc 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -33598,7 +33598,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. @@ -33642,7 +33642,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 @@ -33827,13 +33827,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 @@ -33877,7 +33877,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) @@ -33903,7 +33903,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 ;;; Copyright © 2020 Ludovic Courtès ;;; Copyright © 2022⁠–⁠2023 Bruno Victal +;;; Copyright © 2023 Maxim Cournoyer ;;; ;;; 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)))) @@ -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 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