[Dovecot] Preforming an action/trigger after a user successfully authenticates
Hi -
I have searched the docs for v1.0 RC7, but cannot find what I'm looking for.
What I'm ultimately wanting to do is have Dovecot preform some action, or a trigger, when the user is successfully authenticated. Even more specifically, I'd like to run another SQL query to record a date/time for last authenticated login.
Short from running a script during logrotate, or constantly tailing the log, is there any mechanism in Dovecot that would allow me to do this? Again, all I'm looking to do is to record the last date/time that someone successfully logged in, into a MySQL database.
Thanks! -dant
On Mon, 2006-09-25 at 12:55 -0700, Dan Trainor wrote:
Hi -
I have searched the docs for v1.0 RC7, but cannot find what I'm looking for.
What I'm ultimately wanting to do is have Dovecot preform some action, or a trigger, when the user is successfully authenticated. Even more specifically, I'd like to run another SQL query to record a date/time for last authenticated login.
Short from running a script during logrotate, or constantly tailing the log, is there any mechanism in Dovecot that would allow me to do this? Again, all I'm looking to do is to record the last date/time that someone successfully logged in, into a MySQL database.
Change mail_executable to point to a script containing something like:
#!/bin/sh
echo "update table ..." | mysql exec /usr/libexec/dovecot/imap/imap
And same for pop3 if you use that.
On Mon, Sep 25, 2006 at 12:55:31PM -0700, Dan Trainor wrote:
What I'm ultimately wanting to do is have Dovecot preform some action, or a trigger, when the user is successfully authenticated. Even more specifically, I'd like to run another SQL query to record a date/time for last authenticated login.
At least in PostgreSQL, you can define TRIGGERs on the SELECT's themselves. Of course you still don't know whether the login was successful, but this way you could log every login _attempt_ automatically.
Grrty
Geert Hendrickx wrote:
On Mon, Sep 25, 2006 at 12:55:31PM -0700, Dan Trainor wrote:
What I'm ultimately wanting to do is have Dovecot preform some action, or a trigger, when the user is successfully authenticated. Even more specifically, I'd like to run another SQL query to record a date/time for last authenticated login.
At least in PostgreSQL, you can define TRIGGERs on the SELECT's themselves. Of course you still don't know whether the login was successful, but this way you could log every login _attempt_ automatically.
Grrty
Hi, Geert -
I think that Timo Siarainen hit the nail in the head there with the mail_executable comment - but I can't find any documentation that says mail_executable is actually ran depending on if the authentication was successfull. I guess in order to know this, it would have to be assumed that the daemons (pop, imap, etc etc) are only ran after authentication is verified. I guess this makes sense, but I have not been able to find documentation regarding this matter.
I'm really interested in mail_executable, and think that it might work for my purposes. But I need to pass at least one piece of identifiable data to this command, which will then run my script, so that I can key my action with said user account, which is stored in SQL.
I found a script on the bottom of:
http://wiki.dovecot.org/PopBSMTPAndDovecot
...which is kindof the way I want this to work. However, I need to pass that one piece of identifiable data, i.e. a user@domain.tld variable, in order to play with SQL some more.
With that being said, anyone know how that might be posssible?
Thanks! -dant
On 25.9.2006, at 23.47, Dan Trainor wrote:
I think that Timo Siarainen hit the nail in the head there with the
mail_executable comment - but I can't find any documentation that
says mail_executable is actually ran depending on if the
authentication was successfull. I guess in order to know this, it
would have to be assumed that the daemons (pop, imap, etc etc) are
only ran after authentication is verified. I guess this makes
sense, but I have not been able to find documentation regarding
this matter.
It's run only after user has authenticated successfully.
...which is kindof the way I want this to work. However, I need to
pass that one piece of identifiable data, i.e. a user@domain.tld
variable, in order to play with SQL some more.With that being said, anyone know how that might be posssible?
It's in $USER environment.
Timo Sirainen wrote:
On 25.9.2006, at 23.47, Dan Trainor wrote:
I think that Timo Siarainen hit the nail in the head there with the mail_executable comment - but I can't find any documentation that says mail_executable is actually ran depending on if the authentication was successfull. I guess in order to know this, it would have to be assumed that the daemons (pop, imap, etc etc) are only ran after authentication is verified. I guess this makes sense, but I have not been able to find documentation regarding this matter.
It's run only after user has authenticated successfully.
...which is kindof the way I want this to work. However, I need to pass that one piece of identifiable data, i.e. a user@domain.tld variable, in order to play with SQL some more.
With that being said, anyone know how that might be posssible?
It's in $USER environment.
Hi, Timo -
Thanks again for the info.
Do you know where I might be able to find a list of variables which are available to me in this manner? Is this Dovecot-specific stuff, or is it shell-specific variables? I'm a bit confused as to where to draw the line.
Thanks! -dant
On 26.9.2006, at 0.07, Dan Trainor wrote:
...which is kindof the way I want this to work. However, I need
to pass that one piece of identifiable data, i.e. a
user@domain.tld variable, in order to play with SQL some more.With that being said, anyone know how that might be posssible? It's in $USER environment.
Hi, Timo -
Thanks again for the info.
Do you know where I might be able to find a list of variables which
are available to me in this manner? Is this Dovecot-specific
stuff, or is it shell-specific variables? I'm a bit confused as to
where to draw the line.
Dovecot creates all the environment variables that the shell sees.
Dovecot master process passes all the configuration and the user-
specific data in environment variables to the mail processes. Easiest
way to get a list of what is available is to just add to the mail
executable script:
set > /tmp/dovecot.envs
Timo Sirainen wrote:
On 26.9.2006, at 0.07, Dan Trainor wrote:
...which is kindof the way I want this to work. However, I need to pass that one piece of identifiable data, i.e. a user@domain.tld variable, in order to play with SQL some more.
With that being said, anyone know how that might be posssible? It's in $USER environment.
Hi, Timo -
Thanks again for the info.
Do you know where I might be able to find a list of variables which are available to me in this manner? Is this Dovecot-specific stuff, or is it shell-specific variables? I'm a bit confused as to where to draw the line.
Dovecot creates all the environment variables that the shell sees. Dovecot master process passes all the configuration and the user-specific data in environment variables to the mail processes. Easiest way to get a list of what is available is to just add to the mail executable script:
set > /tmp/dovecot.envs
Hi -
Awesome, exactly what I was looking for.
Expect to see my results on the Wiki within the hour. I think this is kindof exciting.
Thanks! -dant
participants (3)
-
Dan Trainor
-
Geert Hendrickx
-
Timo Sirainen