civodul pushed a commit to branch devel
in repository shepherd.
commit 48dd7e85b280573eb70bce14279979502b8e818c
Author: Ludovic Courtès <[email protected]>
AuthorDate: Sat Oct 12 11:48:17 2024 +0200
timer: Add ‘supplementary-groups’ field to <command>.
* modules/shepherd/service/timer.scm (<command>)[supplementary-groups]:
New field.
(command): Add #:supplementary-groups and honor it.
(command->sexp): Serialize it.
(sexp->command): Deserialize it.
(make-timer-constructor): Pass #:supplementary-groups to
‘start-command’.
* doc/shepherd.texi (Timers): Mention it.
---
doc/shepherd.texi | 2 +-
modules/shepherd/service/timer.scm | 15 +++++++++++++--
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index 1b4f995..0e627b3 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -1557,7 +1557,7 @@ command to execute. Those are specified using the
@code{command}
procedure below.
@deffn {Procedure} command @var{line} @
- [#:user #f] [#:group #f] @
+ [#:user #f] [#:group #f] [#:supplementary-groups '()] @
[#:environment-variables (default-environment-variables)] @
[#:directory (default-service-directory)] @
[#:resource-limits '()]
diff --git a/modules/shepherd/service/timer.scm
b/modules/shepherd/service/timer.scm
index 0e10d40..28dbf73 100644
--- a/modules/shepherd/service/timer.scm
+++ b/modules/shepherd/service/timer.scm
@@ -480,17 +480,20 @@ conciseness."
;; Command to be executed by a timer.
(define-record-type <command>
- (%command arguments user group environment-variables directory
+ (%command arguments user group supplementary-groups
+ environment-variables directory
resource-limits)
command?
(arguments command-arguments)
(user command-user)
(group command-group)
+ (supplementary-groups command-supplementary-groups)
(environment-variables command-environment-variables)
(directory command-directory)
(resource-limits command-resource-limits))
(define* (command arguments #:key user group
+ (supplementary-groups '())
(environment-variables (default-environment-variables))
(directory (default-service-directory))
(resource-limits '()))
@@ -498,7 +501,8 @@ conciseness."
list, to be executed as @var{user} and @var{group}, with the given
@var{environment-variables}, in @var{directory}, and with the given
@var{resource-limits}."
- (%command arguments user group environment-variables directory
+ (%command arguments user group supplementary-groups
+ environment-variables directory
resource-limits))
(define (calendar-event->sexp event)
@@ -530,6 +534,7 @@ list, to be executed as @var{user} and @var{group}, with
the given
(arguments ,(command-arguments command))
(user ,(command-user command))
(group ,(command-group command))
+ (supplementary-groups ,(command-supplementary-groups command))
(environment-variables ,(command-environment-variables command))
(directory ,(command-directory command))
(resource-limits ,(command-resource-limits command))))
@@ -541,11 +546,13 @@ list, to be executed as @var{user} and @var{group}, with
the given
(('command ('version 0)
('arguments arguments)
('user user) ('group group)
+ ('supplementary-groups supplementary-groups)
('environment-variables environment-variables)
('directory directory)
('resource-limits resource-limits)
_ ...)
(command arguments #:user user #:group group
+ #:supplementary-groups supplementary-groups
#:environment-variables environment-variables
#:directory directory
#:resource-limits resource-limits))
@@ -701,6 +708,8 @@ after ~a seconds.")
#:log-file log-file
#:user (command-user action)
#:group (command-group action)
+ #:supplementary-groups
+ (command-supplementary-groups action)
#:environment-variables
(command-environment-variables action)
#:directory (command-directory action)
@@ -871,6 +880,8 @@ first occurrence of that event. Raise an error if
@var{spec} is invalid."
(command arguments
#:user user
#:group (and=> user user-group)
+ ;; FIXME: Should set #:supplementary-groups as
+ ;; returned by 'getgrouplist' for USER.
#:directory
(or (and=> user user-home)
(default-service-directory)))))