unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
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 1/3] services: mcron: Add 'shepherd-requirement' field.
Date: Sat,  1 Apr 2023 18:35:53 +0100	[thread overview]
Message-ID: <c36bb61c1bc857d2d4972e31f7c69ebe8fbd441d.1680370145.git.mirai@makinata.eu> (raw)
In-Reply-To: <47e924fd42f74fc2800dc64399f7a069ad463515.1679854500.git.mirai@makinata.eu>

* gnu/services/mcron.scm (mcron-configuration)[shepherd-requirement]: New field.
(list-of-symbols?): New predicate.
(mcron-shepherd-services): Add support for additional shepherd requirements.
* doc/guix.texi (Scheduled Job Execution): Update it.
---

Notable changes since v3:
* Implemented adjustable user, group and supplementary groups for mcron service.
  These are especially useful when configuring multiple instances. This also aligns
  with upstream recommendation to run multiple mcron instances with lesser
  privileged accounts.

Quoting mcron commit 0fe4d2cc9544d24ecc3e74a2d92433e01b9e25c6:
> I don't believe that anyone should be running system-wide cron processes these
> days (the attack surface is rather large), but should use separate per-user or
> per-service mcron daemon processes.

Tested with 'make check-system TESTS=mcron'.

 doc/guix.texi          |  4 ++++
 gnu/services/mcron.scm | 13 +++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index a58ea8f9ec..56aa86118a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -19379,6 +19379,10 @@ Scheduled Job Execution
 @item @code{mcron} (default: @code{mcron}) (type: file-like)
 The mcron package to use.
 
+@item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbols)
+This is a list of symbols naming Shepherd services that this service
+will depend on.
+
 @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 2ef5980e09..99eb0edd60 100644
--- a/gnu/services/mcron.scm
+++ b/gnu/services/mcron.scm
@@ -32,6 +32,7 @@ (define-module (gnu services mcron)
   #:export (mcron-configuration
             mcron-configuration?
             mcron-configuration-mcron
+            mcron-configuration-shepherd-requirement
             mcron-configuration-jobs
             mcron-configuration-log?
             mcron-configuration-log-file
@@ -58,6 +59,9 @@ (define-module (gnu services mcron)
 (define list-of-gexps?
   (list-of gexp?))
 
+(define list-of-symbols?
+  (list-of symbol?))
+
 (define-maybe/no-serialization string)
 
 (define-configuration/no-serialization mcron-configuration
@@ -65,6 +69,11 @@ (define-configuration/no-serialization mcron-configuration
    (file-like mcron)
    "The mcron package to use.")
 
+  (shepherd-requirement
+   (list-of-symbols '())
+   "This is a list of symbols naming Shepherd services that this service
+will depend on.")
+
   (jobs
    (list-of-gexps '())
    "This is a list of gexps (@pxref{G-Expressions}), where each gexp
@@ -158,13 +167,13 @@ (define (shepherd-schedule-action mcron files)
 
 (define (mcron-shepherd-services config)
   (match-record config <mcron-configuration>
-    (mcron jobs log? log-file log-format date-format)
+    (mcron shepherd-requirement jobs log? log-file log-format date-format)
     (if (eq? jobs '())
         '()                             ;nothing to do
         (let ((files (job-files mcron jobs)))
           (list (shepherd-service
                  (provision '(mcron))
-                 (requirement '(user-processes))
+                 (requirement `(user-processes ,@shepherd-requirement))
                  (modules `((srfi srfi-1)
                             (srfi srfi-26)
                             (ice-9 popen) ;for the 'schedule' action
-- 
2.39.1





  parent reply	other threads:[~2023-04-01 17:37 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 ` Bruno Victal [this message]
2023-04-01 17:35   ` [bug#62465] [PATCH v4 2/3] " Bruno Victal
2023-04-01 17:35   ` [bug#62465] [PATCH v4 3/3] services: mcron: Add user-name, user-group and supplementary-groups fields Bruno Victal

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=c36bb61c1bc857d2d4972e31f7c69ebe8fbd441d.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).