From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cCpkFfo6wmGAVQEAgWs5BA (envelope-from ) for ; Tue, 21 Dec 2021 21:37:14 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id GNTzEPo6wmGDcwAAB5/wlQ (envelope-from ) for ; Tue, 21 Dec 2021 20:37:14 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DC2F5E837 for ; Tue, 21 Dec 2021 21:37:13 +0100 (CET) Received: from localhost ([::1]:34052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzlsn-0007vk-3F for larch@yhetil.org; Tue, 21 Dec 2021 15:37:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzlsc-0007uZ-Jr for guix-patches@gnu.org; Tue, 21 Dec 2021 15:37:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44257) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzlsb-0003Up-Pk for guix-patches@gnu.org; Tue, 21 Dec 2021 15:37:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mzlsb-0002Rp-NL for guix-patches@gnu.org; Tue, 21 Dec 2021 15:37:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#49650] [PATCH v2] services: dovecot: Fix "/var/run/dovecot" owner. References: <20210719211943.23824-1-brice@waegenei.re> In-Reply-To: <20210719211943.23824-1-brice@waegenei.re> Resent-From: Brice Waegeneire Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 21 Dec 2021 20:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49650 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49650@debbugs.gnu.org Received: via spool by 49650-submit@debbugs.gnu.org id=B49650.16401189769351 (code B ref 49650); Tue, 21 Dec 2021 20:37:01 +0000 Received: (at 49650) by debbugs.gnu.org; 21 Dec 2021 20:36:16 +0000 Received: from localhost ([127.0.0.1]:55803 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzlrr-0002Ql-Hv for submit@debbugs.gnu.org; Tue, 21 Dec 2021 15:36:16 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:35795) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzlrp-0002QS-10 for 49650@debbugs.gnu.org; Tue, 21 Dec 2021 15:36:14 -0500 Received: (Authenticated sender: brice@waegenei.re) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 1E57AE0005 for <49650@debbugs.gnu.org>; Tue, 21 Dec 2021 20:36:05 +0000 (UTC) From: Brice Waegeneire Date: Tue, 21 Dec 2021 21:36:03 +0100 Message-Id: <20211221203603.7326-1-brice@waegenei.re> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640119033; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=/J8wphiDvrhsbCOhKD0KDXWI2JMWhegwMfhTv8zWkt4=; b=XzJlGTwlx2nHGLMx8M1n+Z4HLMmn9RXiWpzUwxi4a9hCeM7PdtuODufD2LNOQrnOmhWj8r bTBIklM4lOzQxp63422H11w2MKyYSuRC2vT4lGCmtTque9D3cQnA2Rayujk7oYnKdPdSfD VPXokj7jFA1p3MCMNBVNvKouXwfPdkccc33EF2lbRzVQ5nJPIUJ08eR/RcL5iOI+5eTq6r 7Q1ArHDomcX3phypwC6HkD2oR2HHo3Fn4wh0cWcsZy6ZVuiPF/XqvPoIjTy4nTzR7rg6R0 517VMko28w5Ugv7Hd6XijSWYh7hwZFJuLcjK6PB3ieZavcQYrWrSiICkQDFp7g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640119033; a=rsa-sha256; cv=none; b=glEmM7+3uyt3b56YYL1CwYfbjEf5utlb29acn1P8znjDKQIVbD/pltS8zw/9tglS9jFBSP yCBpRPuYYtF862weGnuadzQIbfvTxIiTlSqgghs36ed+UdPUAZJgXMrV3stwQLNGKrbKlC AjI6KiTYWPF/HlFbEMaciXZrr3Oy5Nux6pem84CgCwQwzsnXmB3gXicWHusbBEdyRJc7lT QJE5rn0hqw7eUidlZpqKymaYA5rliiQSjkyBLcLb96OlUv2tgfUjMyORNrXLsdviZKD4I4 KlZTRhr0TJS/pBZUoBBba4q3ujIQBTW7438FXxMNY3hYc+h/Gr37kyVAKBTfgA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.93 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: DC2F5E837 X-Spam-Score: -2.93 X-Migadu-Scanner: scn0.migadu.com X-TUID: bSxV1F0bwGFl * gnu/services/mail.scm (%dovecot-activation)[mkdir-p/perms]: Use procedure defined in (gnu build activation), fixing the 'chown' call which was using the static string "/var/run/dovecot". --- This version replace the faulty mkdir-p/perms procedure with a correct and more widely used one. It pass the system check: --8<---------------cut here---------------start------------->8--- $ make check-system TESTS="dovecot" -j4 [...] %%%% Starting test dovecot (Writing full log to "/gnu/store/q8iyyvzk954vfc1ihwzvd0ma6f2vxjf7-dovecot-test/dovecot.log") marionette is ready PASS: dovecot running PASS: service process id PASS: accept an email PASS: mail arrived # of expected passes 4 successfully built /gnu/store/2i0jkcpirr5v5wr9bvmgvphc7lh3zwir-dovecot-test.drv /gnu/store/q8iyyvzk954vfc1ihwzvd0ma6f2vxjf7-dovecot-test --8<---------------cut here---------------end--------------->8--- gnu/services/mail.scm | 117 +++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm index 4ad6ddb534..f376c67284 100644 --- a/gnu/services/mail.scm +++ b/gnu/services/mail.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2017, 2020 Tobias Geerinckx-Rice ;;; Copyright © 2019 Kristofer Buffington ;;; Copyright © 2020 Jonathan Brielmaier +;;; Copyright © 2021 Brice Waegeneire ;;; ;;; This file is part of GNU Guix. ;;; @@ -35,6 +36,7 @@ (define-module (gnu services mail) #:use-module (gnu packages dav) #:use-module (gnu packages tls) #:use-module (guix records) + #:use-module (guix modules) #:use-module (guix packages) #:use-module (guix gexp) #:use-module (ice-9 match) @@ -1511,64 +1513,63 @@ (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." base-commit: 87e5502d406bfb44b61f7577b241602e02a3498e -- 2.34.0