Commit | Line | Data |
---|---|---|
d8c18af8 AW |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2015 Andy Wingo <wingo@igalia.com> | |
8d9bb4b4 | 3 | ;;; Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org> |
82ccc499 | 4 | ;;; Copyright © 2017 Carlo Zancanaro <carlo@zancanaro.id.au> |
28c03b45 | 5 | ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr> |
d8c18af8 AW |
6 | ;;; |
7 | ;;; This file is part of GNU Guix. | |
8 | ;;; | |
9 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
10 | ;;; under the terms of the GNU General Public License as published by | |
11 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
12 | ;;; your option) any later version. | |
13 | ;;; | |
14 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
15 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | ;;; GNU General Public License for more details. | |
18 | ;;; | |
19 | ;;; You should have received a copy of the GNU General Public License | |
20 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
21 | ;;; | |
22 | ;;; Some of the help text was taken from the default dovecot.conf files. | |
23 | ||
24 | (define-module (gnu services mail) | |
25 | #:use-module (gnu services) | |
26 | #:use-module (gnu services base) | |
5305ed20 | 27 | #:use-module (gnu services configuration) |
0190c1c0 | 28 | #:use-module (gnu services shepherd) |
d8c18af8 AW |
29 | #:use-module (gnu system pam) |
30 | #:use-module (gnu system shadow) | |
31 | #:use-module (gnu packages mail) | |
32 | #:use-module (gnu packages admin) | |
33 | #:use-module (gnu packages tls) | |
34 | #:use-module (guix records) | |
35 | #:use-module (guix packages) | |
36 | #:use-module (guix gexp) | |
d8c18af8 | 37 | #:use-module (ice-9 match) |
82ccc499 | 38 | #:use-module (ice-9 format) |
8d17cf1c | 39 | #:use-module (srfi srfi-1) |
5305ed20 | 40 | #:export (dovecot-service |
24e96431 | 41 | dovecot-service-type |
d8c18af8 AW |
42 | dovecot-configuration |
43 | opaque-dovecot-configuration | |
44 | ||
45 | dict-configuration | |
46 | passdb-configuration | |
47 | userdb-configuration | |
48 | unix-listener-configuration | |
49 | fifo-listener-configuration | |
50 | inet-listener-configuration | |
51 | service-configuration | |
52 | protocol-configuration | |
53 | plugin-configuration | |
54 | mailbox-configuration | |
f88371e8 SB |
55 | namespace-configuration |
56 | ||
57 | opensmtpd-configuration | |
58 | opensmtpd-configuration? | |
59 | opensmtpd-service-type | |
82ccc499 CZ |
60 | %default-opensmtpd-config-file |
61 | ||
8d17cf1c CZ |
62 | mail-aliases-service-type |
63 | ||
82ccc499 CZ |
64 | exim-configuration |
65 | exim-configuration? | |
66 | exim-service-type | |
67 | %default-exim-config-file)) | |
d8c18af8 AW |
68 | |
69 | ;;; Commentary: | |
70 | ;;; | |
71 | ;;; This module provides service definitions for the Dovecot POP3 and IMAP | |
72 | ;;; mail server. | |
73 | ;;; | |
74 | ;;; Code: | |
75 | ||
56aef188 CL |
76 | (define (uglify-field-name field-name) |
77 | (let ((str (symbol->string field-name))) | |
78 | (string-join (string-split (if (string-suffix? "?" str) | |
79 | (substring str 0 (1- (string-length str))) | |
80 | str) | |
81 | #\-) | |
82 | "_"))) | |
83 | ||
84 | (define (serialize-field field-name val) | |
85 | (format #t "~a=~a\n" (uglify-field-name field-name) val)) | |
86 | ||
87 | (define (serialize-string field-name val) | |
88 | (serialize-field field-name val)) | |
89 | ||
90 | (define (space-separated-string-list? val) | |
91 | (and (list? val) | |
92 | (and-map (lambda (x) | |
93 | (and (string? x) (not (string-index x #\space)))) | |
94 | val))) | |
95 | (define (serialize-space-separated-string-list field-name val) | |
96 | (serialize-field field-name (string-join val " "))) | |
d8c18af8 AW |
97 | |
98 | (define (comma-separated-string-list? val) | |
99 | (and (list? val) | |
100 | (and-map (lambda (x) | |
101 | (and (string? x) (not (string-index x #\,)))) | |
102 | val))) | |
103 | (define (serialize-comma-separated-string-list field-name val) | |
104 | (serialize-field field-name (string-join val ","))) | |
105 | ||
56aef188 CL |
106 | (define (file-name? val) |
107 | (and (string? val) | |
108 | (string-prefix? "/" val))) | |
109 | (define (serialize-file-name field-name val) | |
110 | (serialize-string field-name val)) | |
111 | ||
d8c18af8 AW |
112 | (define (colon-separated-file-name-list? val) |
113 | (and (list? val) | |
114 | ;; Trailing slashes not needed and not | |
115 | (and-map file-name? val))) | |
116 | (define (serialize-colon-separated-file-name-list field-name val) | |
117 | (serialize-field field-name (string-join val ":"))) | |
118 | ||
56aef188 CL |
119 | (define (serialize-boolean field-name val) |
120 | (serialize-string field-name (if val "yes" "no"))) | |
121 | ||
d8c18af8 AW |
122 | (define (non-negative-integer? val) |
123 | (and (exact-integer? val) (not (negative? val)))) | |
124 | (define (serialize-non-negative-integer field-name val) | |
125 | (serialize-field field-name val)) | |
126 | ||
127 | (define (hours? val) (non-negative-integer? val)) | |
128 | (define (serialize-hours field-name val) | |
129 | (serialize-field field-name (format #f "~a hours" val))) | |
130 | ||
131 | (define (free-form-fields? val) | |
132 | (match val | |
133 | (() #t) | |
134 | ((((? symbol?) . (? string)) . val) (free-form-fields? val)) | |
135 | (_ #f))) | |
136 | (define (serialize-free-form-fields field-name val) | |
137 | (for-each (match-lambda ((k . v) (serialize-field k v))) val)) | |
138 | ||
139 | (define (free-form-args? val) | |
140 | (match val | |
141 | (() #t) | |
142 | ((((? symbol?) . (? string)) . val) (free-form-args? val)) | |
143 | (_ #f))) | |
144 | (define (serialize-free-form-args field-name val) | |
145 | (serialize-field field-name | |
146 | (string-join | |
147 | (map (match-lambda ((k . v) (format #t "~a=~a" k v))) val) | |
148 | " "))) | |
149 | ||
150 | (define-configuration dict-configuration | |
151 | (entries | |
152 | (free-form-fields '()) | |
153 | "A list of key-value pairs that this dict should hold.")) | |
154 | ||
155 | (define (serialize-dict-configuration field-name val) | |
156 | (format #t "dict {\n") | |
157 | (serialize-configuration val dict-configuration-fields) | |
158 | (format #t "}\n")) | |
159 | ||
160 | (define-configuration passdb-configuration | |
161 | (driver | |
162 | (string "pam") | |
163 | "The driver that the passdb should use. Valid values include | |
164 | @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and | |
165 | @samp{static}.") | |
166 | (args | |
deb36188 CL |
167 | (space-separated-string-list '()) |
168 | "Space separated list of arguments to the passdb driver.")) | |
d8c18af8 AW |
169 | |
170 | (define (serialize-passdb-configuration field-name val) | |
171 | (format #t "passdb {\n") | |
172 | (serialize-configuration val passdb-configuration-fields) | |
173 | (format #t "}\n")) | |
174 | (define (passdb-configuration-list? val) | |
175 | (and (list? val) (and-map passdb-configuration? val))) | |
176 | (define (serialize-passdb-configuration-list field-name val) | |
177 | (for-each (lambda (val) (serialize-passdb-configuration field-name val)) val)) | |
178 | ||
179 | (define-configuration userdb-configuration | |
180 | (driver | |
181 | (string "passwd") | |
182 | "The driver that the userdb should use. Valid values include | |
183 | @samp{passwd} and @samp{static}.") | |
184 | (args | |
deb36188 CL |
185 | (space-separated-string-list '()) |
186 | "Space separated list of arguments to the userdb driver.") | |
d8c18af8 AW |
187 | (override-fields |
188 | (free-form-args '()) | |
189 | "Override fields from passwd.")) | |
190 | ||
191 | (define (serialize-userdb-configuration field-name val) | |
192 | (format #t "userdb {\n") | |
193 | (serialize-configuration val userdb-configuration-fields) | |
194 | (format #t "}\n")) | |
195 | (define (userdb-configuration-list? val) | |
196 | (and (list? val) (and-map userdb-configuration? val))) | |
197 | (define (serialize-userdb-configuration-list field-name val) | |
198 | (for-each (lambda (val) (serialize-userdb-configuration field-name val)) val)) | |
199 | ||
200 | (define-configuration unix-listener-configuration | |
201 | (path | |
eba56076 CL |
202 | (string (configuration-missing-field 'unix-listener 'path)) |
203 | "Path to the file, relative to @code{base-dir} field. This is also used as | |
204 | the section name.") | |
d8c18af8 AW |
205 | (mode |
206 | (string "0600") | |
207 | "The access mode for the socket.") | |
208 | (user | |
209 | (string "") | |
210 | "The user to own the the socket.") | |
211 | (group | |
212 | (string "") | |
213 | "The group to own the socket.")) | |
214 | ||
215 | (define (serialize-unix-listener-configuration field-name val) | |
216 | (format #t "unix_listener ~a {\n" (unix-listener-configuration-path val)) | |
217 | (serialize-configuration val (cdr unix-listener-configuration-fields)) | |
218 | (format #t "}\n")) | |
219 | ||
220 | (define-configuration fifo-listener-configuration | |
221 | (path | |
eba56076 CL |
222 | (string (configuration-missing-field 'fifo-listener 'path)) |
223 | "Path to the file, relative to @code{base-dir} field. This is also used as | |
224 | the section name.") | |
d8c18af8 AW |
225 | (mode |
226 | (string "0600") | |
227 | "The access mode for the socket.") | |
228 | (user | |
229 | (string "") | |
230 | "The user to own the the socket.") | |
231 | (group | |
232 | (string "") | |
233 | "The group to own the socket.")) | |
234 | ||
235 | (define (serialize-fifo-listener-configuration field-name val) | |
236 | (format #t "fifo_listener ~a {\n" (fifo-listener-configuration-path val)) | |
237 | (serialize-configuration val (cdr fifo-listener-configuration-fields)) | |
238 | (format #t "}\n")) | |
239 | ||
240 | (define-configuration inet-listener-configuration | |
241 | (protocol | |
5305ed20 | 242 | (string (configuration-missing-field 'inet-listener 'protocol)) |
d8c18af8 AW |
243 | "The protocol to listen for.") |
244 | (address | |
245 | (string "") | |
246 | "The address on which to listen, or empty for all addresses.") | |
247 | (port | |
248 | (non-negative-integer | |
5305ed20 | 249 | (configuration-missing-field 'inet-listener 'port)) |
d8c18af8 AW |
250 | "The port on which to listen.") |
251 | (ssl? | |
252 | (boolean #t) | |
253 | "Whether to use SSL for this service; @samp{yes}, @samp{no}, or | |
254 | @samp{required}.")) | |
255 | ||
256 | (define (serialize-inet-listener-configuration field-name val) | |
257 | (format #t "inet_listener ~a {\n" (inet-listener-configuration-protocol val)) | |
258 | (serialize-configuration val (cdr inet-listener-configuration-fields)) | |
259 | (format #t "}\n")) | |
260 | ||
261 | (define (listener-configuration? val) | |
262 | (or (unix-listener-configuration? val) | |
263 | (fifo-listener-configuration? val) | |
264 | (inet-listener-configuration? val))) | |
265 | (define (serialize-listener-configuration field-name val) | |
266 | (cond | |
267 | ((unix-listener-configuration? val) | |
268 | (serialize-unix-listener-configuration field-name val)) | |
269 | ((fifo-listener-configuration? val) | |
270 | (serialize-fifo-listener-configuration field-name val)) | |
271 | ((inet-listener-configuration? val) | |
272 | (serialize-inet-listener-configuration field-name val)) | |
5305ed20 | 273 | (else (configuration-field-error field-name val)))) |
d8c18af8 AW |
274 | (define (listener-configuration-list? val) |
275 | (and (list? val) (and-map listener-configuration? val))) | |
276 | (define (serialize-listener-configuration-list field-name val) | |
277 | (for-each (lambda (val) | |
278 | (serialize-listener-configuration field-name val)) | |
279 | val)) | |
280 | ||
281 | (define-configuration service-configuration | |
282 | (kind | |
5305ed20 | 283 | (string (configuration-missing-field 'service 'kind)) |
d8c18af8 AW |
284 | "The service kind. Valid values include @code{director}, |
285 | @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap}, | |
286 | @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict}, | |
287 | @code{tcpwrap}, @code{quota-warning}, or anything else.") | |
288 | (listeners | |
289 | (listener-configuration-list '()) | |
290 | "Listeners for the service. A listener is either an | |
291 | @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or | |
292 | an @code{inet-listener-configuration}.") | |
8d9bb4b4 CL |
293 | (client-limit |
294 | (non-negative-integer 0) | |
295 | "Maximum number of simultaneous client connections per process. Once this | |
296 | number of connections is received, the next incoming connection will prompt | |
297 | Dovecot to spawn another process. If set to 0, @code{default-client-limit} is | |
298 | used instead.") | |
d8c18af8 AW |
299 | (service-count |
300 | (non-negative-integer 1) | |
301 | "Number of connections to handle before starting a new process. | |
302 | Typically the only useful values are 0 (unlimited) or 1. 1 is more | |
303 | secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.") | |
be8dd4a5 CL |
304 | (process-limit |
305 | (non-negative-integer 0) | |
306 | "Maximum number of processes that can exist for this service. If set to 0, | |
307 | @code{default-process-limit} is used instead.") | |
d8c18af8 AW |
308 | (process-min-avail |
309 | (non-negative-integer 0) | |
310 | "Number of processes to always keep waiting for more connections.") | |
311 | ;; FIXME: Need to be able to take the default for this value from other | |
312 | ;; parts of the config. | |
313 | (vsz-limit | |
314 | (non-negative-integer #e256e6) | |
315 | "If you set @samp{service-count 0}, you probably need to grow | |
316 | this.")) | |
317 | ||
318 | (define (serialize-service-configuration field-name val) | |
319 | (format #t "service ~a {\n" (service-configuration-kind val)) | |
320 | (serialize-configuration val (cdr service-configuration-fields)) | |
321 | (format #t "}\n")) | |
322 | (define (service-configuration-list? val) | |
323 | (and (list? val) (and-map service-configuration? val))) | |
324 | (define (serialize-service-configuration-list field-name val) | |
325 | (for-each (lambda (val) | |
326 | (serialize-service-configuration field-name val)) | |
327 | val)) | |
328 | ||
329 | (define-configuration protocol-configuration | |
330 | (name | |
5305ed20 | 331 | (string (configuration-missing-field 'protocol 'name)) |
d8c18af8 AW |
332 | "The name of the protocol.") |
333 | (auth-socket-path | |
334 | (string "/var/run/dovecot/auth-userdb") | |
335 | "UNIX socket path to master authentication server to find users. | |
336 | This is used by imap (for shared users) and lda.") | |
337 | (mail-plugins | |
338 | (space-separated-string-list '("$mail_plugins")) | |
339 | "Space separated list of plugins to load.") | |
340 | (mail-max-userip-connections | |
341 | (non-negative-integer 10) | |
342 | "Maximum number of IMAP connections allowed for a user from each IP | |
343 | address. NOTE: The username is compared case-sensitively.")) | |
344 | ||
345 | (define (serialize-protocol-configuration field-name val) | |
346 | (format #t "protocol ~a {\n" (protocol-configuration-name val)) | |
347 | (serialize-configuration val (cdr protocol-configuration-fields)) | |
348 | (format #t "}\n")) | |
349 | (define (protocol-configuration-list? val) | |
350 | (and (list? val) (and-map protocol-configuration? val))) | |
351 | (define (serialize-protocol-configuration-list field-name val) | |
352 | (serialize-field 'protocols | |
353 | (string-join (map protocol-configuration-name val) " ")) | |
354 | (for-each (lambda (val) | |
355 | (serialize-protocol-configuration field-name val)) | |
356 | val)) | |
357 | ||
358 | (define-configuration plugin-configuration | |
359 | (entries | |
360 | (free-form-fields '()) | |
361 | "A list of key-value pairs that this dict should hold.")) | |
362 | ||
363 | (define (serialize-plugin-configuration field-name val) | |
364 | (format #t "plugin {\n") | |
365 | (serialize-configuration val plugin-configuration-fields) | |
366 | (format #t "}\n")) | |
367 | ||
368 | (define-configuration mailbox-configuration | |
369 | (name | |
370 | (string (error "mailbox name is required")) | |
371 | "Name for this mailbox.") | |
372 | ||
373 | (auto | |
374 | (string "no") | |
375 | "@samp{create} will automatically create this mailbox. | |
376 | @samp{subscribe} will both create and subscribe to the mailbox.") | |
377 | ||
378 | (special-use | |
379 | (space-separated-string-list '()) | |
380 | "List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154. | |
381 | Valid values are @code{\\All}, @code{\\Archive}, @code{\\Drafts}, | |
382 | @code{\\Flagged}, @code{\\Junk}, @code{\\Sent}, and @code{\\Trash}.")) | |
383 | ||
384 | (define (serialize-mailbox-configuration field-name val) | |
385 | (format #t "mailbox \"~a\" {\n" (mailbox-configuration-name val)) | |
386 | (serialize-configuration val (cdr mailbox-configuration-fields)) | |
387 | (format #t "}\n")) | |
388 | (define (mailbox-configuration-list? val) | |
389 | (and (list? val) (and-map mailbox-configuration? val))) | |
390 | (define (serialize-mailbox-configuration-list field-name val) | |
391 | (for-each (lambda (val) | |
392 | (serialize-mailbox-configuration field-name val)) | |
393 | val)) | |
394 | ||
395 | (define-configuration namespace-configuration | |
396 | (name | |
397 | (string (error "namespace name is required")) | |
398 | "Name for this namespace.") | |
399 | ||
400 | (type | |
401 | (string "private") | |
402 | "Namespace type: @samp{private}, @samp{shared} or @samp{public}.") | |
403 | ||
404 | (separator | |
405 | (string "") | |
406 | "Hierarchy separator to use. You should use the same separator for | |
407 | all namespaces or some clients get confused. @samp{/} is usually a good | |
408 | one. The default however depends on the underlying mail storage | |
409 | format.") | |
410 | ||
411 | (prefix | |
412 | (string "") | |
413 | "Prefix required to access this namespace. This needs to be | |
414 | different for all namespaces. For example @samp{Public/}.") | |
415 | ||
416 | (location | |
417 | (string "") | |
418 | "Physical location of the mailbox. This is in same format as | |
419 | mail_location, which is also the default for it.") | |
420 | ||
421 | (inbox? | |
422 | (boolean #f) | |
423 | "There can be only one INBOX, and this setting defines which | |
424 | namespace has it.") | |
425 | ||
426 | (hidden? | |
427 | (boolean #f) | |
428 | "If namespace is hidden, it's not advertised to clients via NAMESPACE | |
429 | extension. You'll most likely also want to set @samp{list? #f}. This is mostly | |
430 | useful when converting from another server with different namespaces | |
431 | which you want to deprecate but still keep working. For example you can | |
432 | create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/} | |
433 | and @samp{mail/}.") | |
434 | ||
435 | (list? | |
436 | (boolean #t) | |
437 | "Show the mailboxes under this namespace with LIST command. This | |
438 | makes the namespace visible for clients that don't support NAMESPACE | |
439 | extension. The special @code{children} value lists child mailboxes, but | |
440 | hides the namespace prefix.") | |
441 | ||
442 | (subscriptions? | |
443 | (boolean #t) | |
444 | "Namespace handles its own subscriptions. If set to @code{#f}, the | |
445 | parent namespace handles them. The empty prefix should always have this | |
446 | as @code{#t}.)") | |
447 | ||
448 | (mailboxes | |
449 | (mailbox-configuration-list '()) | |
450 | "List of predefined mailboxes in this namespace.")) | |
451 | ||
452 | (define (serialize-namespace-configuration field-name val) | |
453 | (format #t "namespace ~a {\n" (namespace-configuration-name val)) | |
454 | (serialize-configuration val (cdr namespace-configuration-fields)) | |
455 | (format #t "}\n")) | |
456 | (define (list-of-namespace-configuration? val) | |
457 | (and (list? val) (and-map namespace-configuration? val))) | |
458 | (define (serialize-list-of-namespace-configuration field-name val) | |
459 | (for-each (lambda (val) | |
460 | (serialize-namespace-configuration field-name val)) | |
461 | val)) | |
462 | ||
463 | (define-configuration dovecot-configuration | |
464 | (dovecot | |
465 | (package dovecot) | |
466 | "The dovecot package.") | |
467 | ||
468 | (listen | |
469 | (comma-separated-string-list '("*" "::")) | |
470 | "A list of IPs or hosts where to listen in for connections. @samp{*} | |
471 | listens in all IPv4 interfaces, @samp{::} listens in all IPv6 | |
472 | interfaces. If you want to specify non-default ports or anything more | |
473 | complex, customize the address and port fields of the | |
474 | @samp{inet-listener} of the specific services you are interested in.") | |
475 | ||
476 | (protocols | |
477 | (protocol-configuration-list | |
478 | (list (protocol-configuration | |
479 | (name "imap")))) | |
480 | "List of protocols we want to serve. Available protocols include | |
481 | @samp{imap}, @samp{pop3}, and @samp{lmtp}.") | |
482 | ||
483 | (services | |
484 | (service-configuration-list | |
485 | (list | |
486 | (service-configuration | |
487 | (kind "imap-login") | |
8d9bb4b4 | 488 | (client-limit 0) |
be8dd4a5 | 489 | (process-limit 0) |
d8c18af8 AW |
490 | (listeners |
491 | (list | |
492 | (inet-listener-configuration (protocol "imap") (port 143) (ssl? #f)) | |
493 | (inet-listener-configuration (protocol "imaps") (port 993) (ssl? #t))))) | |
494 | (service-configuration | |
495 | (kind "pop3-login") | |
496 | (listeners | |
497 | (list | |
498 | (inet-listener-configuration (protocol "pop3") (port 110) (ssl? #f)) | |
499 | (inet-listener-configuration (protocol "pop3s") (port 995) (ssl? #t))))) | |
500 | (service-configuration | |
501 | (kind "lmtp") | |
8d9bb4b4 | 502 | (client-limit 1) |
be8dd4a5 | 503 | (process-limit 0) |
d8c18af8 AW |
504 | (listeners |
505 | (list (unix-listener-configuration (path "lmtp") (mode "0666"))))) | |
8d9bb4b4 CL |
506 | (service-configuration |
507 | (kind "imap") | |
be8dd4a5 CL |
508 | (client-limit 1) |
509 | (process-limit 1024)) | |
8d9bb4b4 CL |
510 | (service-configuration |
511 | (kind "pop3") | |
be8dd4a5 CL |
512 | (client-limit 1) |
513 | (process-limit 1024)) | |
a7553a73 CL |
514 | (service-configuration |
515 | (kind "auth") | |
516 | (service-count 0) | |
8d9bb4b4 | 517 | (client-limit 0) |
be8dd4a5 | 518 | (process-limit 1) |
d8c18af8 AW |
519 | (listeners |
520 | (list (unix-listener-configuration (path "auth-userdb"))))) | |
8d9bb4b4 CL |
521 | (service-configuration |
522 | (kind "auth-worker") | |
be8dd4a5 CL |
523 | (client-limit 1) |
524 | (process-limit 0)) | |
8d9bb4b4 CL |
525 | (service-configuration |
526 | (kind "dict") | |
527 | (client-limit 1) | |
be8dd4a5 | 528 | (process-limit 0) |
d8c18af8 AW |
529 | (listeners (list (unix-listener-configuration (path "dict"))))))) |
530 | "List of services to enable. Available services include @samp{imap}, | |
531 | @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and | |
532 | @samp{lmtp}.") | |
533 | ||
534 | (dict | |
535 | (dict-configuration (dict-configuration)) | |
536 | "Dict configuration, as created by the @code{dict-configuration} | |
537 | constructor.") | |
538 | ||
539 | (passdbs | |
540 | (passdb-configuration-list (list (passdb-configuration (driver "pam")))) | |
541 | "List of passdb configurations, each one created by the | |
542 | @code{passdb-configuration} constructor.") | |
543 | ||
544 | (userdbs | |
545 | (userdb-configuration-list (list (userdb-configuration (driver "passwd")))) | |
546 | "List of userdb configurations, each one created by the | |
547 | @code{userdb-configuration} constructor.") | |
548 | ||
549 | (plugin-configuration | |
550 | (plugin-configuration (plugin-configuration)) | |
551 | "Plug-in configuration, created by the @code{plugin-configuration} | |
552 | constructor.") | |
553 | ||
554 | (namespaces | |
555 | (list-of-namespace-configuration | |
556 | (list | |
557 | (namespace-configuration | |
558 | (name "inbox") | |
559 | (prefix "") | |
560 | (inbox? #t) | |
561 | (mailboxes | |
562 | (list | |
563 | (mailbox-configuration (name "Drafts") (special-use '("\\Drafts"))) | |
564 | (mailbox-configuration (name "Junk") (special-use '("\\Junk"))) | |
565 | (mailbox-configuration (name "Trash") (special-use '("\\Trash"))) | |
566 | (mailbox-configuration (name "Sent") (special-use '("\\Sent"))) | |
567 | (mailbox-configuration (name "Sent Messages") (special-use '("\\Sent"))) | |
568 | (mailbox-configuration (name "Drafts") (special-use '("\\Drafts")))))))) | |
569 | "List of namespaces. Each item in the list is created by the | |
570 | @code{namespace-configuration} constructor.") | |
571 | ||
572 | (base-dir | |
573 | (file-name "/var/run/dovecot/") | |
574 | "Base directory where to store runtime data.") | |
575 | ||
576 | (login-greeting | |
577 | (string "Dovecot ready.") | |
578 | "Greeting message for clients.") | |
579 | ||
580 | (login-trusted-networks | |
581 | (space-separated-string-list '()) | |
582 | "List of trusted network ranges. Connections from these IPs are | |
583 | allowed to override their IP addresses and ports (for logging and for | |
584 | authentication checks). @samp{disable-plaintext-auth} is also ignored | |
585 | for these networks. Typically you'd specify your IMAP proxy servers | |
586 | here.") | |
587 | ||
588 | (login-access-sockets | |
589 | (space-separated-string-list '()) | |
590 | "List of login access check sockets (e.g. tcpwrap).") | |
591 | ||
592 | (verbose-proctitle? | |
593 | (boolean #f) | |
594 | "Show more verbose process titles (in ps). Currently shows user name | |
595 | and IP address. Useful for seeing who are actually using the IMAP | |
596 | processes (e.g. shared mailboxes or if same uid is used for multiple | |
597 | accounts).") | |
598 | ||
599 | (shutdown-clients? | |
600 | (boolean #t) | |
601 | "Should all processes be killed when Dovecot master process shuts down. | |
602 | Setting this to @code{#f} means that Dovecot can be upgraded without | |
603 | forcing existing client connections to close (although that could also | |
604 | be a problem if the upgrade is e.g. because of a security fix).") | |
605 | ||
606 | (doveadm-worker-count | |
607 | (non-negative-integer 0) | |
608 | "If non-zero, run mail commands via this many connections to doveadm | |
609 | server, instead of running them directly in the same process.") | |
610 | ||
611 | (doveadm-socket-path | |
612 | (string "doveadm-server") | |
613 | "UNIX socket or host:port used for connecting to doveadm server.") | |
614 | ||
615 | (import-environment | |
616 | (space-separated-string-list '("TZ")) | |
617 | "List of environment variables that are preserved on Dovecot startup | |
618 | and passed down to all of its child processes. You can also give | |
619 | key=value pairs to always set specific settings.") | |
620 | ||
621 | ;;; Authentication processes | |
622 | ||
623 | (disable-plaintext-auth? | |
624 | (boolean #t) | |
625 | "Disable LOGIN command and all other plaintext authentications unless | |
626 | SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP | |
627 | matches the local IP (i.e. you're connecting from the same computer), | |
628 | the connection is considered secure and plaintext authentication is | |
629 | allowed. See also ssl=required setting.") | |
630 | ||
631 | (auth-cache-size | |
632 | (non-negative-integer 0) | |
633 | "Authentication cache size (e.g. @samp{#e10e6}). 0 means it's disabled. | |
634 | Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set | |
635 | for caching to be used.") | |
636 | ||
637 | (auth-cache-ttl | |
638 | (string "1 hour") | |
639 | "Time to live for cached data. After TTL expires the cached record | |
640 | is no longer used, *except* if the main database lookup returns internal | |
641 | failure. We also try to handle password changes automatically: If | |
642 | user's previous authentication was successful, but this one wasn't, the | |
643 | cache isn't used. For now this works only with plaintext | |
644 | authentication.") | |
645 | ||
646 | (auth-cache-negative-ttl | |
647 | (string "1 hour") | |
648 | "TTL for negative hits (user not found, password mismatch). | |
649 | 0 disables caching them completely.") | |
650 | ||
651 | (auth-realms | |
652 | (space-separated-string-list '()) | |
653 | "List of realms for SASL authentication mechanisms that need them. | |
654 | You can leave it empty if you don't want to support multiple realms. | |
655 | Many clients simply use the first one listed here, so keep the default | |
656 | realm first.") | |
657 | ||
658 | (auth-default-realm | |
659 | (string "") | |
660 | "Default realm/domain to use if none was specified. This is used for | |
661 | both SASL realms and appending @@domain to username in plaintext | |
662 | logins.") | |
663 | ||
664 | (auth-username-chars | |
665 | (string | |
666 | "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@") | |
667 | "List of allowed characters in username. If the user-given username | |
668 | contains a character not listed in here, the login automatically fails. | |
669 | This is just an extra check to make sure user can't exploit any | |
670 | potential quote escaping vulnerabilities with SQL/LDAP databases. If | |
671 | you want to allow all characters, set this value to empty.") | |
672 | ||
673 | (auth-username-translation | |
674 | (string "") | |
675 | "Username character translations before it's looked up from | |
676 | databases. The value contains series of from -> to characters. For | |
677 | example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are | |
678 | translated to @samp{@@}.") | |
679 | ||
680 | (auth-username-format | |
681 | (string "%Lu") | |
682 | "Username formatting before it's looked up from databases. You can | |
683 | use the standard variables here, e.g. %Lu would lowercase the username, | |
684 | %n would drop away the domain if it was given, or @samp{%n-AT-%d} would | |
685 | change the @samp{@@} into @samp{-AT-}. This translation is done after | |
686 | @samp{auth-username-translation} changes.") | |
687 | ||
688 | (auth-master-user-separator | |
689 | (string "") | |
690 | "If you want to allow master users to log in by specifying the master | |
691 | username within the normal username string (i.e. not using SASL | |
692 | mechanism's support for it), you can specify the separator character | |
693 | here. The format is then <username><separator><master username>. | |
694 | UW-IMAP uses @samp{*} as the separator, so that could be a good | |
695 | choice.") | |
696 | ||
697 | (auth-anonymous-username | |
698 | (string "anonymous") | |
699 | "Username to use for users logging in with ANONYMOUS SASL | |
700 | mechanism.") | |
701 | ||
702 | (auth-worker-max-count | |
703 | (non-negative-integer 30) | |
704 | "Maximum number of dovecot-auth worker processes. They're used to | |
705 | execute blocking passdb and userdb queries (e.g. MySQL and PAM). | |
706 | They're automatically created and destroyed as needed.") | |
707 | ||
708 | (auth-gssapi-hostname | |
709 | (string "") | |
710 | "Host name to use in GSSAPI principal names. The default is to use | |
711 | the name returned by gethostname(). Use @samp{$ALL} (with quotes) to | |
712 | allow all keytab entries.") | |
713 | ||
714 | (auth-krb5-keytab | |
715 | (string "") | |
716 | "Kerberos keytab to use for the GSSAPI mechanism. Will use the | |
717 | system default (usually /etc/krb5.keytab) if not specified. You may | |
718 | need to change the auth service to run as root to be able to read this | |
719 | file.") | |
720 | ||
721 | (auth-use-winbind? | |
722 | (boolean #f) | |
723 | "Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon | |
724 | and @samp{ntlm-auth} helper. | |
725 | <doc/wiki/Authentication/Mechanisms/Winbind.txt>.") | |
726 | ||
727 | (auth-winbind-helper-path | |
728 | (file-name "/usr/bin/ntlm_auth") | |
729 | "Path for Samba's @samp{ntlm-auth} helper binary.") | |
730 | ||
731 | (auth-failure-delay | |
732 | (string "2 secs") | |
733 | "Time to delay before replying to failed authentications.") | |
734 | ||
735 | (auth-ssl-require-client-cert? | |
736 | (boolean #f) | |
737 | "Require a valid SSL client certificate or the authentication | |
738 | fails.") | |
739 | ||
740 | (auth-ssl-username-from-cert? | |
741 | (boolean #f) | |
742 | "Take the username from client's SSL certificate, using | |
743 | @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's | |
744 | CommonName.") | |
745 | ||
746 | (auth-mechanisms | |
747 | (space-separated-string-list '("plain")) | |
748 | "List of wanted authentication mechanisms. Supported mechanisms are: | |
749 | @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5}, | |
750 | @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi}, | |
751 | @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also | |
752 | @samp{disable-plaintext-auth} setting.") | |
753 | ||
754 | (director-servers | |
755 | (space-separated-string-list '()) | |
756 | "List of IPs or hostnames to all director servers, including ourself. | |
757 | Ports can be specified as ip:port. The default port is the same as what | |
758 | director service's @samp{inet-listener} is using.") | |
759 | ||
760 | (director-mail-servers | |
761 | (space-separated-string-list '()) | |
762 | "List of IPs or hostnames to all backend mail servers. Ranges are | |
763 | allowed too, like 10.0.0.10-10.0.0.30.") | |
764 | ||
765 | (director-user-expire | |
766 | (string "15 min") | |
767 | "How long to redirect users to a specific server after it no longer | |
768 | has any connections.") | |
769 | ||
d8c18af8 AW |
770 | (director-username-hash |
771 | (string "%Lu") | |
772 | "How the username is translated before being hashed. Useful values | |
773 | include %Ln if user can log in with or without @@domain, %Ld if mailboxes | |
774 | are shared within domain.") | |
775 | ||
776 | ;;; Log destination. | |
777 | ||
778 | (log-path | |
779 | (string "syslog") | |
780 | "Log file to use for error messages. @samp{syslog} logs to syslog, | |
781 | @samp{/dev/stderr} logs to stderr.") | |
782 | ||
783 | (info-log-path | |
784 | (string "") | |
785 | "Log file to use for informational messages. Defaults to | |
786 | @samp{log-path}.") | |
787 | ||
788 | (debug-log-path | |
789 | (string "") | |
790 | "Log file to use for debug messages. Defaults to | |
791 | @samp{info-log-path}.") | |
792 | ||
793 | (syslog-facility | |
794 | (string "mail") | |
795 | "Syslog facility to use if you're logging to syslog. Usually if you | |
796 | don't want to use @samp{mail}, you'll use local0..local7. Also other | |
797 | standard facilities are supported.") | |
798 | ||
799 | (auth-verbose? | |
800 | (boolean #f) | |
801 | "Log unsuccessful authentication attempts and the reasons why they | |
802 | failed.") | |
803 | ||
804 | (auth-verbose-passwords? | |
805 | (boolean #f) | |
806 | "In case of password mismatches, log the attempted password. Valid | |
807 | values are no, plain and sha1. sha1 can be useful for detecting brute | |
808 | force password attempts vs. user simply trying the same password over | |
809 | and over again. You can also truncate the value to n chars by appending | |
810 | \":n\" (e.g. sha1:6).") | |
811 | ||
812 | (auth-debug? | |
813 | (boolean #f) | |
814 | "Even more verbose logging for debugging purposes. Shows for example | |
815 | SQL queries.") | |
816 | ||
817 | (auth-debug-passwords? | |
818 | (boolean #f) | |
819 | "In case of password mismatches, log the passwords and used scheme so | |
820 | the problem can be debugged. Enabling this also enables | |
821 | @samp{auth-debug}.") | |
822 | ||
823 | (mail-debug? | |
824 | (boolean #f) | |
825 | "Enable mail process debugging. This can help you figure out why | |
826 | Dovecot isn't finding your mails.") | |
827 | ||
828 | (verbose-ssl? | |
829 | (boolean #f) | |
830 | "Show protocol level SSL errors.") | |
831 | ||
832 | (log-timestamp | |
833 | (string "\"%b %d %H:%M:%S \"") | |
834 | "Prefix for each line written to log file. % codes are in | |
835 | strftime(3) format.") | |
836 | ||
837 | (login-log-format-elements | |
838 | (space-separated-string-list | |
839 | '("user=<%u>" "method=%m" "rip=%r" "lip=%l" "mpid=%e" "%c")) | |
840 | "List of elements we want to log. The elements which have a | |
841 | non-empty variable value are joined together to form a comma-separated | |
842 | string.") | |
843 | ||
844 | (login-log-format | |
845 | (string "%$: %s") | |
846 | "Login log format. %s contains @samp{login-log-format-elements} | |
847 | string, %$ contains the data we want to log.") | |
848 | ||
849 | (mail-log-prefix | |
28c03b45 | 850 | (string "\"%s(%u)<%{pid}><%{session}>: \"") |
d8c18af8 AW |
851 | "Log prefix for mail processes. See doc/wiki/Variables.txt for list |
852 | of possible variables you can use.") | |
853 | ||
854 | (deliver-log-format | |
855 | (string "msgid=%m: %$") | |
856 | "Format to use for logging mail deliveries. You can use variables: | |
857 | @table @code | |
858 | @item %$ | |
859 | Delivery status message (e.g. @samp{saved to INBOX}) | |
860 | @item %m | |
861 | Message-ID | |
862 | @item %s | |
863 | Subject | |
864 | @item %f | |
865 | From address | |
866 | @item %p | |
867 | Physical size | |
868 | @item %w | |
869 | Virtual size. | |
870 | @end table") | |
871 | ||
872 | ;;; Mailbox locations and namespaces | |
873 | ||
874 | (mail-location | |
875 | (string "") | |
876 | "Location for users' mailboxes. The default is empty, which means | |
877 | that Dovecot tries to find the mailboxes automatically. This won't work | |
878 | if the user doesn't yet have any mail, so you should explicitly tell | |
879 | Dovecot the full location. | |
880 | ||
881 | If you're using mbox, giving a path to the INBOX | |
882 | file (e.g. /var/mail/%u) isn't enough. You'll also need to tell Dovecot | |
883 | where the other mailboxes are kept. This is called the \"root mail | |
884 | directory\", and it must be the first path given in the | |
885 | @samp{mail-location} setting. | |
886 | ||
887 | There are a few special variables you can use, eg.: | |
888 | ||
889 | @table @samp | |
890 | @item %u | |
891 | username | |
892 | @item %n | |
893 | user part in user@@domain, same as %u if there's no domain | |
894 | @item %d | |
895 | domain part in user@@domain, empty if there's no domain | |
896 | @item %h | |
897 | home director | |
898 | @end table | |
899 | ||
900 | See doc/wiki/Variables.txt for full list. Some examples: | |
901 | @table @samp | |
902 | @item maildir:~/Maildir | |
903 | @item mbox:~/mail:INBOX=/var/mail/%u | |
904 | @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/% | |
905 | @end table") | |
906 | ||
907 | (mail-uid | |
908 | (string "") | |
909 | "System user and group used to access mails. If you use multiple, | |
910 | userdb can override these by returning uid or gid fields. You can use | |
911 | either numbers or names. <doc/wiki/UserIds.txt>.") | |
912 | ||
913 | (mail-gid | |
914 | (string "") | |
915 | "") | |
916 | ||
917 | (mail-privileged-group | |
918 | (string "") | |
919 | "Group to enable temporarily for privileged operations. Currently | |
920 | this is used only with INBOX when either its initial creation or | |
921 | dotlocking fails. Typically this is set to \"mail\" to give access to | |
922 | /var/mail.") | |
923 | ||
924 | (mail-access-groups | |
925 | (string "") | |
926 | "Grant access to these supplementary groups for mail processes. | |
927 | Typically these are used to set up access to shared mailboxes. Note | |
928 | that it may be dangerous to set these if users can create | |
929 | symlinks (e.g. if \"mail\" group is set here, ln -s /var/mail ~/mail/var | |
930 | could allow a user to delete others' mailboxes, or ln -s | |
931 | /secret/shared/box ~/mail/mybox would allow reading it).") | |
932 | ||
933 | (mail-full-filesystem-access? | |
934 | (boolean #f) | |
8f65585b | 935 | "Allow full file system access to clients. There's no access checks |
d8c18af8 AW |
936 | other than what the operating system does for the active UID/GID. It |
937 | works with both maildir and mboxes, allowing you to prefix mailboxes | |
938 | names with e.g. /path/ or ~user/.") | |
939 | ||
940 | ;;; Mail processes | |
941 | ||
942 | (mmap-disable? | |
943 | (boolean #f) | |
944 | "Don't use mmap() at all. This is required if you store indexes to | |
8f65585b | 945 | shared file systems (NFS or clustered file system).") |
d8c18af8 AW |
946 | |
947 | (dotlock-use-excl? | |
948 | (boolean #t) | |
949 | "Rely on @samp{O_EXCL} to work when creating dotlock files. NFS | |
950 | supports @samp{O_EXCL} since version 3, so this should be safe to use | |
951 | nowadays by default.") | |
952 | ||
953 | (mail-fsync | |
954 | (string "optimized") | |
955 | "When to use fsync() or fdatasync() calls: | |
956 | @table @code | |
957 | @item optimized | |
958 | Whenever necessary to avoid losing important data | |
959 | @item always | |
960 | Useful with e.g. NFS when write()s are delayed | |
961 | @item never | |
962 | Never use it (best performance, but crashes can lose data). | |
963 | @end table") | |
964 | ||
965 | (mail-nfs-storage? | |
966 | (boolean #f) | |
967 | "Mail storage exists in NFS. Set this to yes to make Dovecot flush | |
968 | NFS caches whenever needed. If you're using only a single mail server | |
969 | this isn't needed.") | |
970 | ||
971 | (mail-nfs-index? | |
972 | (boolean #f) | |
973 | "Mail index files also exist in NFS. Setting this to yes requires | |
974 | @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.") | |
975 | ||
976 | (lock-method | |
977 | (string "fcntl") | |
978 | "Locking method for index files. Alternatives are fcntl, flock and | |
979 | dotlock. Dotlocking uses some tricks which may create more disk I/O | |
980 | than other locking methods. NFS users: flock doesn't work, remember to | |
981 | change @samp{mmap-disable}.") | |
982 | ||
983 | (mail-temp-dir | |
984 | (file-name "/tmp") | |
985 | "Directory in which LDA/LMTP temporarily stores incoming mails >128 | |
986 | kB.") | |
987 | ||
988 | (first-valid-uid | |
989 | (non-negative-integer 500) | |
990 | "Valid UID range for users. This is mostly to make sure that users can't | |
991 | log in as daemons or other system users. Note that denying root logins is | |
992 | hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid} | |
993 | is set to 0.") | |
994 | ||
995 | (last-valid-uid | |
996 | (non-negative-integer 0) | |
997 | "") | |
998 | ||
999 | (first-valid-gid | |
1000 | (non-negative-integer 1) | |
1001 | "Valid GID range for users. Users having non-valid GID as primary group ID | |
1002 | aren't allowed to log in. If user belongs to supplementary groups with | |
1003 | non-valid GIDs, those groups are not set.") | |
1004 | ||
1005 | (last-valid-gid | |
1006 | (non-negative-integer 0) | |
1007 | "") | |
1008 | ||
1009 | (mail-max-keyword-length | |
1010 | (non-negative-integer 50) | |
1011 | "Maximum allowed length for mail keyword name. It's only forced when | |
1012 | trying to create new keywords.") | |
1013 | ||
1014 | (valid-chroot-dirs | |
1015 | (colon-separated-file-name-list '()) | |
1016 | "List of directories under which chrooting is allowed for mail | |
1017 | processes (i.e. /var/mail will allow chrooting to /var/mail/foo/bar | |
1018 | too). This setting doesn't affect @samp{login-chroot} | |
1019 | @samp{mail-chroot} or auth chroot settings. If this setting is empty, | |
1020 | \"/./\" in home dirs are ignored. WARNING: Never add directories here | |
1021 | which local users can modify, that may lead to root exploit. Usually | |
1022 | this should be done only if you don't allow shell access for users. | |
1023 | <doc/wiki/Chrooting.txt>.") | |
1024 | ||
1025 | (mail-chroot | |
1026 | (string "") | |
1027 | "Default chroot directory for mail processes. This can be overridden | |
1028 | for specific users in user database by giving /./ in user's home | |
1029 | directory (e.g. /home/./user chroots into /home). Note that usually | |
1030 | there is no real need to do chrooting, Dovecot doesn't allow users to | |
1031 | access files outside their mail directory anyway. If your home | |
1032 | directories are prefixed with the chroot directory, append \"/.\" to | |
1033 | @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.") | |
1034 | ||
1035 | (auth-socket-path | |
1036 | (file-name "/var/run/dovecot/auth-userdb") | |
1037 | "UNIX socket path to master authentication server to find users. | |
1038 | This is used by imap (for shared users) and lda.") | |
1039 | ||
1040 | (mail-plugin-dir | |
1041 | (file-name "/usr/lib/dovecot") | |
1042 | "Directory where to look up mail plugins.") | |
1043 | ||
1044 | (mail-plugins | |
1045 | (space-separated-string-list '()) | |
1046 | "List of plugins to load for all services. Plugins specific to IMAP, | |
1047 | LDA, etc. are added to this list in their own .conf files.") | |
1048 | ||
1049 | ||
1050 | (mail-cache-min-mail-count | |
1051 | (non-negative-integer 0) | |
1052 | "The minimum number of mails in a mailbox before updates are done to | |
1053 | cache file. This allows optimizing Dovecot's behavior to do less disk | |
1054 | writes at the cost of more disk reads.") | |
1055 | ||
1056 | (mailbox-idle-check-interval | |
1057 | (string "30 secs") | |
1058 | "When IDLE command is running, mailbox is checked once in a while to | |
1059 | see if there are any new mails or other changes. This setting defines | |
1060 | the minimum time to wait between those checks. Dovecot can also use | |
1061 | dnotify, inotify and kqueue to find out immediately when changes | |
1062 | occur.") | |
1063 | ||
1064 | (mail-save-crlf? | |
1065 | (boolean #f) | |
1066 | "Save mails with CR+LF instead of plain LF. This makes sending those | |
1067 | mails take less CPU, especially with sendfile() syscall with Linux and | |
1068 | FreeBSD. But it also creates a bit more disk I/O which may just make it | |
1069 | slower. Also note that if other software reads the mboxes/maildirs, | |
1070 | they may handle the extra CRs wrong and cause problems.") | |
1071 | ||
1072 | (maildir-stat-dirs? | |
1073 | (boolean #f) | |
1074 | "By default LIST command returns all entries in maildir beginning | |
1075 | with a dot. Enabling this option makes Dovecot return only entries | |
1076 | which are directories. This is done by stat()ing each entry, so it | |
1077 | causes more disk I/O. | |
1078 | (For systems setting struct @samp{dirent->d_type} this check is free | |
1079 | and it's done always regardless of this setting).") | |
1080 | ||
1081 | (maildir-copy-with-hardlinks? | |
1082 | (boolean #t) | |
1083 | "When copying a message, do it with hard links whenever possible. | |
1084 | This makes the performance much better, and it's unlikely to have any | |
1085 | side effects.") | |
1086 | ||
1087 | (maildir-very-dirty-syncs? | |
1088 | (boolean #f) | |
1089 | "Assume Dovecot is the only MUA accessing Maildir: Scan cur/ | |
1090 | directory only when its mtime changes unexpectedly or when we can't find | |
1091 | the mail otherwise.") | |
1092 | ||
1093 | (mbox-read-locks | |
1094 | (space-separated-string-list '("fcntl")) | |
1095 | "Which locking methods to use for locking mbox. There are four | |
1096 | available: | |
1097 | ||
1098 | @table @code | |
1099 | @item dotlock | |
1100 | Create <mailbox>.lock file. This is the oldest and most NFS-safe | |
1101 | solution. If you want to use /var/mail/ like directory, the users will | |
1102 | need write access to that directory. | |
1103 | @item dotlock-try | |
1104 | Same as dotlock, but if it fails because of permissions or because there | |
1105 | isn't enough disk space, just skip it. | |
1106 | @item fcntl | |
1107 | Use this if possible. Works with NFS too if lockd is used. | |
1108 | @item flock | |
1109 | May not exist in all systems. Doesn't work with NFS. | |
1110 | @item lockf | |
1111 | May not exist in all systems. Doesn't work with NFS. | |
1112 | @end table | |
1113 | ||
1114 | You can use multiple locking methods; if you do the order they're declared | |
1115 | in is important to avoid deadlocks if other MTAs/MUAs are using multiple | |
1116 | locking methods as well. Some operating systems don't allow using some of | |
1117 | them simultaneously.") | |
1118 | ||
1119 | (mbox-write-locks | |
1120 | (space-separated-string-list '("dotlock" "fcntl")) | |
1121 | "") | |
1122 | ||
1123 | (mbox-lock-timeout | |
1124 | (string "5 mins") | |
1125 | "Maximum time to wait for lock (all of them) before aborting.") | |
1126 | ||
1127 | (mbox-dotlock-change-timeout | |
1128 | (string "2 mins") | |
1129 | "If dotlock exists but the mailbox isn't modified in any way, | |
1130 | override the lock file after this much time.") | |
1131 | ||
1132 | (mbox-dirty-syncs? | |
1133 | (boolean #t) | |
1134 | "When mbox changes unexpectedly we have to fully read it to find out | |
1135 | what changed. If the mbox is large this can take a long time. Since | |
1136 | the change is usually just a newly appended mail, it'd be faster to | |
1137 | simply read the new mails. If this setting is enabled, Dovecot does | |
1138 | this but still safely fallbacks to re-reading the whole mbox file | |
1139 | whenever something in mbox isn't how it's expected to be. The only real | |
1140 | downside to this setting is that if some other MUA changes message | |
1141 | flags, Dovecot doesn't notice it immediately. Note that a full sync is | |
1142 | done with SELECT, EXAMINE, EXPUNGE and CHECK commands.") | |
1143 | ||
1144 | (mbox-very-dirty-syncs? | |
1145 | (boolean #f) | |
1146 | "Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT, | |
1147 | EXAMINE, EXPUNGE or CHECK commands. If this is set, | |
1148 | @samp{mbox-dirty-syncs} is ignored.") | |
1149 | ||
1150 | (mbox-lazy-writes? | |
1151 | (boolean #t) | |
1152 | "Delay writing mbox headers until doing a full write sync (EXPUNGE | |
1153 | and CHECK commands and when closing the mailbox). This is especially | |
1154 | useful for POP3 where clients often delete all mails. The downside is | |
1155 | that our changes aren't immediately visible to other MUAs.") | |
1156 | ||
1157 | (mbox-min-index-size | |
1158 | (non-negative-integer 0) | |
1159 | "If mbox size is smaller than this (e.g. 100k), don't write index | |
1160 | files. If an index file already exists it's still read, just not | |
1161 | updated.") | |
1162 | ||
1163 | (mdbox-rotate-size | |
28c03b45 | 1164 | (non-negative-integer #e10e6) |
d8c18af8 AW |
1165 | "Maximum dbox file size until it's rotated.") |
1166 | ||
1167 | (mdbox-rotate-interval | |
1168 | (string "1d") | |
1169 | "Maximum dbox file age until it's rotated. Typically in days. Day | |
1170 | begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check | |
1171 | disabled.") | |
1172 | ||
1173 | (mdbox-preallocate-space? | |
1174 | (boolean #f) | |
1175 | "When creating new mdbox files, immediately preallocate their size to | |
1176 | @samp{mdbox-rotate-size}. This setting currently works only in Linux | |
8f65585b | 1177 | with some file systems (ext4, xfs).") |
d8c18af8 AW |
1178 | |
1179 | (mail-attachment-dir | |
1180 | (string "") | |
1181 | "sdbox and mdbox support saving mail attachments to external files, | |
1182 | which also allows single instance storage for them. Other backends | |
1183 | don't support this for now. | |
1184 | ||
1185 | WARNING: This feature hasn't been tested much yet. Use at your own risk. | |
1186 | ||
1187 | Directory root where to store mail attachments. Disabled, if empty.") | |
1188 | ||
1189 | (mail-attachment-min-size | |
1190 | (non-negative-integer #e128e3) | |
1191 | "Attachments smaller than this aren't saved externally. It's also | |
1192 | possible to write a plugin to disable saving specific attachments | |
1193 | externally.") | |
1194 | ||
1195 | (mail-attachment-fs | |
1196 | (string "sis posix") | |
8f65585b | 1197 | "File system backend to use for saving attachments: |
d8c18af8 AW |
1198 | @table @code |
1199 | @item posix | |
1200 | No SiS done by Dovecot (but this might help FS's own deduplication) | |
1201 | @item sis posix | |
1202 | SiS with immediate byte-by-byte comparison during saving | |
1203 | @item sis-queue posix | |
1204 | SiS with delayed comparison and deduplication. | |
1205 | @end table") | |
1206 | ||
1207 | (mail-attachment-hash | |
1208 | (string "%{sha1}") | |
1209 | "Hash format to use in attachment filenames. You can add any text and | |
1210 | variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}}, | |
1211 | @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be | |
1212 | truncated, e.g. @code{%@{sha256:80@}} returns only first 80 bits.") | |
1213 | ||
1214 | (default-process-limit | |
1215 | (non-negative-integer 100) | |
1216 | "") | |
1217 | ||
1218 | (default-client-limit | |
1219 | (non-negative-integer 1000) | |
1220 | "") | |
1221 | ||
1222 | (default-vsz-limit | |
1223 | (non-negative-integer #e256e6) | |
1224 | "Default VSZ (virtual memory size) limit for service processes. | |
1225 | This is mainly intended to catch and kill processes that leak memory | |
1226 | before they eat up everything.") | |
1227 | ||
1228 | (default-login-user | |
1229 | (string "dovenull") | |
1230 | "Login user is internally used by login processes. This is the most | |
1231 | untrusted user in Dovecot system. It shouldn't have access to anything | |
1232 | at all.") | |
1233 | ||
1234 | (default-internal-user | |
1235 | (string "dovecot") | |
1236 | "Internal user is used by unprivileged processes. It should be | |
1237 | separate from login user, so that login processes can't disturb other | |
1238 | processes.") | |
1239 | ||
1240 | (ssl? | |
1241 | (string "required") | |
1242 | "SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.") | |
1243 | ||
1244 | (ssl-cert | |
1245 | (string "</etc/dovecot/default.pem") | |
1246 | "PEM encoded X.509 SSL/TLS certificate (public key).") | |
1247 | ||
1248 | (ssl-key | |
1249 | (string "</etc/dovecot/private/default.pem") | |
1250 | "PEM encoded SSL/TLS private key. The key is opened before | |
1251 | dropping root privileges, so keep the key file unreadable by anyone but | |
1252 | root.") | |
1253 | ||
1254 | (ssl-key-password | |
1255 | (string "") | |
1256 | "If key file is password protected, give the password here. | |
1257 | Alternatively give it when starting dovecot with -p parameter. Since | |
1258 | this file is often world-readable, you may want to place this setting | |
1259 | instead to a different.") | |
1260 | ||
1261 | (ssl-ca | |
1262 | (string "") | |
1263 | "PEM encoded trusted certificate authority. Set this only if you | |
1264 | intend to use @samp{ssl-verify-client-cert? #t}. The file should | |
1265 | contain the CA certificate(s) followed by the matching | |
1266 | CRL(s). (e.g. @samp{ssl-ca </etc/ssl/certs/ca.pem}).") | |
1267 | (ssl-require-crl? | |
1268 | (boolean #t) | |
1269 | "Require that CRL check succeeds for client certificates.") | |
1270 | (ssl-verify-client-cert? | |
1271 | (boolean #f) | |
1272 | "Request client to send a certificate. If you also want to require | |
1273 | it, set @samp{auth-ssl-require-client-cert? #t} in auth section.") | |
1274 | ||
1275 | (ssl-cert-username-field | |
1276 | (string "commonName") | |
1277 | "Which field from certificate to use for username. commonName and | |
1278 | x500UniqueIdentifier are the usual choices. You'll also need to set | |
1279 | @samp{auth-ssl-username-from-cert? #t}.") | |
1280 | ||
28c03b45 TGR |
1281 | (ssl-min-protocol |
1282 | (string "TLSv1") | |
1283 | "Minimum SSL protocol version to accept.") | |
d8c18af8 AW |
1284 | |
1285 | (ssl-cipher-list | |
28c03b45 | 1286 | (string "ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@STRENGTH") |
d8c18af8 AW |
1287 | "SSL ciphers to use.") |
1288 | ||
1289 | (ssl-crypto-device | |
1290 | (string "") | |
1291 | "SSL crypto device to use, for valid values run \"openssl engine\".") | |
1292 | ||
1293 | (postmaster-address | |
66329c23 | 1294 | (string "postmaster@%d") |
d8c18af8 AW |
1295 | "Address to use when sending rejection mails. |
1296 | Default is postmaster@@<your domain>. %d expands to recipient domain.") | |
1297 | ||
1298 | (hostname | |
1299 | (string "") | |
1300 | "Hostname to use in various parts of sent mails (e.g. in Message-Id) | |
1301 | and in LMTP replies. Default is the system's real hostname@@domain.") | |
1302 | ||
1303 | (quota-full-tempfail? | |
1304 | (boolean #f) | |
1305 | "If user is over quota, return with temporary failure instead of | |
1306 | bouncing the mail.") | |
1307 | ||
1308 | (sendmail-path | |
1309 | (file-name "/usr/sbin/sendmail") | |
1310 | "Binary to use for sending mails.") | |
1311 | ||
1312 | (submission-host | |
1313 | (string "") | |
1314 | "If non-empty, send mails via this SMTP host[:port] instead of | |
1315 | sendmail.") | |
1316 | ||
1317 | (rejection-subject | |
1318 | (string "Rejected: %s") | |
1319 | "Subject: header to use for rejection mails. You can use the same | |
1320 | variables as for @samp{rejection-reason} below.") | |
1321 | ||
1322 | (rejection-reason | |
1323 | (string "Your message to <%t> was automatically rejected:%n%r") | |
1324 | "Human readable error message for rejection mails. You can use | |
1325 | variables: | |
1326 | ||
1327 | @table @code | |
1328 | @item %n | |
1329 | CRLF | |
1330 | @item %r | |
1331 | reason | |
1332 | @item %s | |
1333 | original subject | |
1334 | @item %t | |
1335 | recipient | |
1336 | @end table") | |
1337 | ||
1338 | (recipient-delimiter | |
1339 | (string "+") | |
1340 | "Delimiter character between local-part and detail in email | |
1341 | address.") | |
1342 | ||
1343 | (lda-original-recipient-header | |
1344 | (string "") | |
1345 | "Header where the original recipient address (SMTP's RCPT TO: | |
1346 | address) is taken from if not available elsewhere. With dovecot-lda -a | |
1347 | parameter overrides this. A commonly used header for this is | |
1348 | X-Original-To.") | |
1349 | ||
1350 | (lda-mailbox-autocreate? | |
1351 | (boolean #f) | |
1352 | "Should saving a mail to a nonexistent mailbox automatically create | |
1353 | it?.") | |
1354 | ||
1355 | (lda-mailbox-autosubscribe? | |
1356 | (boolean #f) | |
1357 | "Should automatically created mailboxes be also automatically | |
1358 | subscribed?.") | |
1359 | ||
1360 | ||
1361 | (imap-max-line-length | |
1362 | (non-negative-integer #e64e3) | |
1363 | "Maximum IMAP command line length. Some clients generate very long | |
1364 | command lines with huge mailboxes, so you may need to raise this if you | |
1365 | get \"Too long argument\" or \"IMAP command line too large\" errors | |
1366 | often.") | |
1367 | ||
1368 | (imap-logout-format | |
28c03b45 | 1369 | (string "in=%i out=%o deleted=%{deleted} expunged=%{expunged} trashed=%{trashed} hdr_count=%{fetch_hdr_count} hdr_bytes=%{fetch_hdr_bytes} body_count=%{fetch_body_count} body_bytes=%{fetch_body_bytes}") |
d8c18af8 AW |
1370 | "IMAP logout format string: |
1371 | @table @code | |
1372 | @item %i | |
1373 | total number of bytes read from client | |
1374 | @item %o | |
1375 | total number of bytes sent to client. | |
28c03b45 TGR |
1376 | @end table |
1377 | See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.") | |
d8c18af8 AW |
1378 | |
1379 | (imap-capability | |
1380 | (string "") | |
1381 | "Override the IMAP CAPABILITY response. If the value begins with '+', | |
1382 | add the given capabilities on top of the defaults (e.g. +XFOO XBAR).") | |
1383 | ||
1384 | (imap-idle-notify-interval | |
1385 | (string "2 mins") | |
1386 | "How long to wait between \"OK Still here\" notifications when client | |
1387 | is IDLEing.") | |
1388 | ||
1389 | (imap-id-send | |
1390 | (string "") | |
1391 | "ID field names and values to send to clients. Using * as the value | |
1392 | makes Dovecot use the default value. The following fields have default | |
1393 | values currently: name, version, os, os-version, support-url, | |
1394 | support-email.") | |
1395 | ||
1396 | (imap-id-log | |
1397 | (string "") | |
1398 | "ID fields sent by client to log. * means everything.") | |
1399 | ||
1400 | (imap-client-workarounds | |
1401 | (space-separated-string-list '()) | |
1402 | "Workarounds for various client bugs: | |
1403 | ||
1404 | @table @code | |
1405 | @item delay-newmail | |
1406 | Send EXISTS/RECENT new mail notifications only when replying to NOOP and | |
1407 | CHECK commands. Some clients ignore them otherwise, for example OSX | |
1408 | Mail (<v2.1). Outlook Express breaks more badly though, without this it | |
1409 | may show user \"Message no longer in server\" errors. Note that OE6 | |
1410 | still breaks even with this workaround if synchronization is set to | |
1411 | \"Headers Only\". | |
1412 | ||
1413 | @item tb-extra-mailbox-sep | |
1414 | Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and | |
1415 | adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to | |
1416 | ignore the extra @samp{/} instead of treating it as invalid mailbox name. | |
1417 | ||
1418 | @item tb-lsub-flags | |
1419 | Show \\Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox). | |
1420 | This makes Thunderbird realize they aren't selectable and show them | |
1421 | greyed out, instead of only later giving \"not selectable\" popup error. | |
1422 | @end table | |
1423 | ") | |
1424 | ||
1425 | (imap-urlauth-host | |
1426 | (string "") | |
1427 | "Host allowed in URLAUTH URLs sent by client. \"*\" allows all.") ) | |
1428 | ||
1429 | (define-configuration opaque-dovecot-configuration | |
1430 | (dovecot | |
1431 | (package dovecot) | |
1432 | "The dovecot package.") | |
1433 | ||
1434 | (string | |
5305ed20 JL |
1435 | (string (configuration-missing-field 'opaque-dovecot-configuration |
1436 | 'string)) | |
d8c18af8 AW |
1437 | "The contents of the @code{dovecot.conf} to use.")) |
1438 | ||
1439 | (define %dovecot-accounts | |
1440 | ;; Account and group for the Dovecot daemon. | |
1441 | (list (user-group (name "dovecot") (system? #t)) | |
1442 | (user-account | |
1443 | (name "dovecot") | |
1444 | (group "dovecot") | |
1445 | (system? #t) | |
1446 | (comment "Dovecot daemon user") | |
1447 | (home-directory "/var/empty") | |
9e41130b | 1448 | (shell (file-append shadow "/sbin/nologin"))) |
d8c18af8 AW |
1449 | |
1450 | (user-group (name "dovenull") (system? #t)) | |
1451 | (user-account | |
1452 | (name "dovenull") | |
1453 | (group "dovenull") | |
1454 | (system? #t) | |
1455 | (comment "Dovecot daemon login user") | |
1456 | (home-directory "/var/empty") | |
9e41130b | 1457 | (shell (file-append shadow "/sbin/nologin"))))) |
d8c18af8 | 1458 | |
6310dff1 | 1459 | (define (%dovecot-activation config) |
d8c18af8 | 1460 | ;; Activation gexp. |
6310dff1 OP |
1461 | (let ((config-str |
1462 | (cond | |
1463 | ((opaque-dovecot-configuration? config) | |
1464 | (opaque-dovecot-configuration-string config)) | |
1465 | (else | |
1466 | (with-output-to-string | |
1467 | (lambda () | |
1468 | (serialize-configuration config | |
1469 | dovecot-configuration-fields))))))) | |
1470 | #~(begin | |
1471 | (use-modules (guix build utils)) | |
1472 | (define (mkdir-p/perms directory owner perms) | |
1473 | (mkdir-p directory) | |
1474 | (chown "/var/run/dovecot" (passwd:uid owner) (passwd:gid owner)) | |
1475 | (chmod directory perms)) | |
1476 | (define (build-subject parameters) | |
1477 | (string-concatenate | |
1478 | (map (lambda (pair) | |
1479 | (let ((k (car pair)) (v (cdr pair))) | |
1480 | (define (escape-char str chr) | |
1481 | (string-join (string-split str chr) (string #\\ chr))) | |
1482 | (string-append "/" k "=" | |
1483 | (escape-char (escape-char v #\=) #\/)))) | |
1484 | (filter (lambda (pair) (cdr pair)) parameters)))) | |
1485 | (define* (create-self-signed-certificate-if-absent | |
1486 | #:key private-key public-key (owner (getpwnam "root")) | |
1487 | (common-name (gethostname)) | |
59e80445 | 1488 | (organization-name "Guix") |
6310dff1 OP |
1489 | (organization-unit-name "Default Self-Signed Certificate") |
1490 | (subject-parameters `(("CN" . ,common-name) | |
1491 | ("O" . ,organization-name) | |
1492 | ("OU" . ,organization-unit-name))) | |
1493 | (subject (build-subject subject-parameters))) | |
1494 | ;; Note that by default, OpenSSL outputs keys in PEM format. This | |
1495 | ;; is what we want. | |
1496 | (unless (file-exists? private-key) | |
1497 | (cond | |
1498 | ((zero? (system* (string-append #$openssl "/bin/openssl") | |
1499 | "genrsa" "-out" private-key "2048")) | |
1500 | (chown private-key (passwd:uid owner) (passwd:gid owner)) | |
1501 | (chmod private-key #o400)) | |
1502 | (else | |
1503 | (format (current-error-port) | |
1504 | "Failed to create private key at ~a.\n" private-key)))) | |
1505 | (unless (file-exists? public-key) | |
1506 | (cond | |
1507 | ((zero? (system* (string-append #$openssl "/bin/openssl") | |
1508 | "req" "-new" "-x509" "-key" private-key | |
1509 | "-out" public-key "-days" "3650" | |
1510 | "-batch" "-subj" subject)) | |
1511 | (chown public-key (passwd:uid owner) (passwd:gid owner)) | |
1512 | (chmod public-key #o444)) | |
1513 | (else | |
1514 | (format (current-error-port) | |
1515 | "Failed to create public key at ~a.\n" public-key))))) | |
1516 | (let ((user (getpwnam "dovecot"))) | |
1517 | (mkdir-p/perms "/var/run/dovecot" user #o755) | |
1518 | (mkdir-p/perms "/var/lib/dovecot" user #o755) | |
1519 | (mkdir-p/perms "/etc/dovecot" user #o755) | |
1520 | (copy-file #$(plain-file "dovecot.conf" config-str) | |
1521 | "/etc/dovecot/dovecot.conf") | |
1522 | (mkdir-p/perms "/etc/dovecot/private" user #o700) | |
1523 | (create-self-signed-certificate-if-absent | |
1524 | #:private-key "/etc/dovecot/private/default.pem" | |
1525 | #:public-key "/etc/dovecot/default.pem" | |
1526 | #:owner (getpwnam "root") | |
1527 | #:common-name (format #f "Dovecot service on ~a" (gethostname))))))) | |
d8c18af8 | 1528 | |
d4053c71 AK |
1529 | (define (dovecot-shepherd-service config) |
1530 | "Return a list of <shepherd-service> for CONFIG." | |
6310dff1 OP |
1531 | (let ((dovecot (if (opaque-dovecot-configuration? config) |
1532 | (opaque-dovecot-configuration-dovecot config) | |
1533 | (dovecot-configuration-dovecot config)))) | |
d4053c71 | 1534 | (list (shepherd-service |
d8c18af8 AW |
1535 | (documentation "Run the Dovecot POP3/IMAP mail server.") |
1536 | (provision '(dovecot)) | |
1537 | (requirement '(networking)) | |
1538 | (start #~(make-forkexec-constructor | |
1539 | (list (string-append #$dovecot "/sbin/dovecot") | |
6310dff1 | 1540 | "-F"))) |
d8c18af8 AW |
1541 | (stop #~(make-forkexec-constructor |
1542 | (list (string-append #$dovecot "/sbin/dovecot") | |
6310dff1 | 1543 | "stop"))))))) |
d8c18af8 AW |
1544 | |
1545 | (define %dovecot-pam-services | |
1546 | (list (unix-pam-service "dovecot"))) | |
1547 | ||
1548 | (define dovecot-service-type | |
1549 | (service-type (name 'dovecot) | |
1550 | (extensions | |
d4053c71 AK |
1551 | (list (service-extension shepherd-root-service-type |
1552 | dovecot-shepherd-service) | |
d8c18af8 AW |
1553 | (service-extension account-service-type |
1554 | (const %dovecot-accounts)) | |
1555 | (service-extension pam-root-service-type | |
1556 | (const %dovecot-pam-services)) | |
1557 | (service-extension activation-service-type | |
6310dff1 | 1558 | %dovecot-activation))))) |
d8c18af8 AW |
1559 | |
1560 | (define* (dovecot-service #:key (config (dovecot-configuration))) | |
1561 | "Return a service that runs @command{dovecot}, a mail server that can run | |
1562 | POP3, IMAP, and LMTP. @var{config} should be a configuration object created | |
1563 | by @code{dovecot-configuration}. @var{config} may also be created by | |
1564 | @code{opaque-dovecot-configuration}, which allows specification of the | |
1565 | @code{dovecot.conf} as a string." | |
1566 | (validate-configuration config | |
1567 | (if (opaque-dovecot-configuration? config) | |
1568 | opaque-dovecot-configuration-fields | |
1569 | dovecot-configuration-fields)) | |
1570 | (service dovecot-service-type config)) | |
1571 | ||
1572 | ;; A little helper to make it easier to document all those fields. | |
5305ed20 JL |
1573 | (define (generate-dovecot-documentation) |
1574 | (generate-documentation | |
d8c18af8 AW |
1575 | `((dovecot-configuration |
1576 | ,dovecot-configuration-fields | |
1577 | (dict dict-configuration) | |
1578 | (namespaces namespace-configuration) | |
1579 | (plugin plugin-configuration) | |
1580 | (passdbs passdb-configuration) | |
1581 | (userdbs userdb-configuration) | |
1582 | (services service-configuration) | |
1583 | (protocols protocol-configuration)) | |
1584 | (dict-configuration ,dict-configuration-fields) | |
1585 | (plugin-configuration ,plugin-configuration-fields) | |
1586 | (passdb-configuration ,passdb-configuration-fields) | |
1587 | (userdb-configuration ,userdb-configuration-fields) | |
1588 | (unix-listener-configuration ,unix-listener-configuration-fields) | |
1589 | (fifo-listener-configuration ,fifo-listener-configuration-fields) | |
1590 | (inet-listener-configuration ,inet-listener-configuration-fields) | |
1591 | (namespace-configuration | |
1592 | ,namespace-configuration-fields | |
1593 | (mailboxes mailbox-configuration)) | |
1594 | (mailbox-configuration ,mailbox-configuration-fields) | |
1595 | (service-configuration | |
1596 | ,service-configuration-fields | |
1597 | (listeners unix-listener-configuration fifo-listener-configuration | |
1598 | inet-listener-configuration)) | |
5305ed20 JL |
1599 | (protocol-configuration ,protocol-configuration-fields)) |
1600 | 'dovecot-configuration)) | |
f88371e8 SB |
1601 | |
1602 | \f | |
1603 | ;;; | |
1604 | ;;; OpenSMTPD. | |
1605 | ;;; | |
1606 | ||
1607 | (define-record-type* <opensmtpd-configuration> | |
1608 | opensmtpd-configuration make-opensmtpd-configuration | |
1609 | opensmtpd-configuration? | |
1610 | (package opensmtpd-configuration-package | |
1611 | (default opensmtpd)) | |
1612 | (config-file opensmtpd-configuration-config-file | |
1613 | (default %default-opensmtpd-config-file))) | |
1614 | ||
1615 | (define %default-opensmtpd-config-file | |
1616 | (plain-file "smtpd.conf" " | |
1617 | listen on lo | |
1618 | accept from any for local deliver to mbox | |
1619 | accept from local for any relay | |
1620 | ")) | |
1621 | ||
1622 | (define opensmtpd-shepherd-service | |
1623 | (match-lambda | |
1624 | (($ <opensmtpd-configuration> package config-file) | |
1625 | (list (shepherd-service | |
1626 | (provision '(smtpd)) | |
1627 | (requirement '(loopback)) | |
1628 | (documentation "Run the OpenSMTPD daemon.") | |
1629 | (start (let ((smtpd (file-append package "/sbin/smtpd"))) | |
1630 | #~(make-forkexec-constructor | |
1631 | (list #$smtpd "-f" #$config-file) | |
1632 | #:pid-file "/var/run/smtpd.pid"))) | |
1633 | (stop #~(make-kill-destructor))))))) | |
1634 | ||
1635 | (define %opensmtpd-accounts | |
1636 | (list (user-group | |
1637 | (name "smtpq") | |
1638 | (system? #t)) | |
1639 | (user-account | |
1640 | (name "smtpd") | |
1641 | (group "nogroup") | |
1642 | (system? #t) | |
1643 | (comment "SMTP Daemon") | |
1644 | (home-directory "/var/empty") | |
1645 | (shell (file-append shadow "/sbin/nologin"))) | |
1646 | (user-account | |
1647 | (name "smtpq") | |
1648 | (group "smtpq") | |
1649 | (system? #t) | |
1650 | (comment "SMTPD Queue") | |
1651 | (home-directory "/var/empty") | |
1652 | (shell (file-append shadow "/sbin/nologin"))))) | |
1653 | ||
1654 | (define opensmtpd-activation | |
1655 | (match-lambda | |
1656 | (($ <opensmtpd-configuration> package config-file) | |
1657 | (let ((smtpd (file-append package "/sbin/smtpd"))) | |
1658 | #~(begin | |
e57bd0be | 1659 | (use-modules (guix build utils)) |
f88371e8 SB |
1660 | ;; Create mbox and spool directories. |
1661 | (mkdir-p "/var/mail") | |
1662 | (mkdir-p "/var/spool/smtpd") | |
1663 | (chmod "/var/spool/smtpd" #o711)))))) | |
1664 | ||
1665 | (define opensmtpd-service-type | |
1666 | (service-type | |
1667 | (name 'opensmtpd) | |
1668 | (extensions | |
1669 | (list (service-extension account-service-type | |
1670 | (const %opensmtpd-accounts)) | |
1671 | (service-extension activation-service-type | |
1672 | opensmtpd-activation) | |
1673 | (service-extension profile-service-type | |
1674 | (compose list opensmtpd-configuration-package)) | |
1675 | (service-extension shepherd-root-service-type | |
1676 | opensmtpd-shepherd-service))))) | |
82ccc499 CZ |
1677 | |
1678 | \f | |
8d17cf1c CZ |
1679 | ;;; |
1680 | ;;; mail aliases. | |
1681 | ;;; | |
1682 | ||
1683 | (define (mail-aliases-etc aliases) | |
1684 | `(("aliases" ,(plain-file "aliases" | |
1685 | ;; Ideally we'd use a format string like | |
1686 | ;; "~:{~a: ~{~a~^,~}\n~}", but it gives a | |
1687 | ;; warning that I can't figure out how to fix, | |
1688 | ;; so we'll just use string-join below instead. | |
1689 | (format #f "~:{~a: ~a\n~}" | |
1690 | (map (match-lambda | |
1691 | ((alias addresses ...) | |
1692 | (list alias (string-join addresses ",")))) | |
1693 | aliases)))))) | |
1694 | ||
1695 | (define mail-aliases-service-type | |
1696 | (service-type | |
1697 | (name 'mail-aliases) | |
1698 | (extensions | |
1699 | (list (service-extension etc-service-type mail-aliases-etc))) | |
1700 | (compose concatenate) | |
1701 | (extend append))) | |
1702 | ||
1703 | \f | |
82ccc499 CZ |
1704 | ;;; |
1705 | ;;; Exim. | |
1706 | ;;; | |
1707 | ||
1708 | (define-record-type* <exim-configuration> exim-configuration | |
1709 | make-exim-configuration | |
1710 | exim-configuration? | |
1711 | (package exim-configuration-package ;<package> | |
1712 | (default exim)) | |
1713 | (config-file exim-configuration-config-file ;file-like | |
b065f78e | 1714 | (default #f))) |
82ccc499 CZ |
1715 | |
1716 | (define %exim-accounts | |
1717 | (list (user-group | |
1718 | (name "exim") | |
1719 | (system? #t)) | |
1720 | (user-account | |
1721 | (name "exim") | |
1722 | (group "exim") | |
1723 | (system? #t) | |
1724 | (comment "Exim Daemon") | |
1725 | (home-directory "/var/empty") | |
1726 | (shell (file-append shadow "/sbin/nologin"))))) | |
1727 | ||
1728 | (define (exim-computed-config-file package config-file) | |
1729 | (computed-file "exim.conf" | |
1730 | #~(call-with-output-file #$output | |
1731 | (lambda (port) | |
1732 | (format port " | |
1733 | exim_user = exim | |
1734 | exim_group = exim | |
1735 | .include ~a" | |
1736 | #$(or config-file | |
1737 | (file-append package "/etc/exim.conf"))))))) | |
1738 | ||
1739 | (define exim-shepherd-service | |
1740 | (match-lambda | |
b065f78e | 1741 | (($ <exim-configuration> package config-file) |
82ccc499 CZ |
1742 | (list (shepherd-service |
1743 | (provision '(exim mta)) | |
1744 | (documentation "Run the exim daemon.") | |
1745 | (requirement '(networking)) | |
1746 | (start #~(make-forkexec-constructor | |
1747 | '(#$(file-append package "/bin/exim") | |
1748 | "-bd" "-v" "-C" | |
1749 | #$(exim-computed-config-file package config-file)))) | |
1750 | (stop #~(make-kill-destructor))))))) | |
1751 | ||
1752 | (define exim-activation | |
1753 | (match-lambda | |
b065f78e | 1754 | (($ <exim-configuration> package config-file) |
82ccc499 CZ |
1755 | (with-imported-modules '((guix build utils)) |
1756 | #~(begin | |
1757 | (use-modules (guix build utils)) | |
1758 | ||
1759 | (let ((uid (passwd:uid (getpw "exim"))) | |
1760 | (gid (group:gid (getgr "exim")))) | |
1761 | (mkdir-p "/var/spool/exim") | |
1762 | (chown "/var/spool/exim" uid gid)) | |
1763 | ||
1764 | (zero? (system* #$(file-append package "/bin/exim") | |
1765 | "-bV" "-C" #$(exim-computed-config-file package config-file)))))))) | |
1766 | ||
82ccc499 CZ |
1767 | (define exim-profile |
1768 | (compose list exim-configuration-package)) | |
1769 | ||
1770 | (define exim-service-type | |
1771 | (service-type | |
1772 | (name 'exim) | |
1773 | (extensions | |
1774 | (list (service-extension shepherd-root-service-type exim-shepherd-service) | |
1775 | (service-extension account-service-type (const %exim-accounts)) | |
1776 | (service-extension activation-service-type exim-activation) | |
1777 | (service-extension profile-service-type exim-profile) | |
b065f78e | 1778 | (service-extension mail-aliases-service-type (const '())))))) |