Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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/  
    unix_listener imap-postlogin {  
         user = root 
service imap {
        executable = imap imap-postlogin

My 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
Home: /var/spool/mail/
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 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 "$@";

share|improve this question
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
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
up vote 1 down vote accepted

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 :)

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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