$OpenBSD: patch-apache1_mod_security_c,v 1.1 2008/05/09 08:28:34 mbalmer Exp $ --- apache1/mod_security.c.orig Wed Dec 5 12:04:19 2007 +++ apache1/mod_security.c Wed Dec 5 12:14:37 2007 @@ -6121,7 +6121,9 @@ void sec_auditlog_init(modsec_rec *msr) { char *uniqueid, *entry_filename, *entry_basename, *text; const array_header *arr = NULL; table_entry *te = NULL; - int i; + char sbuf[NI_MAXSERV]; + u_int16_t localport, remoteport; + int error, i; sec_debug_log(r, 4, "sec_auditlog_init: Starting"); @@ -6189,9 +6191,24 @@ void sec_auditlog_init(modsec_rec *msr) { /* Format: time transaction_id remote_addr remote_port local_addr local_port */ + error = getnameinfo((struct sockaddr *)&r->connection->remote_addr, + r->connection->remote_addr.ss_len, NULL, 0, sbuf, sizeof(sbuf), + NI_NUMERICSERV); + if (error) + remoteport = 0; + else + remoteport = atol(sbuf); + error = getnameinfo((struct sockaddr *)&r->connection->local_addr, + r->connection->local_addr.ss_len, NULL, 0, sbuf, sizeof(sbuf), + NI_NUMERICSERV); + if (error) + localport = 0; + else + localport = atol(sbuf); + text = ap_psprintf(r->pool, "[%s] %s %s %i %s %i", - current_logtime(r), uniqueid, r->connection->remote_ip, r->connection->remote_addr.sin_port, - r->connection->local_ip, r->connection->local_addr.sin_port); + current_logtime(r), uniqueid, r->connection->remote_ip, remoteport, + r->connection->local_ip, localport); sec_auditlog_write(msr, text, strlen(text));