You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Cyril Bouthors <cy...@bouthors.org> on 2004/02/13 02:51:32 UTC
Adding user log feature to mod_accounting
Simone,
First of all, thank you for making mod_accounting, it's a very useful
module.
I'm trying to add user log feature to mod_accounting (the one
configured by the "User" Apache directive) in order do get accounting
by user and not by vhost, we have many vhosts by user/client.
Here's a sample configuration:
<VirtualHost *>
ServerName www.drumcorpsnet.com
User drumcorpsnet
Group users
(...)
</VirtualHost>
I'm using User directive for suexec + php and I'd like mod_accounting
to use it to "UPDATE ... WHERE user='drumcorpsnet'". Each user has
more than one virtualhost.
I've made patch inspired by src/main/util_script.c:
libapache-mod-acct-0.5$ diff mod_accounting.c{.00,}
28a29,30
> #include <pwd.h>
> #include <sys/types.h>
419a422,424
> char *httpuser; // ="nobody";
> struct passwd *pw;
>
439a445,452
> case 'U':
> /* inspired from src/main/util_script.c */
> if ((pw = getpwuid(r->server->server_uid)) != NULL) {
> httpuser = ap_pstrdup(r->pool, pw->pw_name);
> query = ap_pstrcat( p, query, ptr, httpuser, NULL );
> }
> break;
>
httpuser is set, MySQL is successfully updated:
233 Query UPDATE user SET byte_total=byte_total+78+3946, hit_total=hit_total+1 WHERE user='www-data'
Everything is working for a few hits but after that, Apache keeps on
making segfaults. It can be easily reproduced with "ab -c500 -n2000":
[Fri Feb 13 02:07:36 2004] [notice] child pid 12536 exit signal Segmentation fault (11)
[Fri Feb 13 02:07:36 2004] [notice] child pid 12535 exit signal Segmentation fault (11)
(...)
Do you have any idea where the bug should come from? The code is
coming almost straight from src/main/util_script.c but I really can't
see a bug, I'm not used to Apache nor multiprocesses environments...
Thank you for your time,
--
Cyril Bouthors