diff --git a/conf/install_update_dovecot.conf.sample b/conf/install_update_dovecot.conf.sample index eca4c32..dae2108 100644 --- a/conf/install_update_dovecot.conf.sample +++ b/conf/install_update_dovecot.conf.sample @@ -166,6 +166,27 @@ max_userip_connections=24 auth_mechanisms="plain login" +# --- +# - Logging of mail actions (mail_log plugin, Dovecot 2.4+) +# --- +# +# - Logs copy/move, save, expunge, delete and folder create/delete/rename +# - into the dovecot log (file conf.d/95-mail-log.conf). +# - +# - Note: with fields 'from' and 'subject' personal data are written +# - to the log files. +# - +# - mail_log defaults to: true +# - mail_log_events defaults to: +# - "copy save expunge delete undelete mailbox_create mailbox_delete mailbox_rename" +# - mail_log_fields defaults to: +# - "uid box msgid from subject" +# - +#mail_log=true +#mail_log_events="copy save expunge delete undelete mailbox_create mailbox_delete mailbox_rename" +#mail_log_fields="uid box msgid from subject" + + # --- # - Settings for quota warning sript # --- diff --git a/install_update_dovecot-2.4.sh b/install_update_dovecot-2.4.sh index dd6c445..fd0aee5 100755 --- a/install_update_dovecot-2.4.sh +++ b/install_update_dovecot-2.4.sh @@ -1093,6 +1093,10 @@ fi [[ -n "$max_userip_connections" ]] || max_userip_connections=24 [[ -n "$auth_mechanisms" ]] || auth_mechanisms="plain login" +[[ -n "$mail_log" ]] || mail_log=true +[[ -n "$mail_log_events" ]] || mail_log_events="copy save expunge delete undelete mailbox_create mailbox_delete mailbox_rename" +[[ -n "$mail_log_fields" ]] || mail_log_fields="uid box msgid from subject" + [[ -n "$service_limit_nofile" ]] || service_limit_nofile=524280 [[ -n "${vmail_uid}" ]] || vmail_uid=${DEFAULT_VMAIL_UID} @@ -1303,6 +1307,12 @@ echo "" echo -e "\tSpan folder...................: $spam_folder" echo -e "\tMax user connections per ip...: $max_userip_connections" echo "" +echo -e "\tLog mail actions (mail_log)...: $mail_log" +if $mail_log ; then + echo -e "\t mail_log_events............: $mail_log_events" + echo -e "\t mail_log_fields............: $mail_log_fields" +fi +echo "" echo -e "\tAuth Listener (Jabber)........: $xmpp_listener" if $xmpp_listener ; then echo -e "\t Auth Listener Addresses....: $xmpp_listener_addresses" @@ -2337,6 +2347,10 @@ echo "" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} echo "spam_folder=\"${spam_folder}\"" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} echo "max_userip_connections"=${max_userip_connections} >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} +echo "mail_log=${mail_log}" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} +echo "mail_log_events=\"${mail_log_events}\"" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} +echo "mail_log_fields=\"${mail_log_fields}\"" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} + echo "plugin_expire=${plugin_expire}" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} #echo "" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} @@ -9723,6 +9737,62 @@ PYEOF fi # Dovecot 2.4+ quota_clone +## ----------------------------------------------------------------- +## --- mail_log plugin (Dovecot 2.4+) +## --- +## --- Logs mailbox actions (copy/move, save, expunge, delete, folder +## --- create/delete/rename). Helps to answer "where did my mail go?" +## --- (e.g. client rules moving mails into the spam folder). +## --- +## --- Every line carries the prefix imap(); the +## --- session id links it to the imap-login line (rip=, login time). +## ----------------------------------------------------------------- + +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + _conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/95-mail-log.conf" + + if $mail_log ; then + echononl " Create '$(basename "${_conf_file}")' (mail_log plugin).." + cat < "${_conf_file}" 2> "${log_file}" +## +## Logging of mail actions (mail_log plugin) +## +## Generated by $(basename "$0") - change settings in +## conf/$(basename "${conf_file}") (mail_log, mail_log_events, +## mail_log_fields) and rerun the script. +## +## Every line carries the prefix imap() +## -> the session=<...> of the matching imap-login line gives +## client IP (rip=) and login time. +## +## see also: https://doc.dovecot.org/${_version}/core/plugins/mail_log.html +## + +mail_plugins { + notify = yes + mail_log = yes +} + +mail_log_events = ${mail_log_events} +mail_log_fields = ${mail_log_fields} +EOF + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + error "Creating file '${_conf_file}' failed!\n$(cat "${log_file}")" + fi + else + echononl " Create '$(basename "${_conf_file}")' (mail_log plugin).." + rm -f "${_conf_file}" + echo -e "$rc_skipped" + fi + +fi # Dovecot 2.4+ mail_log + + # In order to support extra variable "quota_rule", also userdb's and # passdb's SQL query have to update #