Thomas Foerster wrote:
>
> Hi there,
>
> i've modified vpopmail-4.9.8 do make vchkpw to log the last POP-Access for a user.
>
> It logs
> * Username
> * Domainname
> * Date+Time
> * IP-Address
> * Resolved IP (if available)
>
> Just compile vpopmail with mysql support , add --enable-logging=y and create the
>following table
> in the vpopmail-database :
>
> CREATE TABLE lastauth (
> user varchar(200) NOT NULL,
> domain varchar(255) NOT NULL,
> timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
> ip varchar(15) NOT NULL,
> host varchar(255) NOT NULL,
> PRIMARY KEY (user, domain),
> KEY user (user, domain)
> );
>
> It's maybe not the best way to do it, but it realy works great here at a local ISP
> (about 600 Domains).
>
> Just replace the vchkpw.c from the vpopmail-source with the attached one.
>
> I hope that this patch *will* be added to the official vpopmail-distribution (e.g.
>with
> a configure option)
Done.
It is available in the new developement release
http://www.inter7.com/vpopmail/vpopmail-4.9.9.tar.gz or
http://www.vpopmail.cx/vpopmail-4.9.9.tar.gz
New option
--enable-auth-logging=y
It is turned off by default.
I changed the table definition
create table authlog (
user char(32) NOT NULL,
domain varchar(223) NOT NULL
remote_ip char(18) not null,
timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
unique index (user, domain) )
I removed the host value, since the REMOTEHOST environment variable
is not set if tcpserver -H option is on. (I like -H).
I also added a unique index on user and domain. This is so we can
use the mysql "replace" function.
I've added a new function
int vlogauth( char *user, char *domain, char *remoteip);
Which will automatically create the table if it doesn't exist,
and uses the "replace" function.
sprintf( SqlBuf,
"replace into lastauth set user='%s', domain='%s', \
remote_ip='%s', timestamp=NOW()", user, domain, remoteip);
I did a quick test on my machine and it seems to be working.
Ken