Update dkimproxy-out service to use guix packages and guile config wrapper
modules/config/mail.scm
93 | 93 | accept for local alias <aliases> deliver to maildir | |
94 | 94 | ")) | |
95 | 95 | ||
96 | - | (define (dkimproxy-conf domain) | |
97 | - | (mixed-text-file "dkimproxy.out.conf" " | |
98 | - | # specify what address/port DKIMproxy should listen on | |
99 | - | listen 127.0.0.1:10027 | |
100 | - | # specify what address/port DKIMproxy forwards mail to | |
101 | - | relay 127.0.0.1:10028 | |
102 | - | # specify what domains DKIMproxy can sign for (comma-separated, no spaces) | |
103 | - | domain " domain " | |
104 | - | # specify what signatures to add | |
105 | - | signature dkim(c=relaxed) | |
106 | - | signature domainkeys(c=nofws) | |
107 | - | # specify location of the private key | |
108 | - | keyfile /etc/mail/dkim/private.key | |
109 | - | # specify the selector (i.e. the name of the key record put in DNS) | |
110 | - | selector dkim | |
111 | - | ")) | |
112 | - | ||
113 | 96 | (define (lepiller-imap-service domain) | |
114 | 97 | (service dovecot-service-type | |
115 | 98 | (dovecot-configuration | |
… | |||
127 | 110 | (define (lepiller-dkim-service domain) | |
128 | 111 | (service dkimproxy-out-service-type | |
129 | 112 | (dkimproxy-out-configuration | |
130 | - | (config-file (dkimproxy-conf domain))))) | |
113 | + | (listen "127.0.0.1:10027") | |
114 | + | (relay "127.0.0.1:10028") | |
115 | + | (sender-map | |
116 | + | `((,domain | |
117 | + | (,(dkimproxy-out-signature-configuration | |
118 | + | (type 'dkim) | |
119 | + | (key "/etc/mail/dkim/private.key") | |
120 | + | (method "relaxed") | |
121 | + | (selector "dkim")) | |
122 | + | ,(dkimproxy-out-signature-configuration | |
123 | + | (type 'domainkeys) | |
124 | + | (method "nofws"))))))))) | |
131 | 125 | ||
132 | 126 | (define* (lepiller-mail-services #:key interface domain) | |
133 | 127 | (list |
modules/packages/perl.scm unknown status 2
1 | - | ;;; GNU Guix --- Functional package management for GNU | |
2 | - | ;;; Copyright ?? 2019 Julien Lepiller <julien@lepiller.eu> | |
3 | - | ;;; | |
4 | - | ;;; This file is part of GNU Guix. | |
5 | - | ;;; | |
6 | - | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
7 | - | ;;; under the terms of the GNU General Public License as published by | |
8 | - | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
9 | - | ;;; your option) any later version. | |
10 | - | ;;; | |
11 | - | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
12 | - | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | - | ;;; GNU General Public License for more details. | |
15 | - | ;;; | |
16 | - | ;;; You should have received a copy of the GNU General Public License | |
17 | - | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
18 | - | ||
19 | - | (define-module (packages perl) | |
20 | - | #:use-module ((guix licenses) #:prefix license:) | |
21 | - | #:use-module (gnu packages) | |
22 | - | #:use-module (guix packages) | |
23 | - | #:use-module (guix download) | |
24 | - | #:use-module (guix utils) | |
25 | - | #:use-module (guix build-system gnu) | |
26 | - | #:use-module (guix build-system perl) | |
27 | - | #:use-module (gnu packages networking) | |
28 | - | #:use-module (gnu packages perl) | |
29 | - | #:use-module (gnu packages perl-check) | |
30 | - | #:use-module (gnu packages tls) | |
31 | - | #:use-module (gnu packages web)) | |
32 | - | ||
33 | - | (define-public perl-mail-authenticationresults | |
34 | - | (package | |
35 | - | (name "perl-mail-authenticationresults") | |
36 | - | (version "1.20180923") | |
37 | - | (source (origin | |
38 | - | (method url-fetch) | |
39 | - | (uri (string-append | |
40 | - | "mirror://cpan/authors/id/M/MB/MBRADSHAW/" | |
41 | - | "Mail-AuthenticationResults-" version ".tar.gz")) | |
42 | - | (sha256 | |
43 | - | (base32 | |
44 | - | "1g1wym9vcbhldwvi4w5pl0fhd4jh2icj975awf4wr5xmkli9mxbz")))) | |
45 | - | (build-system perl-build-system) | |
46 | - | (native-inputs | |
47 | - | `(("perl-test-exception" ,perl-test-exception))) | |
48 | - | (home-page "https://metacpan.org/release/Mail-AuthenticationResults") | |
49 | - | (synopsis "Object Oriented Authentication-Results Headers") | |
50 | - | (description "Mail::AuthenticationResults parses the message header field | |
51 | - | that indicates the message authentication status as per RFC7601. This module | |
52 | - | is not fully compliant with the RFC but it tries to implement most styles of | |
53 | - | Authentication-Results header seen in the wild.") | |
54 | - | (license license:perl-license))) | |
55 | - | ||
56 | - | (define-public perl-net-dns-resolver-mock | |
57 | - | (package | |
58 | - | (name "perl-net-dns-resolver-mock") | |
59 | - | (version "1.20171219") | |
60 | - | (source (origin | |
61 | - | (method url-fetch) | |
62 | - | (uri (string-append | |
63 | - | "mirror://cpan/authors/id/M/MB/MBRADSHAW/" | |
64 | - | "Net-DNS-Resolver-Mock-" version ".tar.gz")) | |
65 | - | (sha256 | |
66 | - | (base32 | |
67 | - | "0m3rxpkv1b9121srvbqkrgzg4m8mnydiydqv34in1i1ixwrl6jn9")))) | |
68 | - | (build-system perl-build-system) | |
69 | - | (propagated-inputs | |
70 | - | `(("perl-net-dns" ,perl-net-dns))) | |
71 | - | (home-page "https://metacpan.org/release/Net-DNS-Resolver-Mock") | |
72 | - | (synopsis "Mock a DNS Resolver object for testing") | |
73 | - | (description "Net::DNS::Resolver::Mock is a a subclass of | |
74 | - | @code{Net::DNS::Resolver} which parses a zonefile for it's data source. It is | |
75 | - | primarily for use in testing.") | |
76 | - | (license license:perl-license))) | |
77 | - | ||
78 | - | (define-public perl-mail-dkim | |
79 | - | (package | |
80 | - | (name "perl-mail-dkim") | |
81 | - | (version "0.55") | |
82 | - | (source (origin | |
83 | - | (method url-fetch) | |
84 | - | (uri (string-append | |
85 | - | "mirror://cpan/authors/id/M/MB/MBRADSHAW/Mail-DKIM-" | |
86 | - | version | |
87 | - | ".tar.gz")) | |
88 | - | (sha256 | |
89 | - | (base32 | |
90 | - | "18nsh1ff6fkns4xk3y2ixmzmadgggydj11qkzj6nlnq2hzqxsafz")))) | |
91 | - | (build-system perl-build-system) | |
92 | - | (propagated-inputs | |
93 | - | `(("perl-crypt-openssl-rsa" ,perl-crypt-openssl-rsa) | |
94 | - | ("perl-mail-authenticationresults" ,perl-mail-authenticationresults) | |
95 | - | ("perl-mailtools" ,perl-mailtools) | |
96 | - | ("perl-net-dns" ,perl-net-dns) | |
97 | - | ("perl-net-dns-resolver-mock" ,perl-net-dns-resolver-mock) | |
98 | - | ("perl-test-requiresinternet" ,perl-test-requiresinternet) | |
99 | - | ("perl-yaml-libyaml" ,perl-yaml-libyaml))) | |
100 | - | (home-page "https://metacpan.org/release/Mail-DKIM") | |
101 | - | (synopsis "Signs/verifies Internet mail with DKIM/DomainKey signatures") | |
102 | - | (description "Mail::DKIM is a Perl module that implements the new Domain | |
103 | - | Keys Identified Mail (DKIM) standard, and the older Yahoo! DomainKeys standard, | |
104 | - | both of which sign and verify emails using digital signatures and DNS records. | |
105 | - | Mail-DKIM can be used by any Perl program that wants to provide support for | |
106 | - | DKIM and/or DomainKeys.") | |
107 | - | (license license:gpl3+))) | |
108 | - | ||
109 | - | (define-public dkimproxy | |
110 | - | (package | |
111 | - | (name "dkimproxy") | |
112 | - | (version "1.4.1") | |
113 | - | (source (origin | |
114 | - | (method url-fetch) | |
115 | - | (uri (string-append | |
116 | - | "mirror://sourceforge/dkimproxy/dkimproxy/" | |
117 | - | version "/dkimproxy-" version ".tar.gz")) | |
118 | - | (sha256 | |
119 | - | (base32 | |
120 | - | "1gc5c7lg2qrlck7b0lvjfqr824ch6jkrzkpsn0gjvlzg7hfmld75")))) | |
121 | - | (build-system gnu-build-system) | |
122 | - | (arguments | |
123 | - | `(#:phases | |
124 | - | (modify-phases %standard-phases | |
125 | - | (add-after 'install 'make-wrapper | |
126 | - | (lambda* (#:key inputs outputs #:allow-other-keys) | |
127 | - | (let ((out (assoc-ref outputs "out"))) | |
128 | - | (for-each | |
129 | - | (lambda (prog) | |
130 | - | (wrap-program (string-append out "/bin/" prog) | |
131 | - | `("PERL5LIB" ":" prefix | |
132 | - | (,(string-append (assoc-ref inputs "perl-mail-dkim") | |
133 | - | "/lib/perl5/site_perl") | |
134 | - | ,(string-append (assoc-ref inputs "perl-mailtools") | |
135 | - | "/lib/perl5/site_perl") | |
136 | - | ,(string-append (assoc-ref inputs "perl-crypt-openssl-rsa") | |
137 | - | "/lib/perl5/site_perl") | |
138 | - | ,(string-append (assoc-ref inputs "perl-net-dns") | |
139 | - | "/lib/perl5/site_perl") | |
140 | - | ,(string-append (assoc-ref inputs "perl-net-server") | |
141 | - | "/lib/perl5/site_perl"))))) | |
142 | - | '("dkimproxy.in" "dkimproxy.out"))) | |
143 | - | #t))))) | |
144 | - | (inputs | |
145 | - | `(("perl" ,perl) | |
146 | - | ("perl-crypt-openssl-rsa" ,perl-crypt-openssl-rsa) | |
147 | - | ("perl-mailtools" ,perl-mailtools) | |
148 | - | ("perl-mail-dkim" ,perl-mail-dkim) | |
149 | - | ("perl-net-dns" ,perl-net-dns) | |
150 | - | ("perl-net-server" ,perl-net-server))) | |
151 | - | (home-page "http://dkimproxy.sourceforge.net/") | |
152 | - | (synopsis "SMTP-proxy for DKIM signing and verifying") | |
153 | - | (description "DKIMproxy is an SMTP-proxy that signs and/or verifies emails, | |
154 | - | using the @code{Mail::DKIM} module. It is designed for Postfix, but should | |
155 | - | work with any mail server. It comprises two separate proxies, an outbound | |
156 | - | proxy for signing outgoing email, and an inbound proxy for verifying signatures | |
157 | - | of incoming email. With Postfix, the proxies can operate as either | |
158 | - | @code{Before-Queue} or @code{After-Queue} content filters.") | |
159 | - | (license license:gpl3+))) |
modules/services/mail.scm
26 | 26 | #:use-module (gnu system pam) | |
27 | 27 | #:use-module (gnu system shadow) | |
28 | 28 | #:use-module (gnu packages admin) | |
29 | + | #:use-module (gnu packages mail) | |
29 | 30 | #:use-module (guix gexp) | |
30 | 31 | #:use-module (guix records) | |
31 | 32 | #:use-module (ice-9 match) | |
32 | - | #:use-module (packages perl) | |
33 | 33 | #:export (dkimproxy-out-service-type | |
34 | 34 | ||
35 | + | dkimproxy-out-signature-configuration | |
36 | + | dkimproxy-out-signature-configuration-type | |
37 | + | dkimproxy-out-signature-configuration-key | |
38 | + | dkimproxy-out-signature-configuration-algorithm | |
39 | + | dkimproxy-out-signature-configuration-method | |
40 | + | dkimproxy-out-signature-configuration-domain | |
41 | + | dkimproxy-out-signature-configuration-identity | |
42 | + | dkimproxy-out-signature-configuration-selector | |
43 | + | ||
35 | 44 | dkimproxy-out-configuration | |
36 | 45 | dkimproxy-out-configuration-package | |
46 | + | dkimproxy-out-configuration-listen | |
47 | + | dkimproxy-out-configuration-relay | |
48 | + | dkimproxy-out-configuration-list-id-map | |
49 | + | dkimproxy-out-configuration-sender-map | |
50 | + | dkimproxy-out-configuration-reject-error? | |
51 | + | ||
37 | 52 | dkimproxy-out-configuration-config-file)) | |
38 | 53 | ||
54 | + | (define-record-type* <dkimproxy-out-signature-configuration> | |
55 | + | dkimproxy-out-signature-configuration make-dkimproxy-out-signature-configuration | |
56 | + | dkimproxy-out-signature-configuration? | |
57 | + | (type dkimproxy-out-signature-configuration-type | |
58 | + | (default 'dkim)) | |
59 | + | (key dkimproxy-out-signature-configuration-key | |
60 | + | (default #f)) | |
61 | + | (algorithm dkimproxy-out-signature-configuration-algorithm | |
62 | + | (default #f)) | |
63 | + | (method dkimproxy-out-signature-configuration-method | |
64 | + | (default #f)) | |
65 | + | (domain dkimproxy-out-signature-configuration-domain | |
66 | + | (default #f)) | |
67 | + | (identity dkimproxy-out-signature-configuration-identity | |
68 | + | (default #f)) | |
69 | + | (selector dkimproxy-out-signature-configuration-selector | |
70 | + | (default #f))) | |
71 | + | ||
72 | + | (define generate-dkimproxy-out-signature-configuration | |
73 | + | (match-lambda | |
74 | + | (($ <dkimproxy-out-signature-configuration> | |
75 | + | type key algorithm method domain identity selector) | |
76 | + | (string-append | |
77 | + | (match type | |
78 | + | ('dkim "dkim") | |
79 | + | ('domainkeys "domainkeys")) | |
80 | + | (if (or key algorithm method domain identity selector) | |
81 | + | (string-append | |
82 | + | "(" | |
83 | + | (string-join | |
84 | + | `( | |
85 | + | ,@(if key | |
86 | + | (list (string-append "key=" key)) | |
87 | + | '()) | |
88 | + | ,@(if algorithm | |
89 | + | (list (string-append "a=" algorithm)) | |
90 | + | '()) | |
91 | + | ,@(if method | |
92 | + | (list (string-append "c=" method)) | |
93 | + | '()) | |
94 | + | ,@(if domain | |
95 | + | (list (string-append "d=" domain)) | |
96 | + | '()) | |
97 | + | ,@(if identity | |
98 | + | (list (string-append "i=" identity)) | |
99 | + | '()) | |
100 | + | ,@(if selector | |
101 | + | (list (string-append "s=" selector)) | |
102 | + | '())) | |
103 | + | ",") | |
104 | + | ")") | |
105 | + | ""))))) | |
106 | + | ||
39 | 107 | (define-record-type* <dkimproxy-out-configuration> | |
40 | 108 | dkimproxy-out-configuration make-dkimproxy-out-configuration | |
41 | 109 | dkimproxy-out-configuration? | |
42 | 110 | (package dkimproxy-out-configuration-package | |
43 | 111 | (default dkimproxy)) | |
112 | + | (listen dkimproxy-out-configuration-listen | |
113 | + | (default #f)) | |
114 | + | (relay dkimproxy-out-configuration-relay | |
115 | + | (default #f)) | |
116 | + | (list-id-map dkimproxy-out-configuration-list-id-map | |
117 | + | (default '())) | |
118 | + | (sender-map dkimproxy-out-configuration-sender-map | |
119 | + | (default '())) | |
120 | + | (reject-error? dkimproxy-out-configuration-sender-reject-error? | |
121 | + | (default #f)) | |
44 | 122 | (config-file dkimproxy-out-configuration-config-file | |
45 | - | (default %default-dkimproxy-out-configuration-config-file))) | |
123 | + | (default #f))) | |
46 | 124 | ||
47 | - | (define %default-dkimproxy-out-configuration-config-file | |
48 | - | (plain-file "dkimproxy_out.conf" " | |
49 | - | # specify what address/port DKIMproxy should listen on | |
50 | - | listen 127.0.0.1:10027 | |
51 | - | # specify what address/port DKIMproxy forwards mail to | |
52 | - | relay 127.0.0.1:10028 | |
53 | - | # specify what domains DKIMproxy can sign for (comma-separated, no spaces) | |
54 | - | domain mail.example.com | |
55 | - | # specify what signatures to add | |
56 | - | signature dkim(c=relaxed) | |
57 | - | signature domainkeys(c=nofws) | |
58 | - | # specify location of the private key | |
59 | - | # It can be generated with for instance: | |
60 | - | # mkdir /etc/mail/dkim | |
61 | - | # openssl genrsa -out /etc/mail/dkim/private.key 1024 | |
62 | - | # openssl rsa -in /etc/mail/dkim/private.key -pubout -out /etc/mail/dkim/public.key | |
63 | - | keyfile /etc/mail/dkim/private.key | |
64 | - | # specify the selector (i.e. the name of the key record put in DNS) | |
65 | - | selector selector1 | |
66 | - | ")) | |
125 | + | (define (generate-map-file config filename) | |
126 | + | (apply plain-file filename | |
127 | + | (map (lambda (config) | |
128 | + | (match config | |
129 | + | ((selector (config ...)) | |
130 | + | (string-append | |
131 | + | selector " " | |
132 | + | (string-join | |
133 | + | (map generate-dkimproxy-out-signature-configuration config) | |
134 | + | "\n"))) | |
135 | + | ((selector config) | |
136 | + | (string-append | |
137 | + | selector " " | |
138 | + | (generate-dkimproxy-out-signature-configuration config))))) | |
139 | + | config))) | |
67 | 140 | ||
68 | 141 | (define dkimproxy-out-shepherd-service | |
69 | 142 | (match-lambda | |
70 | - | (($ <dkimproxy-out-configuration> package config-file) | |
143 | + | (($ <dkimproxy-out-configuration> package listen relay list-id-map sender-map | |
144 | + | reject-error? config-file) | |
71 | 145 | (list (shepherd-service | |
72 | 146 | (provision '(dkimproxy-out)) | |
73 | 147 | (requirement '(loopback)) | |
74 | 148 | (documentation "Outbound DKIM proxy.") | |
75 | 149 | (start (let ((proxy (file-append package "/bin/dkimproxy.out"))) | |
76 | - | #~(make-forkexec-constructor | |
77 | - | (list #$proxy (string-append "--conf_file=" #$config-file) | |
78 | - | "--pidfile=/var/run/dkimproxy.out.pid" | |
79 | - | "--user=dkimproxy" "--group=dkimproxy") | |
80 | - | #:pid-file "/var/run/dkimproxy.out.pid"))) | |
150 | + | (if config-file | |
151 | + | #~(make-forkexec-constructor | |
152 | + | (list #$proxy (string-append "--conf_file=" #$config-file) | |
153 | + | "--pidfile=/var/run/dkimproxy.out.pid" | |
154 | + | "--user=dkimproxy" "--group=dkimproxy") | |
155 | + | #:pid-file "/var/run/dkimproxy.out.pid") | |
156 | + | (let* ((first-signature (match sender-map | |
157 | + | (((sender (signature _ ...)) _ ...) | |
158 | + | signature) | |
159 | + | (((sender signature) _ ...) | |
160 | + | signature))) | |
161 | + | (domains | |
162 | + | (apply append | |
163 | + | (map | |
164 | + | (lambda (sender) | |
165 | + | (match sender | |
166 | + | (((domains ...) config) | |
167 | + | domains) | |
168 | + | ((domain config) | |
169 | + | domain))) | |
170 | + | sender-map))) | |
171 | + | (sender-map (generate-map-file sender-map | |
172 | + | "sender.map")) | |
173 | + | (listid-map | |
174 | + | (if (null? list-id-map) | |
175 | + | #f | |
176 | + | (generate-map-file list-id-map "listid.map"))) | |
177 | + | (keyfile | |
178 | + | (dkimproxy-out-signature-configuration-key | |
179 | + | first-signature)) | |
180 | + | (selector | |
181 | + | (dkimproxy-out-signature-configuration-selector | |
182 | + | first-signature)) | |
183 | + | (method | |
184 | + | (dkimproxy-out-signature-configuration-method | |
185 | + | first-signature)) | |
186 | + | (signature | |
187 | + | (match (dkimproxy-out-signature-configuration-type | |
188 | + | first-signature) | |
189 | + | ('dkim "dkim") | |
190 | + | ('domainkeys "domainkeys")))) | |
191 | + | #~(make-forkexec-constructor | |
192 | + | `(,#$proxy "--pidfile=/var/run/dkimproxy.out.pid" | |
193 | + | "--user=dkimproxy" "--group=dkimproxy" | |
194 | + | ,(string-append "--listen=" #$listen) | |
195 | + | ,(string-append "--relay=" #$relay) | |
196 | + | ,(string-append "--sender_map=" #$sender-map) | |
197 | + | ,@(if #$listid-map | |
198 | + | (list | |
199 | + | (string-append "--listid_map=" #$listid-map)) | |
200 | + | '()) | |
201 | + | ,(string-append "--domain=" #$domains) | |
202 | + | ,(string-append "--keyfile=" #$keyfile) | |
203 | + | ,(string-append "--selector=" #$selector) | |
204 | + | ,@(if #$method | |
205 | + | (list | |
206 | + | (string-append "--method=" #$method)) | |
207 | + | '()) | |
208 | + | ,@(if #$reject-error? | |
209 | + | '("--reject_error") | |
210 | + | '()) | |
211 | + | ,@(if #$signature | |
212 | + | (list | |
213 | + | (string-append "--signature=" #$signature)) | |
214 | + | '()))))))) | |
81 | 215 | (stop #~(make-kill-destructor))))))) | |
82 | 216 | ||
83 | 217 | (define %dkimproxy-accounts |