mail.scm 67 KB

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