In short I am trying to run a bash script which will then update a mysql database with the last login date/time & last IP for each mailbox.

If i remove the modifications that cause the script to execute the user/mailbox authenticates no problem, but the moment I try to invoke the script authentication starts failing.

I have searched google dead but still cant figure out what im doing wrong or if there is some issue with the centos 6 rpm's for dovecot.

my setup in 10-master.conf looks like the following:

service imap-postlogin {  
    executable = script-login /var/www/lighttpd/mail-admin/scripts/lastLogin.sh  
    unix_listener imap-postlogin {  
         user = root 
service imap {
        executable = imap imap-postlogin

My lastLogin.sh bash script has the following in it for debugging
echo "$(date +%Y.%m.%d-%H:%M:%S)";
echo "User: ${USER}" >> /tmp/tracking.log 2>&1;
echo "Home: ${HOME}" >> /tmp/tracking.log 2>&1;
echo "Client IP: ${IP}" >> /tmp/tracking.log 2>&1;
echo "Server IP: ${LOCAL_IP}" >> /tmp/tracking.log 2>&1;

The output to my /tmp/tracker.log is the following
User: user@domain.com
Home: /var/spool/mail/domain.com/user
Client IP: x.x.x.x
Server IP: y.y.y.y

The Authentication Error I am getting now
Feb 3 15:23:35 vps dovecot: script-login: Fatal: read() failed: Interrupted system call
Feb 3 15:23:35 vps dovecot: imap-login: Error: read(imap) failed: Remote closed connection (process_limit reached?)
Feb 3 15:23:35 vps dovecot: auth: Debug: client in: CANCEL#0111
Feb 3 15:23:35 vps dovecot: imap-login: Internal login failure (pid=20102 id=1) (internal failure, 1 successful auths): user=, method=PLAIN, rip=x.x.x.x, lip=y.y.y.y.y, TLS, session=

At the moment for testing the script lastLogin.sh looks like below
echo "$(date +%Y.%m.%d-%H:%M:%S)";
echo "User: ${USER}" >> /tmp/tracking.log 2>&1;
echo "Password: ${PASS}" >> /tmp/tracking.log 2>&1;
echo "Home: ${HOME}" >> /tmp/tracking.log 2>&1;
echo "Client IP: ${IP}" >> /tmp/tracking.log 2>&1;
echo "Server IP: ${LOCAL_IP}" >> /tmp/tracking.log 2>&1;
echo "Secured: ${SECURED}" >> /tmp/tracking.log 2>&1;
echo "1: ${1}" >> /tmp/tracking.log 2>&1;
echo "2: ${2}" >> /tmp/tracking.log 2>&1;
echo "at: ${@}" >> /tmp/tracking.log 2>&1;
echo "star $*" >> /tmp/tracking.log 2>&1;
exec "$@";

  • Where is the error exactly? – NickW Feb 3 '14 at 12:19
  • soz copy spazzed out originally, edited it now – Sayajin Feb 3 '14 at 13:27
  • What happens if you move user=root before unix-listener, and out of the imap-postlogin{} ? – NickW Feb 3 '14 at 13:45
  • does your script end with exec "$@" ? – Gryphius Feb 3 '14 at 13:49
  • 1
    If you set the script to do something much more simple? Just echo "hi" to your log maybe? I really can't see much else that you have done wrong dovecot wise.. – NickW Feb 4 '14 at 15:31

Ok seems that it is working now, what appeared to have been messing it up was the redirections at the end of the logging 2>&1. After removing that it all seems to be working 100%.

@NickW Thanks for the help and a pair of fresh eye's :)

| improve this answer | |
  • Glad I could help! – NickW Feb 5 '14 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.