Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
#!/bin/sh
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 at 12:19
    
soz copy spazzed out originally, edited it now –  Sayajin Feb 3 at 13:27
    
What happens if you move user=root before unix-listener, and out of the imap-postlogin{} ? –  NickW Feb 3 at 13:45
    
does your script end with exec "$@" ? –  Gryphius Feb 3 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 at 15:31

1 Answer 1

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 at 14:30

Your Answer

 
discard

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.