From 176139488c80187d1f2e5462f8553db033a4044e Mon Sep 17 00:00:00 2001 From: Jude N Date: Sat, 9 Nov 2013 15:25:52 -0500 Subject: [PATCH] Initial version of hgr module --- files/dovecot/10-auth.conf | 127 ++++++++++ files/dovecot/10-mail.conf | 363 ++++++++++++++++++++++++++++ files/dovecot/10-master.conf | 119 +++++++++ files/my-notmuch-new.sh | 4 + files/postfix/master.cf | 126 ++++++++++ files/procmailrc | 13 + files/slapd/slapd.default | 47 ++++ files/spamassassin/local.cf | 88 +++++++ manifests/dovecot.pp | 42 ++++ manifests/init.pp | 12 + manifests/postfix.pp | 58 +++++ manifests/radicale.pp | 34 +++ manifests/slapd.pp | 55 +++++ manifests/spamassassin.pp | 38 +++ templates/postfix/main.cf.erb | 65 +++++ templates/radicale/config.erb | 97 ++++++++ templates/slapd/tls-config.ldif.erb | 9 + 17 files changed, 1297 insertions(+) create mode 100644 files/dovecot/10-auth.conf create mode 100644 files/dovecot/10-mail.conf create mode 100644 files/dovecot/10-master.conf create mode 100644 files/my-notmuch-new.sh create mode 100644 files/postfix/master.cf create mode 100644 files/procmailrc create mode 100644 files/slapd/slapd.default create mode 100644 files/spamassassin/local.cf create mode 100644 manifests/dovecot.pp create mode 100644 manifests/init.pp create mode 100644 manifests/postfix.pp create mode 100644 manifests/radicale.pp create mode 100644 manifests/slapd.pp create mode 100644 manifests/spamassassin.pp create mode 100644 templates/postfix/main.cf.erb create mode 100644 templates/radicale/config.erb create mode 100644 templates/slapd/tls-config.ldif.erb diff --git a/files/dovecot/10-auth.conf b/files/dovecot/10-auth.conf new file mode 100644 index 0000000..fa225b9 --- /dev/null +++ b/files/dovecot/10-auth.conf @@ -0,0 +1,127 @@ +## +## Authentication processes +## + +# Disable LOGIN command and all other plaintext authentications unless +# SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP +# matches the local IP (ie. you're connecting from the same computer), the +# connection is considered secure and plaintext authentication is allowed. +disable_plaintext_auth = yes + +# Authentication cache size (e.g. 10M). 0 means it's disabled. Note that +# bsdauth, PAM and vpopmail require cache_key to be set for caching to be used. +#auth_cache_size = 0 +# Time to live for cached data. After TTL expires the cached record is no +# longer used, *except* if the main database lookup returns internal failure. +# We also try to handle password changes automatically: If user's previous +# authentication was successful, but this one wasn't, the cache isn't used. +# For now this works only with plaintext authentication. +#auth_cache_ttl = 1 hour +# TTL for negative hits (user not found, password mismatch). +# 0 disables caching them completely. +#auth_cache_negative_ttl = 1 hour + +# Space separated list of realms for SASL authentication mechanisms that need +# them. You can leave it empty if you don't want to support multiple realms. +# Many clients simply use the first one listed here, so keep the default realm +# first. +#auth_realms = + +# Default realm/domain to use if none was specified. This is used for both +# SASL realms and appending @domain to username in plaintext logins. +#auth_default_realm = + +# List of allowed characters in username. If the user-given username contains +# a character not listed in here, the login automatically fails. This is just +# an extra check to make sure user can't exploit any potential quote escaping +# vulnerabilities with SQL/LDAP databases. If you want to allow all characters, +# set this value to empty. +#auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@ + +# Username character translations before it's looked up from databases. The +# value contains series of from -> to characters. For example "#@/@" means +# that '#' and '/' characters are translated to '@'. +#auth_username_translation = + +# Username formatting before it's looked up from databases. You can use +# the standard variables here, eg. %Lu would lowercase the username, %n would +# drop away the domain if it was given, or "%n-AT-%d" would change the '@' into +# "-AT-". This translation is done after auth_username_translation changes. +#auth_username_format = %Lu + +# If you want to allow master users to log in by specifying the master +# username within the normal username string (ie. not using SASL mechanism's +# support for it), you can specify the separator character here. The format +# is then . UW-IMAP uses "*" as the +# separator, so that could be a good choice. +#auth_master_user_separator = + +# Username to use for users logging in with ANONYMOUS SASL mechanism +#auth_anonymous_username = anonymous + +# Maximum number of dovecot-auth worker processes. They're used to execute +# blocking passdb and userdb queries (eg. MySQL and PAM). They're +# automatically created and destroyed as needed. +#auth_worker_max_count = 30 + +# Host name to use in GSSAPI principal names. The default is to use the +# name returned by gethostname(). Use "$ALL" (with quotes) to allow all keytab +# entries. +#auth_gssapi_hostname = + +# Kerberos keytab to use for the GSSAPI mechanism. Will use the system +# default (usually /etc/krb5.keytab) if not specified. You may need to change +# the auth service to run as root to be able to read this file. +#auth_krb5_keytab = + +# Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon and +# ntlm_auth helper. +#auth_use_winbind = no + +# Path for Samba's ntlm_auth helper binary. +#auth_winbind_helper_path = /usr/bin/ntlm_auth + +# Time to delay before replying to failed authentications. +#auth_failure_delay = 2 secs + +# Require a valid SSL client certificate or the authentication fails. +#auth_ssl_require_client_cert = no + +# Take the username from client's SSL certificate, using +# X509_NAME_get_text_by_NID() which returns the subject's DN's +# CommonName. +#auth_ssl_username_from_cert = no + +# Space separated list of wanted authentication mechanisms: +# plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp skey +# gss-spnego +# NOTE: See also disable_plaintext_auth setting. +auth_mechanisms = plain + +## +## Password and user databases +## + +# +# Password database is used to verify user's password (and nothing more). +# You can have multiple passdbs and userdbs. This is useful if you want to +# allow both system users (/etc/passwd) and virtual users to login without +# duplicating the system users into virtual database. +# +# +# +# User database specifies where mails are located and what user/group IDs +# own them. For single-UID configuration use "static" userdb. +# +# + +#!include auth-deny.conf.ext +#!include auth-master.conf.ext + +!include auth-system.conf.ext +#!include auth-sql.conf.ext +#!include auth-ldap.conf.ext +#!include auth-passwdfile.conf.ext +#!include auth-checkpassword.conf.ext +#!include auth-vpopmail.conf.ext +#!include auth-static.conf.ext diff --git a/files/dovecot/10-mail.conf b/files/dovecot/10-mail.conf new file mode 100644 index 0000000..009da4a --- /dev/null +++ b/files/dovecot/10-mail.conf @@ -0,0 +1,363 @@ +## +## Mailbox locations and namespaces +## + +# Location for users' mailboxes. The default is empty, which means that Dovecot +# tries to find the mailboxes automatically. This won't work if the user +# doesn't yet have any mail, so you should explicitly tell Dovecot the full +# location. +# +# If you're using mbox, giving a path to the INBOX file (eg. /var/mail/%u) +# isn't enough. You'll also need to tell Dovecot where the other mailboxes are +# kept. This is called the "root mail directory", and it must be the first +# path given in the mail_location setting. +# +# There are a few special variables you can use, eg.: +# +# %u - username +# %n - user part in user@domain, same as %u if there's no domain +# %d - domain part in user@domain, empty if there's no domain +# %h - home directory +# +# See doc/wiki/Variables.txt for full list. Some examples: +# +# mail_location = maildir:~/Maildir +# mail_location = mbox:~/mail:INBOX=/var/mail/%u +# mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n +# +# +# +#mail_location = mbox:~/mail:INBOX=/var/mail/%u +mail_location = maildir:~/Maildir/ + +# If you need to set multiple mailbox locations or want to change default +# namespace settings, you can do it by defining namespace sections. +# +# You can have private, shared and public namespaces. Private namespaces +# are for user's personal mails. Shared namespaces are for accessing other +# users' mailboxes that have been shared. Public namespaces are for shared +# mailboxes that are managed by sysadmin. If you create any shared or public +# namespaces you'll typically want to enable ACL plugin also, otherwise all +# users can access all the shared mailboxes, assuming they have permissions +# on filesystem level to do so. +namespace inbox { + # Namespace type: private, shared or public + #type = private + + # Hierarchy separator to use. You should use the same separator for all + # namespaces or some clients get confused. '/' is usually a good one. + # The default however depends on the underlying mail storage format. + #separator = + + # Prefix required to access this namespace. This needs to be different for + # all namespaces. For example "Public/". + #prefix = + + # Physical location of the mailbox. This is in same format as + # mail_location, which is also the default for it. + #location = + + # There can be only one INBOX, and this setting defines which namespace + # has it. + inbox = yes + + # If namespace is hidden, it's not advertised to clients via NAMESPACE + # extension. You'll most likely also want to set list=no. This is mostly + # useful when converting from another server with different namespaces which + # you want to deprecate but still keep working. For example you can create + # hidden namespaces with prefixes "~/mail/", "~%u/mail/" and "mail/". + #hidden = no + + # Show the mailboxes under this namespace with LIST command. This makes the + # namespace visible for clients that don't support NAMESPACE extension. + # "children" value lists child mailboxes, but hides the namespace prefix. + #list = yes + + # Namespace handles its own subscriptions. If set to "no", the parent + # namespace handles them (empty prefix should always have this as "yes") + #subscriptions = yes +} + +# Example shared namespace configuration +#namespace { + #type = shared + #separator = / + + # Mailboxes are visible under "shared/user@domain/" + # %%n, %%d and %%u are expanded to the destination user. + #prefix = shared/%%u/ + + # Mail location for other users' mailboxes. Note that %variables and ~/ + # expands to the logged in user's data. %%n, %%d, %%u and %%h expand to the + # destination user's data. + #location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u + + # Use the default namespace for saving subscriptions. + #subscriptions = no + + # List the shared/ namespace only if there are visible shared mailboxes. + #list = children +#} +# Should shared INBOX be visible as "shared/user" or "shared/user/INBOX"? +#mail_shared_explicit_inbox = yes + +# System user and group used to access mails. If you use multiple, userdb +# can override these by returning uid or gid fields. You can use either numbers +# or names. +#mail_uid = +#mail_gid = + +# Group to enable temporarily for privileged operations. Currently this is +# used only with INBOX when either its initial creation or dotlocking fails. +# Typically this is set to "mail" to give access to /var/mail. +#mail_privileged_group = + +# Grant access to these supplementary groups for mail processes. Typically +# these are used to set up access to shared mailboxes. Note that it may be +# dangerous to set these if users can create symlinks (e.g. if "mail" group is +# set here, ln -s /var/mail ~/mail/var could allow a user to delete others' +# mailboxes, or ln -s /secret/shared/box ~/mail/mybox would allow reading it). +#mail_access_groups = + +# Allow full filesystem access to clients. There's no access checks other than +# what the operating system does for the active UID/GID. It works with both +# maildir and mboxes, allowing you to prefix mailboxes names with eg. /path/ +# or ~user/. +#mail_full_filesystem_access = no + +## +## Mail processes +## + +# Don't use mmap() at all. This is required if you store indexes to shared +# filesystems (NFS or clustered filesystem). +#mmap_disable = no + +# Rely on O_EXCL to work when creating dotlock files. NFS supports O_EXCL +# since version 3, so this should be safe to use nowadays by default. +#dotlock_use_excl = yes + +# When to use fsync() or fdatasync() calls: +# optimized (default): Whenever necessary to avoid losing important data +# always: Useful with e.g. NFS when write()s are delayed +# never: Never use it (best performance, but crashes can lose data) +#mail_fsync = optimized + +# Mail storage exists in NFS. Set this to yes to make Dovecot flush NFS caches +# whenever needed. If you're using only a single mail server this isn't needed. +#mail_nfs_storage = no +# Mail index files also exist in NFS. Setting this to yes requires +# mmap_disable=yes and fsync_disable=no. +#mail_nfs_index = no + +# Locking method for index files. Alternatives are fcntl, flock and dotlock. +# Dotlocking uses some tricks which may create more disk I/O than other locking +# methods. NFS users: flock doesn't work, remember to change mmap_disable. +#lock_method = fcntl + +# Directory in which LDA/LMTP temporarily stores incoming mails >128 kB. +#mail_temp_dir = /tmp + +# Valid UID range for users, defaults to 500 and above. This is mostly +# to make sure that users can't log in as daemons or other system users. +# Note that denying root logins is hardcoded to dovecot binary and can't +# be done even if first_valid_uid is set to 0. +#first_valid_uid = 500 +#last_valid_uid = 0 + +# Valid GID range for users, defaults to non-root/wheel. Users having +# non-valid GID as primary group ID aren't allowed to log in. If user +# belongs to supplementary groups with non-valid GIDs, those groups are +# not set. +#first_valid_gid = 1 +#last_valid_gid = 0 + +# Maximum allowed length for mail keyword name. It's only forced when trying +# to create new keywords. +#mail_max_keyword_length = 50 + +# ':' separated list of directories under which chrooting is allowed for mail +# processes (ie. /var/mail will allow chrooting to /var/mail/foo/bar too). +# This setting doesn't affect login_chroot, mail_chroot or auth chroot +# settings. If this setting is empty, "/./" in home dirs are ignored. +# WARNING: Never add directories here which local users can modify, that +# may lead to root exploit. Usually this should be done only if you don't +# allow shell access for users. +#valid_chroot_dirs = + +# Default chroot directory for mail processes. This can be overridden for +# specific users in user database by giving /./ in user's home directory +# (eg. /home/./user chroots into /home). Note that usually there is no real +# need to do chrooting, Dovecot doesn't allow users to access files outside +# their mail directory anyway. If your home directories are prefixed with +# the chroot directory, append "/." to mail_chroot. +#mail_chroot = + +# UNIX socket path to master authentication server to find users. +# This is used by imap (for shared users) and lda. +#auth_socket_path = /var/run/dovecot/auth-userdb + +# Directory where to look up mail plugins. +#mail_plugin_dir = /usr/lib/dovecot/modules + +# Space separated list of plugins to load for all services. Plugins specific to +# IMAP, LDA, etc. are added to this list in their own .conf files. +#mail_plugins = + +## +## Mailbox handling optimizations +## + +# The minimum number of mails in a mailbox before updates are done to cache +# file. This allows optimizing Dovecot's behavior to do less disk writes at +# the cost of more disk reads. +#mail_cache_min_mail_count = 0 + +# When IDLE command is running, mailbox is checked once in a while to see if +# there are any new mails or other changes. This setting defines the minimum +# time to wait between those checks. Dovecot can also use dnotify, inotify and +# kqueue to find out immediately when changes occur. +#mailbox_idle_check_interval = 30 secs + +# Save mails with CR+LF instead of plain LF. This makes sending those mails +# take less CPU, especially with sendfile() syscall with Linux and FreeBSD. +# But it also creates a bit more disk I/O which may just make it slower. +# Also note that if other software reads the mboxes/maildirs, they may handle +# the extra CRs wrong and cause problems. +#mail_save_crlf = no + +# Max number of mails to keep open and prefetch to memory. This only works with +# some mailbox formats and/or operating systems. +#mail_prefetch_count = 0 + +# How often to scan for stale temporary files and delete them (0 = never). +# These should exist only after Dovecot dies in the middle of saving mails. +#mail_temp_scan_interval = 1w + +## +## Maildir-specific settings +## + +# By default LIST command returns all entries in maildir beginning with a dot. +# Enabling this option makes Dovecot return only entries which are directories. +# This is done by stat()ing each entry, so it causes more disk I/O. +# (For systems setting struct dirent->d_type, this check is free and it's +# done always regardless of this setting) +#maildir_stat_dirs = no + +# When copying a message, do it with hard links whenever possible. This makes +# the performance much better, and it's unlikely to have any side effects. +#maildir_copy_with_hardlinks = yes + +# Assume Dovecot is the only MUA accessing Maildir: Scan cur/ directory only +# when its mtime changes unexpectedly or when we can't find the mail otherwise. +#maildir_very_dirty_syncs = no + +# If enabled, Dovecot doesn't use the S= in the Maildir filenames for +# getting the mail's physical size, except when recalculating Maildir++ quota. +# This can be useful in systems where a lot of the Maildir filenames have a +# broken size. The performance hit for enabling this is very small. +#maildir_broken_filename_sizes = no + +## +## mbox-specific settings +## + +# Which locking methods to use for locking mbox. There are four available: +# dotlock: Create .lock file. This is the oldest and most NFS-safe +# solution. If you want to use /var/mail/ like directory, the users +# will need write access to that directory. +# dotlock_try: Same as dotlock, but if it fails because of permissions or +# because there isn't enough disk space, just skip it. +# fcntl : Use this if possible. Works with NFS too if lockd is used. +# flock : May not exist in all systems. Doesn't work with NFS. +# lockf : May not exist in all systems. Doesn't work with NFS. +# +# You can use multiple locking methods; if you do the order they're declared +# in is important to avoid deadlocks if other MTAs/MUAs are using multiple +# locking methods as well. Some operating systems don't allow using some of +# them simultaneously. +#mbox_read_locks = fcntl +#mbox_write_locks = dotlock fcntl + +# Maximum time to wait for lock (all of them) before aborting. +#mbox_lock_timeout = 5 mins + +# If dotlock exists but the mailbox isn't modified in any way, override the +# lock file after this much time. +#mbox_dotlock_change_timeout = 2 mins + +# When mbox changes unexpectedly we have to fully read it to find out what +# changed. If the mbox is large this can take a long time. Since the change +# is usually just a newly appended mail, it'd be faster to simply read the +# new mails. If this setting is enabled, Dovecot does this but still safely +# fallbacks to re-reading the whole mbox file whenever something in mbox isn't +# how it's expected to be. The only real downside to this setting is that if +# some other MUA changes message flags, Dovecot doesn't notice it immediately. +# Note that a full sync is done with SELECT, EXAMINE, EXPUNGE and CHECK +# commands. +#mbox_dirty_syncs = yes + +# Like mbox_dirty_syncs, but don't do full syncs even with SELECT, EXAMINE, +# EXPUNGE or CHECK commands. If this is set, mbox_dirty_syncs is ignored. +#mbox_very_dirty_syncs = no + +# Delay writing mbox headers until doing a full write sync (EXPUNGE and CHECK +# commands and when closing the mailbox). This is especially useful for POP3 +# where clients often delete all mails. The downside is that our changes +# aren't immediately visible to other MUAs. +#mbox_lazy_writes = yes + +# If mbox size is smaller than this (e.g. 100k), don't write index files. +# If an index file already exists it's still read, just not updated. +#mbox_min_index_size = 0 + +# Mail header selection algorithm to use for MD5 POP3 UIDLs when +# pop3_uidl_format=%m. For backwards compatibility we use apop3d inspired +# algorithm, but it fails if the first Received: header isn't unique in all +# mails. An alternative algorithm is "all" that selects all headers. +#mbox_md5 = apop3d + +## +## mdbox-specific settings +## + +# Maximum dbox file size until it's rotated. +#mdbox_rotate_size = 2M + +# Maximum dbox file age until it's rotated. Typically in days. Day begins +# from midnight, so 1d = today, 2d = yesterday, etc. 0 = check disabled. +#mdbox_rotate_interval = 0 + +# When creating new mdbox files, immediately preallocate their size to +# mdbox_rotate_size. This setting currently works only in Linux with some +# filesystems (ext4, xfs). +#mdbox_preallocate_space = no + +## +## Mail attachments +## + +# sdbox and mdbox support saving mail attachments to external files, which +# also allows single instance storage for them. Other backends don't support +# this for now. + +# WARNING: This feature hasn't been tested much yet. Use at your own risk. + +# Directory root where to store mail attachments. Disabled, if empty. +#mail_attachment_dir = + +# Attachments smaller than this aren't saved externally. It's also possible to +# write a plugin to disable saving specific attachments externally. +#mail_attachment_min_size = 128k + +# Filesystem backend to use for saving attachments: +# posix : No SiS done by Dovecot (but this might help FS's own deduplication) +# sis posix : SiS with immediate byte-by-byte comparison during saving +# sis-queue posix : SiS with delayed comparison and deduplication +#mail_attachment_fs = sis posix + +# Hash format to use in attachment filenames. You can add any text and +# variables: %{md4}, %{md5}, %{sha1}, %{sha256}, %{sha512}, %{size}. +# Variables can be truncated, e.g. %{sha256:80} returns only first 80 bits +#mail_attachment_hash = %{sha1} diff --git a/files/dovecot/10-master.conf b/files/dovecot/10-master.conf new file mode 100644 index 0000000..b6127d0 --- /dev/null +++ b/files/dovecot/10-master.conf @@ -0,0 +1,119 @@ +#default_process_limit = 100 +#default_client_limit = 1000 + +# Default VSZ (virtual memory size) limit for service processes. This is mainly +# intended to catch and kill processes that leak memory before they eat up +# everything. +#default_vsz_limit = 256M + +# Login user is internally used by login processes. This is the most untrusted +# user in Dovecot system. It shouldn't have access to anything at all. +#default_login_user = dovenull + +# Internal user is used by unprivileged processes. It should be separate from +# login user, so that login processes can't disturb other processes. +#default_internal_user = dovecot + +service imap-login { + inet_listener imap { + #port = 143 + } + inet_listener imaps { + #port = 993 + #ssl = yes + } + + # Number of connections to handle before starting a new process. Typically + # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0 + # is faster. + #service_count = 1 + + # Number of processes to always keep waiting for more connections. + #process_min_avail = 0 + + # If you set service_count=0, you probably need to grow this. + #vsz_limit = $default_vsz_limit +} + +service pop3-login { + inet_listener pop3 { + #port = 110 + } + inet_listener pop3s { + #port = 995 + #ssl = yes + } +} + +service lmtp { + unix_listener lmtp { + #mode = 0666 + } + + # Create inet listener only if you can't use the above UNIX socket + #inet_listener lmtp { + # Avoid making LMTP visible for the entire internet + #address = + #port = + #} +} + +service imap { + # Most of the memory goes to mmap()ing files. You may need to increase this + # limit if you have huge mailboxes. + #vsz_limit = $default_vsz_limit + + # Max. number of IMAP processes (connections) + #process_limit = 1024 +} + +service pop3 { + # Max. number of POP3 processes (connections) + #process_limit = 1024 +} + +service auth { + # auth_socket_path points to this userdb socket by default. It's typically + # used by dovecot-lda, doveadm, possibly imap process, etc. Users that have + # full permissions to this socket are able to get a list of all usernames and + # get the results of everyone's userdb lookups. + # + # The default 0666 mode allows anyone to connect to the socket, but the + # userdb lookups will succeed only if the userdb returns an "uid" field that + # matches the caller process's UID. Also if caller's uid or gid matches the + # socket's uid or gid the lookup succeeds. Anything else causes a failure. + # + # To give the caller full permissions to lookup all users, set the mode to + # something else than 0666 and Dovecot lets the kernel enforce the + # permissions (e.g. 0777 allows everyone full permissions). + #unix_listener auth-userdb { + # #mode = 0666 + # #user = + # #group = + #} + + # Postfix smtp-auth + unix_listener /var/spool/postfix/private/auth { + mode = 0666 + } + + # Auth process is run as this user. + #user = $default_internal_user +} + +service auth-worker { + # Auth worker process is run as root by default, so that it can access + # /etc/shadow. If this isn't necessary, the user should be changed to + # $default_internal_user. + #user = root +} + +service dict { + # If dict proxy is used, mail processes should have access to its socket. + # For example: mode=0660, group=vmail and global mail_access_groups=vmail + unix_listener dict { + #mode = 0600 + #user = + #group = + } +} diff --git a/files/my-notmuch-new.sh b/files/my-notmuch-new.sh new file mode 100644 index 0000000..0d8ba47 --- /dev/null +++ b/files/my-notmuch-new.sh @@ -0,0 +1,4 @@ +#!/bin/bash +/usr/local/bin/notmuch new >> /dev/null 2>&1 +/usr/local/bin/afew -nt >> /dev/null 2>&1 +/usr/local/bin/afew -m >> /dev/null 2>&1 diff --git a/files/postfix/master.cf b/files/postfix/master.cf new file mode 100644 index 0000000..accae33 --- /dev/null +++ b/files/postfix/master.cf @@ -0,0 +1,126 @@ +# +# Postfix master process configuration file. For details on the format +# of the file, see the master(5) manual page (command: "man 5 master"). +# +# Do not forget to execute "postfix reload" after editing this file. +# +# ========================================================================== +# service type private unpriv chroot wakeup maxproc command + args +# (yes) (yes) (yes) (never) (100) +# ========================================================================== +smtp inet n - - - - smtpd + -o content_filter=spamassassin +587 inet n - - - - smtpd + -o content_filter=spamassassin +#smtp inet n - - - 1 postscreen +#smtpd pass - - - - - smtpd +#dnsblog unix - - - - 0 dnsblog +#tlsproxy unix - - - - 0 tlsproxy +submission inet n - - - - smtpd + -o syslog_name=postfix/submission + -o smtpd_tls_security_level=encrypt + -o smtpd_sasl_auth_enable=yes + -o smtpd_sasl_type=dovecot + -o smtpd_sasl_path=private/auth + -o smtpd_client_restrictions=permit_sasl_authenticated,reject + -o smtpd_recipient_restrictions=reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_sasl_authenticated,reject +# -o syslog_name=postfix/submission +# -o smtpd_tls_security_level=encrypt +# -o smtpd_sasl_auth_enable=yes +# -o smtpd_client_restrictions=permit_sasl_authenticated,reject +# -o milter_macro_daemon_name=ORIGINATING +#smtps inet n - - - - smtpd +# -o syslog_name=postfix/smtps +# -o smtpd_tls_wrappermode=yes +# -o smtpd_sasl_auth_enable=yes +# -o smtpd_client_restrictions=permit_sasl_authenticated,reject +# -o milter_macro_daemon_name=ORIGINATING +#628 inet n - - - - qmqpd +pickup fifo n - - 60 1 pickup +cleanup unix n - - - 0 cleanup +qmgr fifo n - n 300 1 qmgr +#qmgr fifo n - n 300 1 oqmgr +tlsmgr unix - - - 1000? 1 tlsmgr +rewrite unix - - - - - trivial-rewrite +bounce unix - - - - 0 bounce +defer unix - - - - 0 bounce +trace unix - - - - 0 bounce +verify unix - - - - 1 verify +flush unix n - - 1000? 0 flush +proxymap unix - - n - - proxymap +proxywrite unix - - n - 1 proxymap +smtp unix - - - - - smtp +relay unix - - - - - smtp +# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5 +showq unix n - - - - showq +error unix - - - - - error +retry unix - - - - - error +discard unix - - - - - discard +local unix - n n - - local +virtual unix - n n - - virtual +lmtp unix - - - - - lmtp +anvil unix - - - - 1 anvil +scache unix - - - - 1 scache +# +# ==================================================================== +# Interfaces to non-Postfix software. Be sure to examine the manual +# pages of the non-Postfix software to find out what options it wants. +# +# Many of the following services use the Postfix pipe(8) delivery +# agent. See the pipe(8) man page for information about ${recipient} +# and other message envelope options. +# ==================================================================== +# +# maildrop. See the Postfix MAILDROP_README file for details. +# Also specify in main.cf: maildrop_destination_recipient_limit=1 +# +maildrop unix - n n - - pipe + flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient} +# +# ==================================================================== +# +# Recent Cyrus versions can use the existing "lmtp" master.cf entry. +# +# Specify in cyrus.conf: +# lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4 +# +# Specify in main.cf one or more of the following: +# mailbox_transport = lmtp:inet:localhost +# virtual_transport = lmtp:inet:localhost +# +# ==================================================================== +# +# Cyrus 2.1.5 (Amos Gouaux) +# Also specify in main.cf: cyrus_destination_recipient_limit=1 +# +#cyrus unix - n n - - pipe +# user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user} +# +# ==================================================================== +# Old example of delivery via Cyrus. +# +#old-cyrus unix - n n - - pipe +# flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user} +# +# ==================================================================== +# +# See the Postfix UUCP_README file for configuration details. +# +uucp unix - n n - - pipe + flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient) +# +# Other external delivery methods. +# +ifmail unix - n n - - pipe + flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient) +bsmtp unix - n n - - pipe + flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient +scalemail-backend unix - n n - 2 pipe + flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension} +mailman unix - n n - - pipe + flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py + ${nexthop} ${user} + +spamassassin unix - n n - - pipe + user=debian-spamd argv=/usr/bin/spamc -f -e + /usr/sbin/sendmail -oi -f ${sender} ${recipient} diff --git a/files/procmailrc b/files/procmailrc new file mode 100644 index 0000000..3650a98 --- /dev/null +++ b/files/procmailrc @@ -0,0 +1,13 @@ +SHELL="/bin/bash" +LOGFILE="/var/log/procmail.log" +DROPPRIVS=YES +ORGMAIL=$HOME/Maildir/ +DELIVER="/usr/lib/dovecot/deliver" +MAILDIR=$ORGMAIL +DEFAULT=$ORGMAIL +:0 w +* ^X-Spam-Status: Yes +$ORGMAIL/.Spam/ +:0 w +| $DELIVER + diff --git a/files/slapd/slapd.default b/files/slapd/slapd.default new file mode 100644 index 0000000..1ce8fdf --- /dev/null +++ b/files/slapd/slapd.default @@ -0,0 +1,47 @@ +# Default location of the slapd.conf file or slapd.d cn=config directory. If +# empty, use the compiled-in default (/etc/ldap/slapd.d with a fallback to +# /etc/ldap/slapd.conf). +SLAPD_CONF= + +# System account to run the slapd server under. If empty the server +# will run as root. +SLAPD_USER="openldap" + +# System group to run the slapd server under. If empty the server will +# run in the primary group of its user. +SLAPD_GROUP="openldap" + +# Path to the pid file of the slapd server. If not set the init.d script +# will try to figure it out from $SLAPD_CONF (/etc/ldap/slapd.conf by +# default) +SLAPD_PIDFILE= + +# slapd normally serves ldap only on all TCP-ports 389. slapd can also +# service requests on TCP-port 636 (ldaps) and requests via unix +# sockets. +# Example usage: +#SLAPD_SERVICES="ldap://127.0.0.1:389/ ldaps:/// ldapi:///" +SLAPD_SERVICES="ldaps:/// ldapi:///" + +# If SLAPD_NO_START is set, the init script will not start or restart +# slapd (but stop will still work). Uncomment this if you are +# starting slapd via some other means or if you don't want slapd normally +# started at boot. +#SLAPD_NO_START=1 + +# If SLAPD_SENTINEL_FILE is set to path to a file and that file exists, +# the init script will not start or restart slapd (but stop will still +# work). Use this for temporarily disabling startup of slapd (when doing +# maintenance, for example, or through a configuration management system) +# when you don't want to edit a configuration file. +SLAPD_SENTINEL_FILE=/etc/ldap/noslapd + +# For Kerberos authentication (via SASL), slapd by default uses the system +# keytab file (/etc/krb5.keytab). To use a different keytab file, +# uncomment this line and change the path. +#export KRB5_KTNAME=/etc/krb5.keytab + +# Additional options to pass to slapd +SLAPD_OPTIONS="" + + diff --git a/files/spamassassin/local.cf b/files/spamassassin/local.cf new file mode 100644 index 0000000..3453d9d --- /dev/null +++ b/files/spamassassin/local.cf @@ -0,0 +1,88 @@ +# This is the right place to customize your installation of SpamAssassin. +# +# See 'perldoc Mail::SpamAssassin::Conf' for details of what can be +# tweaked. +# +# Only a small subset of options are listed below +# +########################################################################### + +# Add *****SPAM***** to the Subject header of spam e-mails +# +# rewrite_header Subject *****SPAM***** +rewrite_header Subject +add_header spam Flag _YESNOCAPS_ +add_header all Status _YESNO_, score=_SCORE_ required_REQD_ tests=_TESTS_ autolearn=_AUTOLEARN_ version=_VERSION_ + + +# Save spam messages as a message/rfc822 MIME attachment instead of +# modifying the original message (0: off, 2: use text/plain instead) +# +# report_safe 1 + + +# Set which networks or hosts are considered 'trusted' by your mail +# server (i.e. not spammers) +# +# trusted_networks 212.17.35. + + +# Set file-locking method (flock is not safe over NFS, but is faster) +# +# lock_method flock + + +# Set the threshold at which a message is considered spam (default: 5.0) +# +# required_score 5.0 + + +# Use Bayesian classifier (default: 1) +# +# use_bayes 1 + + +# Bayesian classifier auto-learning (default: 1) +# +# bayes_auto_learn 1 + + +# Set headers which may provide inappropriate cues to the Bayesian +# classifier +# +# bayes_ignore_header X-Bogosity +# bayes_ignore_header X-Spam-Flag +# bayes_ignore_header X-Spam-Status + + +# Some shortcircuiting, if the plugin is enabled +# +ifplugin Mail::SpamAssassin::Plugin::Shortcircuit +# +# default: strongly-whitelisted mails are *really* whitelisted now, if the +# shortcircuiting plugin is active, causing early exit to save CPU load. +# Uncomment to turn this on +# +# shortcircuit USER_IN_WHITELIST on +# shortcircuit USER_IN_DEF_WHITELIST on +# shortcircuit USER_IN_ALL_SPAM_TO on +# shortcircuit SUBJECT_IN_WHITELIST on + +# the opposite; blacklisted mails can also save CPU +# +# shortcircuit USER_IN_BLACKLIST on +# shortcircuit USER_IN_BLACKLIST_TO on +# shortcircuit SUBJECT_IN_BLACKLIST on + +# if you have taken the time to correctly specify your "trusted_networks", +# this is another good way to save CPU +# +# shortcircuit ALL_TRUSTED on + +# and a well-trained bayes DB can save running rules, too +# +# shortcircuit BAYES_99 spam +# shortcircuit BAYES_00 ham + +endif # Mail::SpamAssassin::Plugin::Shortcircuit + diff --git a/manifests/dovecot.pp b/manifests/dovecot.pp new file mode 100644 index 0000000..5e1e44e --- /dev/null +++ b/manifests/dovecot.pp @@ -0,0 +1,42 @@ +class hgr::dovecot { + + package { + "dovecot-imapd": + ensure => installed; + } + + file { + "/etc/dovecot/conf.d/10-mail.conf": + ensure => present, + source => "puppet:///modules/hgr/dovecot/10-mail.conf", + owner => "root", + group => "root", + mode => "0644", + notify => Service["dovecot"], + require => [Package["dovecot-imapd"]]; + "/etc/dovecot/conf.d/10-master.conf": + ensure => present, + source => "puppet:///modules/hgr/dovecot/10-master.conf", + owner => "root", + group => "root", + mode => "0644", + notify => Service["dovecot"], + require => [Package["dovecot-imapd"]]; + "/etc/dovecot/conf.d/10-auth.conf": + ensure => present, + source => "puppet:///modules/hgr/dovecot/10-auth.conf", + owner => "root", + group => "root", + mode => "0644", + notify => Service["dovecot"], + require => [Package["dovecot-imapd"]]; + } + + service { + "dovecot": + ensure => running, + enable => true, + require => Package["dovecot-imapd"]; + } + +} diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..2e7e396 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,12 @@ +# Puppet manifests for a 'hackers GMAIL replacement' based on +# http://dbpmail.net/essays/2013-06-29-hackers-replacement-for-gmail.html + +class hgr { + + include hgr::postfix + include hgr::dovecot + include hgr::spamassassin + include hgr::radicale + include hgr::slapd + +} diff --git a/manifests/postfix.pp b/manifests/postfix.pp new file mode 100644 index 0000000..506af5c --- /dev/null +++ b/manifests/postfix.pp @@ -0,0 +1,58 @@ +class hgr::postfix { + + package { + "exim4": + ensure => absent; + "postfix": + ensure => installed; + "sasl2-bin": + ensure => installed; + "libsasl2-2": + ensure => installed; + "libsasl2-modules": + ensure => installed; + "procmail": + ensure => installed; + } + + file { + + "/etc/postfix/main.cf": + ensure => present, + content => template("hgr/postfix/main.cf.erb"), + owner => "root", + group => "root", + mode => "0644", + notify => Service["postfix"], + require => [Package["postfix"],File["/etc/ssl/certs/${::fqdn}.pem"],File["/etc/ssl/private/${::fqdn}.key"],File["/etc/ssl/certs/${::fqdn}-CA.pem"]]; + + "/etc/postfix/master.cf": + ensure => present, + source => "puppet:///modules/hgr/postfix/master.cf", + owner => "root", + group => "root", + mode => "0644", + notify => Service["postfix"], + require => [Package["postfix","spamassassin"]]; + "/etc/procmailrc": + ensure => present, + source => "puppet:///modules/hgr/procmailrc", + owner => "root", + group => "root", + mode => "0644", + require => Package["procmail"]; + + + } + + service { + "postfix": + ensure => running, + enable => true, + require => Package["postfix"]; + } + + + + +} diff --git a/manifests/radicale.pp b/manifests/radicale.pp new file mode 100644 index 0000000..1da60f9 --- /dev/null +++ b/manifests/radicale.pp @@ -0,0 +1,34 @@ +class hgr::radicale { + + $radicale_public_users = hiera('radicale.public_users','public') + $radicale_private_users = hiera('radicale.private_users','private') + + package { + "radicale": + ensure => installed; + } + + file { + "/etc/radicale/config": + ensure => file, + content => template("hgr/radicale/config.erb"), + owner => "root", + group => "root", + mode => "0644", + require => [Package["radicale"],File["/etc/ssl/certs/${::fqdn}.pem"],File["/etc/ssl/private/${::fqdn}.key"],File["/etc/radicale/users"]]; + "/etc/radicale/users": + ensure => file, + mode => "0644", + owner => "root", + group => "root", + require => Package["radicale"]; + } + + service { + "radicale": + ensure => running, + enable => true, + require => [Package["radicale"],File["/etc/radicale/config"]]; + } + +} diff --git a/manifests/slapd.pp b/manifests/slapd.pp new file mode 100644 index 0000000..b60eda8 --- /dev/null +++ b/manifests/slapd.pp @@ -0,0 +1,55 @@ +class hgr::slapd { + + # first define a admin password for LDAP + + package { + "slapd" : ensure => installed; + "ldapscripts" : ensure => installed; + } + + service { + "slapd": + ensure => running, + enable => true, + require => [Package["slapd"],File["/etc/default/slapd"]]; + } + + file { + "/etc/default/slapd": + ensure => present, + source => "puppet:///modules/hgr/slapd/slapd.default", + owner => "root", + group => "root", + mode => "0644", + require => Package["slapd"]; + + "/etc/ldap/slapd.d/tls-config.ldif": + ensure => present, + contents => template("hgr/slapd/tls-config.ldif.erb"), + owner => "root", + group => "root", + mode => "0644", + require => Package["slapd"]; + } + + exec { + "tls-config.ldif": + command => "/usr/bin/ldapmodify -QY EXTERNAL -H ldapi:/// -f /etc/ldap/slapd.d/tls-config.ldif", + unless => "/bin/grep olcTLS 'cn=config.ldif'", + logoutput => true, + refreshonly => true, + subscribe => File["/etc/ldap/slapd.d/tls-config.ldif"], + timeout => 5, + require => [Service["slapd"],File["/etc/ldap/slapd.d/tls-config.ldif"]]; + } + + # add openldap to the ssl-cert group + # (usermod -a -G ssl-cert openldap) + # unless 'groups openldap | grep ssl-cert' + + # Need to ensure /etc/ssl/private is group-readable + + # Need to open 636 on /etc/iptables/rules.v4 + + +} diff --git a/manifests/spamassassin.pp b/manifests/spamassassin.pp new file mode 100644 index 0000000..2b2d68d --- /dev/null +++ b/manifests/spamassassin.pp @@ -0,0 +1,38 @@ +class hgr::spamassassin { + + package { + "spamassassin": + ensure => installed; + "pyzor": + ensure => installed; + } + + file { + "/etc/spamassassin/local.cf": + ensure => present, + source => "puppet:///modules/hgr/spamassassin/local.cf", + owner => "root", + group => "root", + mode => "0644", + notify => Service["spamassassin"], + require => Package["spamassassin"]; + } + + service { + "spamassassin": + ensure => running, + enable => true, + require => Package["spamassassin"]; + } + + exec { + "pyzor-discover": + command => "/usr/bin/pyzor discover", + creates => "/root/.pyzor/servers", + user => "root", + require => Package["pyzor"]; + } + + + +} diff --git a/templates/postfix/main.cf.erb b/templates/postfix/main.cf.erb new file mode 100644 index 0000000..bfc7bb0 --- /dev/null +++ b/templates/postfix/main.cf.erb @@ -0,0 +1,65 @@ +# See /usr/share/postfix/main.cf.dist for a commented, more complete version + + +# Debian specific: Specifying a file name will cause the first +# line of that file to be used as the name. The Debian default +# is /etc/mailname. +#myorigin = /etc/mailname + +smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) +biff = no + +# appending .domain is the MUA's job. +append_dot_mydomain = no + +# Uncomment the next line to generate "delayed mail" warnings +#delay_warning_time = 4h + +readme_directory = no + +# TLS parameters +#smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem +smtpd_tls_cert_file=/etc/ssl/certs/<%= scope.lookupvar('::fqdn') %>.pem +#smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key +smtpd_tls_key_file=/etc/ssl/private/<%= scope.lookupvar('::fqdn') %>.key +smtpd_tls_CAfile=/etc/ssl/certs/<%= scope.lookupvar('::fqdn') %>-CA.pem +smtpd_use_tls=yes +smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache +smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache + +# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for +# information on enabling SSL in the smtp client. + +#myhostname = localhost +myhostname = <%= scope.lookupvar('::fqdn') %> +alias_maps = hash:/etc/aliases,regexp:/etc/postfix/regexp_aliases +alias_database = hash:/etc/aliases +myorigin = <%= scope.lookupvar('::fqdn') %> +mydestination = <%= scope.lookupvar('::fqdn') %>, localhost, localhost.localdomain, localhost +relayhost = +mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 +mailbox_size_limit = 0 +recipient_delimiter = + +inet_interfaces = all + +mailbox_command = procmail -a "$EXTENSION" +home_mailbox = Maildir/ + +smtpd_sasl_type = dovecot +smtpd_sasl_path = private/auth +smtpd_sasl_auth_enable = yes +smtpd_sasl_security_options = noanonymous +smtpd_sasl_local_domain = $myhostname +broken_sasl_auth_clients = yes + +smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, +#smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, +# reject_unknown_sender_domain,reject + +smtpd_recipient_restrictions = reject_unauth_pipelining, + permit_sasl_authenticated, + permit_mynetworks, + reject_non_fqdn_recipient, + reject_unknown_recipient_domain, + reject_unauth_destination +relay_domains = <%= scope.lookupvar('::fqdn') %> diff --git a/templates/radicale/config.erb b/templates/radicale/config.erb new file mode 100644 index 0000000..037378c --- /dev/null +++ b/templates/radicale/config.erb @@ -0,0 +1,97 @@ +# -*- mode: conf -*- +# vim:ft=cfg + +# Config file for Radicale - A simple calendar server +# +# Place it into /etc/radicale/config (global) +# or ~/.config/radicale/config (user) +# +# The commented out values are the defaults. + + +[server] +# CalDAV server hostnames separated by a comma +# IPv4 syntax: address:port +# IPv6 syntax: [address]:port +# IPv6 adresses are configured to only allow IPv6 connections +#hosts = 0.0.0.0:5232 +# Daemon flag +#daemon = False +# File storing the PID in daemon mode +#pid = +# SSL flag, enable HTTPS protocol +#ssl = False +# SSL certificate path +certificate = /etc/ssl/certs/<%= scope.lookupvar('::fqdn') %>.pem +# SSL private key +key = /etc/ssl/private/<%= scope.lookupvar('::fqdn') %>.key +# Reverse DNS to resolve client address in logs +#dns_lookup = True + + +[encoding] +# Encoding for responding requests +#request = utf-8 +# Encoding for storing local collections +#stock = utf-8 + +[acl] +# Access method +# Value: None | htpasswd | LDAP | PAM | courier +type = htpasswd + +# Usernames used for public collections, separated by a comma +public_users = <%= radicale_public_users %> +# Usernames used for private collections, separated by a comma +private_users = <%= radicale_private_users %> + +# Htpasswd filename +htpasswd_filename = /etc/radicale/users +# Htpasswd encryption method +# Value: plain | sha1 | crypt +htpasswd_encryption = crypt + +# LDAP server URL, with protocol and port +#ldap_url = ldap://localhost:389/ +# LDAP base path +#ldap_base = ou=users,dc=example,dC=COm +# LDAP login attribute +#ldap_attribute = uid +# LDAP filter string +# placed as X in a query of the form (&(...)X) +# example: (objectCategory=Person)(objectClass=User)(memberOf=cn=calenderusers,ou=users,dc=example,dc=org) +# leave empty if no additional filter is needed +#ldap_filter = +# LDAP dn for initial login, used if LDAP server does not allow anonymous searches +# Leave empty if searches are anonymous +#ldap_binddn = +# LDAP password for initial login, used with ldap_binddn +#ldap_password = +# LDAP scope of the search +#ldap_scope = OneLevel + +# PAM group user should be member of +#pam_group_membership = + +# Path to the Courier Authdaemon socket +#courier_socket = + +[storage] +# Storage backend +#type = filesystem + +# Folder for storing local collections, created if not present +filesystem_folder = /var/lib/radicale/collections + + +[logging] +# Logging configuration file +# If no config is given, simple information is printed on the standard output +# For more information about the syntax of the configuration file, see: +# http://docs.python.org/library/logging.config.html +#config = /etc/radicale/logging +# Set the default logging level to debug +#debug = False +# Store all environment variables (including those set in the shell) +#full_environment = False + diff --git a/templates/slapd/tls-config.ldif.erb b/templates/slapd/tls-config.ldif.erb new file mode 100644 index 0000000..554f265 --- /dev/null +++ b/templates/slapd/tls-config.ldif.erb @@ -0,0 +1,9 @@ +dn: cn=config +add: olcTLSCACertificateFile +olcTLSCACertificateFile: /etc/ssl/certs/<%= scope.lookupvar('::fqdn') %>-CA.pem +- +add: olcTLSCertificateFile +olcTLSCertificateFile: /etc/ssl/certs/<%= scope.lookupvar('::fqdn') %>.pem +- +add: olcTLSCertificateKeyFile +olcTLSCertificateKeyFile: /etc/ssl/private/<%= scope.lookupvar('::fqdn') %>.key -- 2.39.5