From patchwork Sat Oct 15 07:51:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Lepiller X-Patchwork-Id: 43420 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A456C27BBEA; Sat, 15 Oct 2022 08:53:21 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id BD59F27BBE9 for ; Sat, 15 Oct 2022 08:53:20 +0100 (BST) Received: from localhost ([::1]:41066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ojbyx-0005xt-UI for patchwork@mira.cbaines.net; Sat, 15 Oct 2022 03:53:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojbyg-0005wY-Ae for guix-patches@gnu.org; Sat, 15 Oct 2022 03:53:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40246) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ojbyg-0004BO-3B for guix-patches@gnu.org; Sat, 15 Oct 2022 03:53:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ojbyf-0002ma-TZ for guix-patches@gnu.org; Sat, 15 Oct 2022 03:53:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58541] [PATCH] gnu: =?utf-8?q?dovecot=3A=C2=A0Use?= standard mkdir-p/perms. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 15 Oct 2022 07:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58541 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58541@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.166582035710658 (code B ref -1); Sat, 15 Oct 2022 07:53:01 +0000 Received: (at submit) by debbugs.gnu.org; 15 Oct 2022 07:52:37 +0000 Received: from localhost ([127.0.0.1]:39324 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ojbyG-0002lp-Qh for submit@debbugs.gnu.org; Sat, 15 Oct 2022 03:52:37 -0400 Received: from lists.gnu.org ([209.51.188.17]:35224) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ojbyF-0002li-91 for submit@debbugs.gnu.org; Sat, 15 Oct 2022 03:52:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojbyE-0005v5-JY for guix-patches@gnu.org; Sat, 15 Oct 2022 03:52:34 -0400 Received: from lepiller.eu ([89.234.186.109]:53744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojby0-00047N-EV for guix-patches@gnu.org; Sat, 15 Oct 2022 03:52:34 -0400 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id ac336ee9 for ; Sat, 15 Oct 2022 07:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:subject:message-id:mime-version:content-type; s=dkim; bh=nHB TmCCWjHPrplrp8mRgdBiqY4auxZ/SsOgXVhalagQ=; b=K6z3K5PDFg4XYA171fz Az9oi5YBg0T4OK46wXsgfx/BmGnYE55QtVScdqX/dv8fUZkJfXykLb1xjsXrFJZF h6ob16BvNJKlBZdkA9j6za0HcxnHAIeGU4qaf9o3dcs+XBqhG+/5JZKC3DklLNNG SVyOPVYr93yETkcmiNb7wrwaU89t9do0htvd5C3Jf9ffwu8DMksaH3FXxolgLxfq QDMAAuhgyK6MMJCA+AGLqACqHxGGJ7EebA6yWfosRPxn5zI4RKcsH5CozPSQ6ve7 fMemd802jwEfQVB7LamOfG2klTSCc07WP0N2YPIeXyGrLC+f3+pybGJ8yuxJeNn6 nDA== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id e5de0c67 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Sat, 15 Oct 2022 07:51:09 +0000 (UTC) Date: Sat, 15 Oct 2022 09:51:07 +0200 From: Julien Lepiller Message-ID: <20221015094927.595686fb@sybil.lepiller.eu> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Received-SPF: pass client-ip=89.234.186.109; envelope-from=julien@lepiller.eu; helo=lepiller.eu X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi Guix! While investigating an issue I have with dovecot and knot, I figured that the dovecot service had a custom mkdir-p/perms procedure that hard-coded the directory to chown, which would not chown any other directories created with it. The patch makes it use mkdir-p/perms from (gnu build utils) instead. I don't think this will fix my issue, but at least, that's one bug fixed :) From 7b754b0f8b31475d22a0bf4c106f0249fc5dd1b7 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Sat, 15 Oct 2022 09:19:38 +0200 Subject: [PATCH] gnu: dovecot: Use standard mkdir-p/perms. * gnu/services/mail.scm (%dovecot-activation): Use (gnu build utils). --- gnu/services/mail.scm | 114 +++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm index 43f144a42d..2dc235a585 100644 --- a/gnu/services/mail.scm +++ b/gnu/services/mail.scm @@ -35,6 +35,7 @@ (define-module (gnu services mail) #:use-module (gnu packages admin) #:use-module (gnu packages dav) #:use-module (gnu packages tls) + #:use-module (guix modules) #:use-module (guix records) #:use-module (guix packages) #:use-module (guix gexp) @@ -1512,64 +1513,61 @@ (define (%dovecot-activation config) (lambda () (serialize-configuration config dovecot-configuration-fields))))))) - #~(begin - (use-modules (guix build utils)) - (define (mkdir-p/perms directory owner perms) - (mkdir-p directory) - (chown "/var/run/dovecot" (passwd:uid owner) (passwd:gid owner)) - (chmod directory perms)) - (define (build-subject parameters) - (string-concatenate - (map (lambda (pair) - (let ((k (car pair)) (v (cdr pair))) - (define (escape-char str chr) - (string-join (string-split str chr) (string #\\ chr))) - (string-append "/" k "=" - (escape-char (escape-char v #\=) #\/)))) - (filter (lambda (pair) (cdr pair)) parameters)))) - (define* (create-self-signed-certificate-if-absent - #:key private-key public-key (owner (getpwnam "root")) - (common-name (gethostname)) - (organization-name "Guix") - (organization-unit-name "Default Self-Signed Certificate") - (subject-parameters `(("CN" . ,common-name) - ("O" . ,organization-name) - ("OU" . ,organization-unit-name))) - (subject (build-subject subject-parameters))) - ;; Note that by default, OpenSSL outputs keys in PEM format. This - ;; is what we want. - (unless (file-exists? private-key) - (cond - ((zero? (system* (string-append #$openssl "/bin/openssl") - "genrsa" "-out" private-key "2048")) - (chown private-key (passwd:uid owner) (passwd:gid owner)) - (chmod private-key #o400)) - (else - (format (current-error-port) - "Failed to create private key at ~a.\n" private-key)))) - (unless (file-exists? public-key) - (cond - ((zero? (system* (string-append #$openssl "/bin/openssl") - "req" "-new" "-x509" "-key" private-key - "-out" public-key "-days" "3650" - "-batch" "-subj" subject)) - (chown public-key (passwd:uid owner) (passwd:gid owner)) - (chmod public-key #o444)) - (else - (format (current-error-port) - "Failed to create public key at ~a.\n" public-key))))) - (let ((user (getpwnam "dovecot"))) - (mkdir-p/perms "/var/run/dovecot" user #o755) - (mkdir-p/perms "/var/lib/dovecot" user #o755) - (mkdir-p/perms "/etc/dovecot" user #o755) - (copy-file #$(plain-file "dovecot.conf" config-str) - "/etc/dovecot/dovecot.conf") - (mkdir-p/perms "/etc/dovecot/private" user #o700) - (create-self-signed-certificate-if-absent - #:private-key "/etc/dovecot/private/default.pem" - #:public-key "/etc/dovecot/default.pem" - #:owner (getpwnam "root") - #:common-name (format #f "Dovecot service on ~a" (gethostname))))))) + (with-imported-modules (source-module-closure '((gnu build activation))) + #~(begin + (use-modules (guix build utils) (gnu build activation)) + (define (build-subject parameters) + (string-concatenate + (map (lambda (pair) + (let ((k (car pair)) (v (cdr pair))) + (define (escape-char str chr) + (string-join (string-split str chr) (string #\\ chr))) + (string-append "/" k "=" + (escape-char (escape-char v #\=) #\/)))) + (filter (lambda (pair) (cdr pair)) parameters)))) + (define* (create-self-signed-certificate-if-absent + #:key private-key public-key (owner (getpwnam "root")) + (common-name (gethostname)) + (organization-name "Guix") + (organization-unit-name "Default Self-Signed Certificate") + (subject-parameters `(("CN" . ,common-name) + ("O" . ,organization-name) + ("OU" . ,organization-unit-name))) + (subject (build-subject subject-parameters))) + ;; Note that by default, OpenSSL outputs keys in PEM format. This + ;; is what we want. + (unless (file-exists? private-key) + (cond + ((zero? (system* (string-append #$openssl "/bin/openssl") + "genrsa" "-out" private-key "2048")) + (chown private-key (passwd:uid owner) (passwd:gid owner)) + (chmod private-key #o400)) + (else + (format (current-error-port) + "Failed to create private key at ~a.\n" private-key)))) + (unless (file-exists? public-key) + (cond + ((zero? (system* (string-append #$openssl "/bin/openssl") + "req" "-new" "-x509" "-key" private-key + "-out" public-key "-days" "3650" + "-batch" "-subj" subject)) + (chown public-key (passwd:uid owner) (passwd:gid owner)) + (chmod public-key #o444)) + (else + (format (current-error-port) + "Failed to create public key at ~a.\n" public-key))))) + (let ((user (getpwnam "dovecot"))) + (mkdir-p/perms "/var/run/dovecot" user #o755) + (mkdir-p/perms "/var/lib/dovecot" user #o755) + (mkdir-p/perms "/etc/dovecot" user #o755) + (copy-file #$(plain-file "dovecot.conf" config-str) + "/etc/dovecot/dovecot.conf") + (mkdir-p/perms "/etc/dovecot/private" user #o700) + (create-self-signed-certificate-if-absent + #:private-key "/etc/dovecot/private/default.pem" + #:public-key "/etc/dovecot/default.pem" + #:owner (getpwnam "root") + #:common-name (format #f "Dovecot service on ~a" (gethostname)))))))) (define (dovecot-shepherd-service config) "Return a list of for CONFIG." -- 2.38.0