unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#59860] [PATCH 0/2] Add shepherd-requirement field to OpenSMTPD
@ 2022-12-06 16:50 mirai
  2022-12-06 16:52 ` [bug#59860] [PATCH 1/2] services: opensmtpd: Use 'match-record' instead of 'match' mirai
  2022-12-06 16:52 ` [bug#59860] [PATCH 2/2] services: opensmtpd: Add shepherd-requirement field mirai
  0 siblings, 2 replies; 3+ messages in thread
From: mirai @ 2022-12-06 16:50 UTC (permalink / raw)
  To: 59860; +Cc: mirai

Replaces the use of 'match-lambda' with 'match-record' and adds
a 'shepherd-requirement' field to opensmtpd-configuration.

Bruno Victal (2):
  services: opensmtpd: Use 'match-record' instead of 'match'.
  services: opensmtpd: Add shepherd-requirement field.

 doc/guix.texi         |   5 ++
 gnu/services/mail.scm | 120 +++++++++++++++++++++---------------------
 2 files changed, 65 insertions(+), 60 deletions(-)


base-commit: b94724e8b2102be0fe9d19e9dfe44d6f7101bd4b
-- 
2.38.1





^ permalink raw reply	[flat|nested] 3+ messages in thread

* [bug#59860] [PATCH 1/2] services: opensmtpd: Use 'match-record' instead of 'match'.
  2022-12-06 16:50 [bug#59860] [PATCH 0/2] Add shepherd-requirement field to OpenSMTPD mirai
@ 2022-12-06 16:52 ` mirai
  2022-12-06 16:52 ` [bug#59860] [PATCH 2/2] services: opensmtpd: Add shepherd-requirement field mirai
  1 sibling, 0 replies; 3+ messages in thread
From: mirai @ 2022-12-06 16:52 UTC (permalink / raw)
  To: 59860; +Cc: Bruno Victal

From: Bruno Victal <mirai@makinata.eu>

* gnu/services/mail.scm (opensmtpd-shepherd-service)
(opensmtpd-activation)
(opensmtpd-set-gids): Use 'match-record' instead of 'match'.
---
 gnu/services/mail.scm | 117 ++++++++++++++++++++----------------------
 1 file changed, 57 insertions(+), 60 deletions(-)

diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index 2dc235a585..dc4a7986b6 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -1666,18 +1666,17 @@ (define %default-opensmtpd-config-file
 match from local for any action outbound
 "))
 
-(define opensmtpd-shepherd-service
-  (match-lambda
-    (($ <opensmtpd-configuration> package config-file)
-     (list (shepherd-service
-            (provision '(smtpd))
-            (requirement '(loopback))
-            (documentation "Run the OpenSMTPD daemon.")
-            (start (let ((smtpd (file-append package "/sbin/smtpd")))
-                     #~(make-forkexec-constructor
-                        (list #$smtpd "-f" #$config-file)
-                        #:pid-file "/var/run/smtpd.pid")))
-            (stop #~(make-kill-destructor)))))))
+(define (opensmtpd-shepherd-service config)
+  (match-record config <opensmtpd-configuration> (package config-file)
+    (list (shepherd-service
+           (provision '(smtpd))
+           (requirement '(loopback))
+           (documentation "Run the OpenSMTPD daemon.")
+           (start (let ((smtpd (file-append package "/sbin/smtpd")))
+                    #~(make-forkexec-constructor
+                       (list #$smtpd "-f" #$config-file)
+                       #:pid-file "/var/run/smtpd.pid")))
+           (stop #~(make-kill-destructor))))))
 
 (define %opensmtpd-accounts
   (list (user-group
@@ -1698,58 +1697,56 @@ (define %opensmtpd-accounts
          (home-directory "/var/empty")
          (shell (file-append shadow "/sbin/nologin")))))
 
-(define opensmtpd-activation
-  (match-lambda
-    (($ <opensmtpd-configuration> package config-file)
-     (let ((smtpd (file-append package "/sbin/smtpd")))
-       #~(begin
-           (use-modules (guix build utils))
-           ;; Create mbox and spool directories.
-           (mkdir-p "/var/mail")
-           (mkdir-p "/var/spool/smtpd")
-           (chmod "/var/spool/smtpd" #o711)
-           (mkdir-p "/var/spool/mail")
-           (chmod "/var/spool/mail" #o711))))))
+(define (opensmtpd-activation config)
+  (match-record config <opensmtpd-configuration> (package config-file)
+    (let ((smtpd (file-append package "/sbin/smtpd")))
+      #~(begin
+          (use-modules (guix build utils))
+          ;; Create mbox and spool directories.
+          (mkdir-p "/var/mail")
+          (mkdir-p "/var/spool/smtpd")
+          (chmod "/var/spool/smtpd" #o711)
+          (mkdir-p "/var/spool/mail")
+          (chmod "/var/spool/mail" #o711)))))
 
 (define %opensmtpd-pam-services
   (list (unix-pam-service "smtpd")))
 
-(define opensmtpd-set-gids
-  (match-lambda
-    (($ <opensmtpd-configuration> package config-file set-gids?)
-     (if set-gids?
-         (list
-          (setuid-program
-           (program (file-append package "/sbin/smtpctl"))
-           (setuid? #false)
-           (setgid? #true)
-           (group "smtpq"))
-          (setuid-program
-           (program (file-append package "/sbin/sendmail"))
-           (setuid? #false)
-           (setgid? #true)
-           (group "smtpq"))
-          (setuid-program
-           (program (file-append package "/sbin/send-mail"))
-           (setuid? #false)
-           (setgid? #true)
-           (group "smtpq"))
-          (setuid-program
-           (program (file-append package "/sbin/makemap"))
-           (setuid? #false)
-           (setgid? #true)
-           (group "smtpq"))
-          (setuid-program
-           (program (file-append package "/sbin/mailq"))
-           (setuid? #false)
-           (setgid? #true)
-           (group "smtpq"))
-          (setuid-program
-           (program (file-append package "/sbin/newaliases"))
-           (setuid? #false)
-           (setgid? #true)
-           (group "smtpq")))
-         '()))))
+(define (opensmtpd-set-gids config)
+  (match-record config <opensmtpd-configuration> (package config-file setgid-commands?)
+    (if setgid-commands?
+        (list
+         (setuid-program
+          (program (file-append package "/sbin/smtpctl"))
+          (setuid? #false)
+          (setgid? #true)
+          (group "smtpq"))
+         (setuid-program
+          (program (file-append package "/sbin/sendmail"))
+          (setuid? #false)
+          (setgid? #true)
+          (group "smtpq"))
+         (setuid-program
+          (program (file-append package "/sbin/send-mail"))
+          (setuid? #false)
+          (setgid? #true)
+          (group "smtpq"))
+         (setuid-program
+          (program (file-append package "/sbin/makemap"))
+          (setuid? #false)
+          (setgid? #true)
+          (group "smtpq"))
+         (setuid-program
+          (program (file-append package "/sbin/mailq"))
+          (setuid? #false)
+          (setgid? #true)
+          (group "smtpq"))
+         (setuid-program
+          (program (file-append package "/sbin/newaliases"))
+          (setuid? #false)
+          (setgid? #true)
+          (group "smtpq")))
+        '())))
 
 (define opensmtpd-service-type
   (service-type
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#59860] [PATCH 2/2] services: opensmtpd: Add shepherd-requirement field.
  2022-12-06 16:50 [bug#59860] [PATCH 0/2] Add shepherd-requirement field to OpenSMTPD mirai
  2022-12-06 16:52 ` [bug#59860] [PATCH 1/2] services: opensmtpd: Use 'match-record' instead of 'match' mirai
@ 2022-12-06 16:52 ` mirai
  1 sibling, 0 replies; 3+ messages in thread
From: mirai @ 2022-12-06 16:52 UTC (permalink / raw)
  To: 59860; +Cc: Bruno Victal

From: Bruno Victal <mirai@makinata.eu>

---
 doc/guix.texi         | 5 +++++
 gnu/services/mail.scm | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index a79b777826..4cf60d7114 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -25730,6 +25730,11 @@ Data type representing the configuration of opensmtpd.
 @item @code{package} (default: @var{opensmtpd})
 Package object of the OpenSMTPD SMTP server.
 
+@item @code{shepherd-requirement} (default: @code{'()})
+This option can be used to provide a list of symbols naming Shepherd services
+that this service will depend on, such as @code{'networking}
+if you want to configure OpenSMTPD to listen on non-loopback interfaces.
+
 @item @code{config-file} (default: @code{%default-opensmtpd-config-file})
 File-like object of the OpenSMTPD configuration file to use.  By default
 it listens on the loopback network interface, and allows for mail from
diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm
index dc4a7986b6..6f588679b1 100644
--- a/gnu/services/mail.scm
+++ b/gnu/services/mail.scm
@@ -1651,6 +1651,8 @@ (define-record-type* <opensmtpd-configuration>
   opensmtpd-configuration?
   (package     opensmtpd-configuration-package
                (default opensmtpd))
+  (shepherd-requirement opensmtpd-configuration-shepherd-requirement
+                        (default '())) ; list of symbols
   (config-file opensmtpd-configuration-config-file
                (default %default-opensmtpd-config-file))
   (setgid-commands? opensmtpd-setgid-commands? (default #t)))
@@ -1667,10 +1669,11 @@ (define %default-opensmtpd-config-file
 "))
 
 (define (opensmtpd-shepherd-service config)
-  (match-record config <opensmtpd-configuration> (package config-file)
+  (match-record config <opensmtpd-configuration>
+                       (package config-file shepherd-requirement)
     (list (shepherd-service
            (provision '(smtpd))
-           (requirement '(loopback))
+           (requirement `(loopback ,@shepherd-requirement))
            (documentation "Run the OpenSMTPD daemon.")
            (start (let ((smtpd (file-append package "/sbin/smtpd")))
                     #~(make-forkexec-constructor
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-06 16:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06 16:50 [bug#59860] [PATCH 0/2] Add shepherd-requirement field to OpenSMTPD mirai
2022-12-06 16:52 ` [bug#59860] [PATCH 1/2] services: opensmtpd: Use 'match-record' instead of 'match' mirai
2022-12-06 16:52 ` [bug#59860] [PATCH 2/2] services: opensmtpd: Add shepherd-requirement field mirai

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