diff --git a/.gitattributes b/.gitattributes index d594a12f..0a74b708 100644 --- a/.gitattributes +++ b/.gitattributes @@ -583,6 +583,7 @@ src/functions_dns.sh -text src/functions_hosting.sh -text src/mem_add -text src/mem_del -text +src/popimap-log-login.sh -text src/quota-warning.sh -text src/quota_delete -text src/quota_edit -text diff --git a/etc/alternc/templates/dovecot/dovecot.conf b/etc/alternc/templates/dovecot/dovecot.conf index ad6b9911..9adfca5c 100644 --- a/etc/alternc/templates/dovecot/dovecot.conf +++ b/etc/alternc/templates/dovecot/dovecot.conf @@ -564,7 +564,7 @@ protocol imap { # /tmp/gdbhelper.* files: # mail_executable = /usr/lib/dovecot/gdbhelper /usr/lib/dovecot/imap # - #mail_executable = /usr/lib/dovecot/imap + mail_executable = /usr/lib/alternc/popimap-log-login.sh /usr/lib/dovecot/imap # Maximum IMAP command line length in bytes. Some clients generate very long # command lines with huge mailboxes, so you may need to raise this if you get @@ -633,7 +633,7 @@ protocol pop3 { # POP3 executable location. See IMAP's mail_executable above for examples # how this could be changed. - #mail_executable = /usr/lib/dovecot/pop3 + mail_executable = /usr/lib/alternc/popimap-log-login.sh /usr/lib/dovecot/pop3 # Don't try to set mails non-recent or seen with POP3 sessions. This is # mostly intended to reduce disk I/O. With maildir it doesn't move files diff --git a/src/popimap-log-login.sh b/src/popimap-log-login.sh new file mode 100755 index 00000000..d134449a --- /dev/null +++ b/src/popimap-log-login.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Script called by Dovecot when an user log in +# Log that the user just log in + +# /!\ Script is launched by dovecot with root permissions /!\ + +# Do not use parameters, Dovecot give environnment vars +# The only parameters is the expected binary server + +CONFIG_FILE="/usr/lib/alternc/functions.sh" +if [ ! -r "$CONFIG_FILE" ]; then + echo "Can't access $CONFIG_FILE." + exit 1 +fi +. "$CONFIG_FILE" + +mysql_query "update address a, domaines d, mailbox m set m.lastlogin=now() where a.domain_id=d.id and m.address_id=a.id and concat_ws('@',a.address,d.domaine) = '$USER';" + +# Now launch the expected binary server +exec "$@"