services: Refactor opensmtpd-set-gids.

* gnu/services/mail.scm (opensmtpd-set-gids):
Rewrite using MAP technology.

Change-Id: I30b7eddaf64d242196b1c56f98dec42a86436c18
This commit is contained in:
Tobias Geerinckx-Rice 2024-08-18 02:00:00 +02:00
parent 79833cdbc6
commit ed3649bcce
No known key found for this signature in database
GPG key ID: 0DB0FF884F556D79

View file

@ -1743,37 +1743,20 @@ (define %opensmtpd-pam-services
(define (opensmtpd-set-gids config)
(match-record config <opensmtpd-configuration> (package config-file setgid-commands?)
(if setgid-commands?
(list
(privileged-program
(program (file-append package "/sbin/smtpctl"))
(setuid? #false)
(setgid? #true)
(group "smtpq"))
(privileged-program
(program (file-append package "/sbin/sendmail"))
(setuid? #false)
(setgid? #true)
(group "smtpq"))
(privileged-program
(program (file-append package "/sbin/send-mail"))
(setuid? #false)
(setgid? #true)
(group "smtpq"))
(privileged-program
(program (file-append package "/sbin/makemap"))
(setuid? #false)
(setgid? #true)
(group "smtpq"))
(privileged-program
(program (file-append package "/sbin/mailq"))
(setuid? #false)
(setgid? #true)
(group "smtpq"))
(privileged-program
(program (file-append package "/sbin/newaliases"))
(setuid? #false)
(setgid? #true)
(group "smtpq")))
(map (lambda (command)
(privileged-program
(program (file-append package "/" command))
(setgid? #t)
(group "smtpq")))
(list "sbin/smtpctl"
;; Also privilege the compatibility symlinks created by
;; the Guix opensmtpd package; all synonyms for smtpctl.
"sbin/mailq"
"sbin/makemap"
"sbin/newaliases"
"sbin/sendmail"
"sbin/send-mail"))
'())))
(define opensmtpd-service-type