[Dovecot] Executing SQL update upon login
Hi,
I'm using SQL authentication in dovecot, and was wondering if anyone had any ideas as to how I could run an UPDATE statement upon each login, to set time of last login (and other interesting stuff) in the database table.
-- Tom
On Tue, 2006-10-10 at 09:23 +0200, Tom Sommer wrote:
Hi,
I'm using SQL authentication in dovecot, and was wondering if anyone had any ideas as to how I could run an UPDATE statement upon each login, to set time of last login (and other interesting stuff) in the database table.
Set mail_executable to point to a script:
#!/bin/sh
echo "update blah where user = '$USER'" | mysql ..
exec /usr/local/libexec/dovecot/imap
On Tue, October 10, 2006 11:59, Timo Sirainen wrote:
On Tue, 2006-10-10 at 09:23 +0200, Tom Sommer wrote:
Hi,
I'm using SQL authentication in dovecot, and was wondering if anyone had any ideas as to how I could run an UPDATE statement upon each login, to set time of last login (and other interesting stuff) in the database table.
Set mail_executable to point to a script:
#!/bin/sh
echo "update blah where user = '$USER'" | mysql ..
exec /usr/local/libexec/dovecot/imap
Won't the overhead on that be pretty high? Considerings it now has to wrap the imap command in to a script.
// Tom
On Tuesday 10 October 2006 05:51, Tom Sommer wrote:
anyone had any ideas as to how I could run an UPDATE statement upon each login, to set time of last login (and other interesting stuff) in the database table.
Set mail_executable to point to a script:
#!/bin/sh echo "update blah where user = '$USER'" | mysql .. exec /usr/local/libexec/dovecot/imap
Won't the overhead on that be pretty high? Considerings it now has to wrap the imap command in to a script.
I doubt overhead would be much of a problem, since all the shells will use shared memory. The problem I see is that at the time you're running the update, you have not yet authenticated the user, so your data could be unreliable.
Offlist mail to this address is discarded unless
"/dev/rob0" or "not-spam" is in Subject: header
On 10.10.2006, at 16.31, /dev/rob0 wrote:
On Tuesday 10 October 2006 05:51, Tom Sommer wrote:
anyone had any ideas as to how I could run an UPDATE statement upon each login, to set time of last login (and other interesting stuff) in the database table.
Set mail_executable to point to a script:
#!/bin/sh echo "update blah where user = '$USER'" | mysql .. exec /usr/local/libexec/dovecot/imap
Won't the overhead on that be pretty high? Considerings it now has to wrap the imap command in to a script.
I doubt overhead would be much of a problem, since all the shells will use shared memory. The problem I see is that at the time you're
running the update, you have not yet authenticated the user, so your data
could be unreliable.
No, mail_executable is run only after a successful authentication.
On Tue, October 10, 2006 16:02, Timo Sirainen wrote:
On 10.10.2006, at 16.31, /dev/rob0 wrote:
On Tuesday 10 October 2006 05:51, Tom Sommer wrote:
anyone had any ideas as to how I could run an UPDATE statement upon each login, to set time of last login (and other interesting stuff) in the database table.
Set mail_executable to point to a script:
#!/bin/sh echo "update blah where user = '$USER'" | mysql .. exec /usr/local/libexec/dovecot/imap
Won't the overhead on that be pretty high? Considerings it now has to wrap the imap command in to a script.
I doubt overhead would be much of a problem, since all the shells will use shared memory. The problem I see is that at the time you're running the update, you have not yet authenticated the user, so your data could be unreliable.
No, mail_executable is run only after a successful authentication.
Would it not be better to add a on_login_query which allowed access to a list of variables, IP address, username, password etc.
on_login_query = UPDATE users SET last_login = NOW(), last_ip = %i WHERE user = %u
On Tue, 2006-10-10 at 16:44 +0200, Tom Sommer wrote:
Would it not be better to add a on_login_query which allowed access to a list of variables, IP address, username, password etc.
on_login_query = UPDATE users SET last_login = NOW(), last_ip = %i WHERE user = %u
Maybe, since so many people have already asked for this. Patches welcome ;)
* On 10/10/06 19:54 +0300, Timo Sirainen wrote: | On Tue, 2006-10-10 at 16:44 +0200, Tom Sommer wrote: | > Would it not be better to add a on_login_query which allowed access to a | > list of variables, IP address, username, password etc. | > | > on_login_query = UPDATE users SET last_login = NOW(), last_ip = %i WHERE | > user = %u | | Maybe, since so many people have already asked for this. Patches | welcome ;) Code to do this kind of thing is available in tpop3d (another great POP3 server), only that I don't know no C, and hence how to "borrow" it from there ;) -Wash http://www.netmeister.org/news/learn2quote.html DISCLAIMER: See http://www.wananchi.com/bms/terms.php -- +======================================================================+ |\ _,,,---,,_ | Odhiambo Washington <wash@wananchi.com> Zzz /,`.-'`' -. ;-;;,_ | Wananchi Online Ltd. www.wananchi.com |,4- ) )-,_. ,\ ( `'-'| Tel: +254 20 313985-9 +254 20 313922 '---''(_/--' `-'\_) | GSM: +254 722 743223 +254 733 744121 +======================================================================+ Equal bytes for women.
On Tuesday 10 October 2006 09:02, Timo Sirainen wrote:
will use shared memory. The problem I see is that at the time you're running the update, you have not yet authenticated the user, so your data could be unreliable.
No, mail_executable is run only after a successful authentication.
Oops, sorry.
Offlist mail to this address is discarded unless
"/dev/rob0" or "not-spam" is in Subject: header
participants (4)
-
/dev/rob0
-
Odhiambo WASHINGTON
-
Timo Sirainen
-
Tom Sommer