You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Chris Heinze <x...@reg.x.nu> on 1997/09/10 18:40:05 UTC

other/1113: log hostname AND ip, log user for dynamic ip-accounting

>Number:         1113
>Category:       other
>Synopsis:       log hostname AND ip, log user for dynamic ip-accounting
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache (Apache HTTP Project)
>State:          open
>Class:          change-request
>Submitter-Id:   apache
>Arrival-Date:   Wed Sep 10 09:40:01 1997
>Originator:     x@x.nu
>Organization:
apache
>Release:        1.2.4
>Environment:
Linux 2.0.30 i486 GCC 2.7.2.1, but that's not interesting. :)
>Description:
it's yet not possible to log both hostname and ip of requesting host. but this
is sometimes needed (e.g. i need it ;). it would be best if there were another
tag in customlogformat for the pure ip-address, even if hostname can be and is
resolved (e.g. %a, as shown below).

another very helpful feature would be if apache could read the corresponding
username for the requesting ip from a file, like net-acct does. that is:
if a user has his ppp-connection up and his dynamic ip-address assigned, the
pppd (ip-up) writes his username to a file /var/run/<user's_ip-address>.
net-acct is an accounting tool that logs all ip-traffic. if it logs traffic
with an ip-address that has the according file in /var/run, it puts the name
in this file into the log, too.
with a similar feature in customlogformat (let's say %c) it would be possible
to account proxy-traffic for users with dynamic ips very easily.

i've been able to patch the first part (hostname and ip - big deal :) ) myself
(see below), but in fact i don't really speak c, so i don't beleive i'm able
to implement the second part (ip->username)... i hope somebody thinks this is
a good idea and hacks a little patch to implement this in future releases... :)
>How-To-Repeat:

>Fix:
sure, patched it:

http_core.h: insert a line 80: #define REMOTE_IP (4)

http_core.c: line 382-388, include in:
    if (type == REMOTE_IP)
    {
        return conn->remote_ip;
    }
    else
    {
        if (conn->remote_host != NULL && conn->remote_host[0] != '\0')
            return conn->remote_host;
        else
        {
            if (type == REMOTE_HOST) return NULL;
            else return conn->remote_ip;
        }
    }

mod_log_config.c: insert a line 356: { 'a', log_remote_ip, 0 },
and under log_remote_host insert:
char *log_remote_ip (request_rec *r, char *a)
{ return (char *)get_remote_host(r->connection, r->per_dir_config, REMOTE_IP); }
%0
>Audit-Trail:
>Unformatted: