;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Julien Lepiller ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . ;;; ;;; Some of the help text was taken from the default dovecot.conf files. (define-module (services mail) #:use-module (gnu services) #:use-module (gnu services base) #:use-module (gnu services configuration) #:use-module (gnu services shepherd) #:use-module (gnu system pam) #:use-module (gnu system shadow) #:use-module (gnu packages admin) #:use-module (guix gexp) #:use-module (guix records) #:use-module (ice-9 match) #:use-module (packages perl) #:export (dkimproxy-out-service-type dkimproxy-out-configuration dkimproxy-out-configuration-package dkimproxy-out-configuration-config-file)) (define-record-type* dkimproxy-out-configuration make-dkimproxy-out-configuration dkimproxy-out-configuration? (package dkimproxy-out-configuration-package (default dkimproxy)) (config-file dkimproxy-out-configuration-config-file (default %default-dkimproxy-out-configuration-config-file))) (define %default-dkimproxy-out-configuration-config-file (plain-file "dkimproxy_out.conf" " # specify what address/port DKIMproxy should listen on listen 127.0.0.1:10027 # specify what address/port DKIMproxy forwards mail to relay 127.0.0.1:10028 # specify what domains DKIMproxy can sign for (comma-separated, no spaces) domain mail.example.com # specify what signatures to add signature dkim(c=relaxed) signature domainkeys(c=nofws) # specify location of the private key # It can be generated with for instance: # mkdir /etc/mail/dkim # openssl genrsa -out /etc/mail/dkim/private.key 1024 # openssl rsa -in /etc/mail/dkim/private.key -pubout -out /etc/mail/dkim/public.key keyfile /etc/mail/dkim/private.key # specify the selector (i.e. the name of the key record put in DNS) selector selector1 ")) (define dkimproxy-out-shepherd-service (match-lambda (($ package config-file) (list (shepherd-service (provision '(dkimproxy-out)) (requirement '(loopback)) (documentation "Outbound DKIM proxy.") (start (let ((proxy (file-append package "/bin/dkimproxy.out"))) #~(make-forkexec-constructor (list #$proxy (string-append "--conf_file=" #$config-file) "--pidfile=/var/run/dkimproxy.out.pid" "--user=dkimproxy" "--group=dkimproxy") #:pid-file "/var/run/dkimproxy.out.pid"))) (stop #~(make-kill-destructor))))))) (define %dkimproxy-accounts (list (user-group (name "dkimproxy") (system? #t)) (user-account (name "dkimproxy") (group "dkimproxy") (system? #t) (comment "Dkimproxy user") (home-directory "/var/empty") (shell (file-append shadow "/sbin/nologin"))))) (define dkimproxy-out-service-type (service-type (name 'dkimproxy-out) (extensions (list (service-extension account-service-type (const %dkimproxy-accounts)) (service-extension shepherd-root-service-type dkimproxy-out-shepherd-service)))))