From 616b0d55783b1c9bf1c5a9438ac929c9a48e3aa4 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 16 Mar 2023 09:42:12 -0300 Subject: queue.scm: Use mkdir-p/perms vs mkdir-p+chown+chmod --- src/org/euandre/queue.scm | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/org/euandre/queue.scm b/src/org/euandre/queue.scm index edc6de3..3fe4db2 100644 --- a/src/org/euandre/queue.scm +++ b/src/org/euandre/queue.scm @@ -516,12 +516,9 @@ collections.OrderedDict that works in Python 2.4-2.6.") (user run-directory) #~(begin (use-modules (guix build utils)) - (let ((user (getpwnam #$user))) - (format (current-error-port) - "Creating Cyrus SASL socket directory: \"~a\".~%" #$run-directory) - (mkdir-p #$run-directory) - (chown #$run-directory (passwd:uid user) (passwd:gid user)) - (chmod #$run-directory #o755))))) + (format (current-error-port) + "Creating Cyrus SASL socket directory: \"~a\".~%" #$run-directory) + (mkdir-p/perms #$run-directory (getpwnam #$user) #o755)))) (define (cyrus-sasl-accounts config) (match-record config @@ -688,13 +685,12 @@ keyfile ~a/private.key (user group data-directory key-size) #~(begin (use-modules (guix build utils)) - (let ((uid (passwd:uid (getpwnam #$user))) - (gid (group:gid (getgrnam #$group)))) + (let* ((user (getpwnam #$user)) + (uid (passwd:uid user)) + (gid (passwd:gid user))) (format (current-error-port) "Creating DKIMproxy.out data directory: \"~a\".~%" #$data-directory) - (mkdir-p #$data-directory) - (chown #$data-directory uid gid) - (chmod #$data-directory #o755) + (mkdir-p/perms #$data-directory user #o755) (let ((private-key (string-append #$data-directory "/private.key")) (public-key (string-append #$data-directory "/public.key"))) (unless (file-exists? private-key) @@ -1024,12 +1020,10 @@ milter_default_action = accept (let ((user (getpwnam "root"))) (format (current-error-port) "Creating Postfix queue directory: \"~a\".~%" #$queue-directory) - (mkdir-p #$queue-directory) - (chown #$queue-directory (passwd:uid user) (passwd:gid user)) - (chmod #$queue-directory #o755) + (mkdir-p/perms #$queue-directory user #o755) (format (current-error-port) "Creating email spool director: \"/var/mail\".~%") - (mkdir-p "/var/mail") + (mkdir-p/perms "/var/mail" user #o755) (format (current-error-port) "Updating /etc/aliases: FIXME.~%") ;; FIXME: add -c option @@ -1355,9 +1349,9 @@ namespace inbox { (let ((user (getpwnam "root"))) (format (current-error-port) "Creating Dovecot base_dir directory: \"~a\".~%" #$base-dir) - (mkdir-p #$base-dir) + (mkdir-p/perms #$base-dir user #o755) (let ((dhparam.pem (string-append #$state-dir "/dhparam.pem"))) - (mkdir-p #$state-dir) + (mkdir-p/perms #$state-dir user #o755) (unless (file-exists? dhparam.pem) (format (current-error-port) "dhparam.pem file doesn't exist yet. Generating one...~%") -- cgit v1.2.3