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