From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id wJeiFPJmSmOSYgAAbAwnHQ (envelope-from ) for ; Sat, 15 Oct 2022 09:53:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id GC+4FPJmSmP0dQAA9RJhRA (envelope-from ) for ; Sat, 15 Oct 2022 09:53:22 +0200 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 958B01AD9B for ; Sat, 15 Oct 2022 09:53:21 +0200 (CEST) Received: from localhost ([::1]:41066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ojbyy-0005xt-Mc for larch@yhetil.org; Sat, 15 Oct 2022 03:53:20 -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:=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 Content-Type: multipart/mixed; boundary="MP_/xbs0kF_kZBS0i1WyWa69mq/" 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+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=1665820402; 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:resent-cc:resent-from:resent-sender: resent-message-id:list-id:list-help:list-unsubscribe:list-subscribe: list-post:dkim-signature; bh=3+se8rffyjWIoozC7DR+ZuWAL8KBdSFp00P4x2DzvNY=; b=AX1XdasOG3BW1wLCj3laN9nZ/yuuHmroN0/bf8mMXZ/CzQzIZyBI5Wd0Sh5vnQG+Ec4z/2 vm3KtR6QZyKIaINM1MAJtcRgrKmrMmqK07wqiLGEAyhpsl/d/XM1YMRMStyYEWuzjuKQBF ST7vc8jIQIhLonQWrupzncHhuigV8GhcyyAoq5P3LsAC0OC/oTSJnsKzTkU+EnYE8VvOFW xoO0VKrYwuCDqKkMB3yYXgmkzcZj/jG/wK6bx6GfcKPQNwsZkN0qM5S/AcwN5VeuSK7eky drpyf8YR4fGZpVTRJ109Pvl9SEajK0305RvreFtwhXWbyLXbV94heF4dBqHecA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665820402; a=rsa-sha256; cv=none; b=FHKAk1SEnGlqlmjuyMtIVrBel3bOS02wRG96zcIEhuNpoohJl6QOlIWnkkx6IrgmyOpIyn gF6vBYbAPNIfIY2SAE9NCPzRHWcTZRFD1pSZUrk8oAS/7ScatNXWu4Q5cdtEQ8sXWPaOih VrsUWC6AklOtbi0I7xtFeO/Hs8OTcsUHEFlBry9fnhI16TEFyKoDL4poYuLozmgZd9Ssr8 QmLWgkjeK/9smgRiGgeDhfAyly3yFDqVYWx94G6no3W2iT0pWJD7gS33Ot1tW5IUFp2mM+ 9zMKnn8Cck49lWsf9Qu5/dQMM9wQRL+jSGe6LIzXDWDs2c3C8CHR7lCjb/ROZw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=K6z3K5PD; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=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: 4.80 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=K6z3K5PD; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=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: 958B01AD9B X-Spam-Score: 4.80 X-Migadu-Scanner: scn0.migadu.com X-TUID: a0dazsUA+cy6 --MP_/xbs0kF_kZBS0i1WyWa69mq/ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 :) --MP_/xbs0kF_kZBS0i1WyWa69mq/ Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-gnu-dovecot-Use-standard-mkdir-p-perms.patch >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 --MP_/xbs0kF_kZBS0i1WyWa69mq/--