From: Bruno Victal <mirai@makinata.eu>
To: 62465@debbugs.gnu.org
Cc: Bruno Victal <mirai@makinata.eu>, maxim.cournoyer@gmail.com
Subject: [bug#62465] [PATCH v4 3/3] services: mcron: Add user-name, user-group and supplementary-groups fields.
Date: Sat, 1 Apr 2023 18:35:55 +0100 [thread overview]
Message-ID: <a73b89b6ea8f4699dd73fde7e6d8432c6c5d15b1.1680370145.git.mirai@makinata.eu> (raw)
In-Reply-To: <c36bb61c1bc857d2d4972e31f7c69ebe8fbd441d.1680370145.git.mirai@makinata.eu>
Allows mcron to be launched with a different user. This is especially useful
when configuring multiple instances.
* gnu/services/mcron.scm
(mcron-configuration)[user, group, supplementary-groups]: New field.
(list-of-user-groups?): New predicate.
(mcron-shepherd-services): Use newly added fields.
* doc/guix.texi (Scheduled Job Execution): Update it.
---
doc/guix.texi | 9 +++++++++
gnu/services/mcron.scm | 31 +++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/doc/guix.texi b/doc/guix.texi
index e2781cb439..1819e1386c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -19387,6 +19387,15 @@ Scheduled Job Execution
Set the shepherd service name to @code{mcron-@var{instance}}. This is
useful when you want to have more than one mcron instance.
+@item @code{user} (type: maybe-user-account)
+Owner of the @command{mcron} process.
+
+@item @code{group} (type: maybe-user-group)
+Owner group of the @command{mcron} process.
+
+@item @code{supplementary-groups} (type: maybe-list-of-user-groups)
+List of supplementary groups of the @command{mcron} process.
+
@item @code{jobs} (default: @code{()}) (type: list-of-gexps)
This is a list of gexps (@pxref{G-Expressions}), where each gexp
corresponds to an mcron job specification (@pxref{Syntax, mcron job
diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm
index 164ef0e723..b4e28fc65d 100644
--- a/gnu/services/mcron.scm
+++ b/gnu/services/mcron.scm
@@ -23,6 +23,7 @@ (define-module (gnu services mcron)
#:use-module (gnu services configuration)
#:use-module (gnu services shepherd)
#:use-module (gnu packages guile-xyz)
+ #:use-module (gnu system accounts)
#:use-module (guix deprecation)
#:use-module (guix records)
#:use-module (guix gexp)
@@ -64,8 +65,14 @@ (define list-of-gexps?
(define list-of-symbols?
(list-of symbol?))
+(define list-of-user-groups?
+ (list-of user-group?))
+
(define-maybe/no-serialization string)
(define-maybe/no-serialization symbol)
+(define-maybe/no-serialization user-account)
+(define-maybe/no-serialization user-group)
+(define-maybe/no-serialization list-of-user-groups)
(define-configuration/no-serialization mcron-configuration
(mcron
@@ -82,6 +89,18 @@ (define-configuration/no-serialization mcron-configuration
"Set the shepherd service name to @code{mcron-@var{instance}}.
This is useful when you want to have more than one mcron instance.")
+ (user
+ maybe-user-account
+ "Owner of the @command{mcron} process.")
+
+ (group
+ maybe-user-group
+ "Owner group of the @command{mcron} process.")
+
+ (supplementary-groups
+ maybe-list-of-user-groups
+ "List of supplementary groups of the @command{mcron} process.")
+
(jobs
(list-of-gexps '())
"This is a list of gexps (@pxref{G-Expressions}), where each gexp
@@ -178,6 +197,7 @@ (define (shepherd-schedule-action mcron files)
(define (mcron-shepherd-services config)
(match-record config <mcron-configuration>
(mcron shepherd-requirement instance
+ user group supplementary-groups
jobs log? log-file log-format date-format)
(if (eq? jobs '())
'() ;nothing to do
@@ -204,6 +224,17 @@ (define (mcron-shepherd-services config)
'()))
'())
#$@files)
+ #$@(if (maybe-value-set? user)
+ `(#:user ,(user-account-name user))
+ '())
+ #$@(if (maybe-value-set? group)
+ `(#:group ,(user-group-name group))
+ '())
+ #$@(if (maybe-value-set? supplementary-groups)
+ `(#:supplementary-groups
+ ,#~'#$(map user-group-name
+ supplementary-groups))
+ '())
;; Disable auto-compilation of the job files and
;; set a sane value for 'PATH'.
--
2.39.1
prev parent reply other threads:[~2023-04-01 17:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-26 18:18 [bug#62465] [PATCH] services: mcron: Add instance name support for mcron Bruno Victal
2023-03-29 13:44 ` [bug#62465] [PATCH v2 1/2] services: mcron: Add 'shepherd-requirement' field Bruno Victal
2023-03-29 13:54 ` [bug#62465] [PATCH v2 2/2] services: mcron: Add instance name support for mcron Bruno Victal
2023-03-30 14:15 ` [bug#62465] [PATCH v3 1/2] services: mcron: Add 'shepherd-requirement' field Bruno Victal
2023-03-30 14:15 ` [bug#62465] [PATCH v3 2/2] services: mcron: Add instance name support for mcron Bruno Victal
2023-04-01 17:35 ` [bug#62465] [PATCH v4 1/3] services: mcron: Add 'shepherd-requirement' field Bruno Victal
2023-04-01 17:35 ` [bug#62465] [PATCH v4 2/3] services: mcron: Add instance name support for mcron Bruno Victal
2023-04-01 17:35 ` Bruno Victal [this message]
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=a73b89b6ea8f4699dd73fde7e6d8432c6c5d15b1.1680370145.git.mirai@makinata.eu \
--to=mirai@makinata.eu \
--cc=62465@debbugs.gnu.org \
--cc=maxim.cournoyer@gmail.com \
/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).