diff options
author | Rich Megginson <rmeggins@redhat.com> | 2010-03-01 15:03:30 -0700 |
---|---|---|
committer | Rich Megginson <rmeggins@redhat.com> | 2010-03-01 18:45:50 -0700 |
commit | 142900b2757378bfbff34e3f390fcb1a292eea91 (patch) | |
tree | 77f675339d01cae94cdc7374a2cdb8af22b01de2 | |
parent | 9aec0f110d8238de66ebbf2f6eb71cb363220c40 (diff) | |
download | ds-142900b2757378bfbff34e3f390fcb1a292eea91.tar.gz ds-142900b2757378bfbff34e3f390fcb1a292eea91.tar.xz ds-142900b2757378bfbff34e3f390fcb1a292eea91.zip |
Bug 551198 - LDAPI: incorrect logging to access log389-ds-base-1.2.6.a2
https://bugzilla.redhat.com/show_bug.cgi?id=551198
Resolves: bug 551198
Bug Description: LDAPI: incorrect logging to access log
Reviewed by: nkinder (Thanks!)
Branch: HEAD
Fix Description: The connection logging code was not ldapi/unix socket
aware. Now we check for the socket type, and check to see if there is
a proper path name in the path field. The "server" side of the socket
seems not to get the path name set correctly - not sure why, but it doesn't
really matter, since the client side path name does seem to be set
correctly. The access log will contain the server side path and the client
side path, so something like "from local to /var/run/slapd-foo.socket"
Platforms tested: RHEL5 x86_64, Fedora 11 x86_64
Flag Day: no
Doc impact: no
-rw-r--r-- | ldap/servers/slapd/connection.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c index 5c8decbe..8686d16e 100644 --- a/ldap/servers/slapd/connection.c +++ b/ldap/servers/slapd/connection.c @@ -242,7 +242,22 @@ connection_reset(Connection* conn, int ns, PRNetAddr * from, int fromLen, int is * get peer address (IP address of this client) */ slapi_ch_free( (void**)&conn->cin_addr ); /* just to be conservative */ - if ( ((from->ipv6.ip.pr_s6_addr32[0] != 0) || /* from contains non zeros */ + if ( from->raw.family == PR_AF_LOCAL ) { /* ldapi */ + conn->cin_addr = (PRNetAddr *) slapi_ch_malloc( sizeof( PRNetAddr ) ); + PL_strncpyz(buf_ip, from->local.path, sizeof(from->local.path)); + memcpy( conn->cin_addr, from, sizeof( PRNetAddr ) ); + if (!buf_ip[0]) { + PR_GetPeerName( conn->c_prfd, from ); + PL_strncpyz(buf_ip, from->local.path, sizeof(from->local.path)); + memcpy( conn->cin_addr, from, sizeof( PRNetAddr ) ); + } + if (!buf_ip[0]) { + /* cannot derive local address */ + /* need something for logging */ + PL_strncpyz(buf_ip, "local", sizeof(buf_ip)); + } + str_ip = buf_ip; + } else if ( ((from->ipv6.ip.pr_s6_addr32[0] != 0) || /* from contains non zeros */ (from->ipv6.ip.pr_s6_addr32[1] != 0) || (from->ipv6.ip.pr_s6_addr32[2] != 0) || (from->ipv6.ip.pr_s6_addr32[3] != 0)) || @@ -261,7 +276,6 @@ connection_reset(Connection* conn, int ns, PRNetAddr * from, int fromLen, int is } buf_ip[ sizeof( buf_ip ) - 1 ] = '\0'; str_ip = buf_ip; - } else { /* try syscall since "from" was not given and PR_GetPeerName failed */ /* a corner case */ @@ -307,7 +321,13 @@ connection_reset(Connection* conn, int ns, PRNetAddr * from, int fromLen, int is conn->cin_destaddr = (PRNetAddr *) slapi_ch_malloc( sizeof( PRNetAddr ) ); memset( conn->cin_destaddr, 0, sizeof( PRNetAddr )); if (PR_GetSockName( conn->c_prfd, conn->cin_destaddr ) == 0) { - if ( PR_IsNetAddrType( conn->cin_destaddr, PR_IpAddrV4Mapped ) ) { + if ( conn->cin_destaddr->raw.family == PR_AF_LOCAL ) { /* ldapi */ + PL_strncpyz(buf_destip, conn->cin_destaddr->local.path, + sizeof(conn->cin_destaddr->local.path)); + if (!buf_destip[0]) { + PL_strncpyz(buf_destip, "unknown local file", sizeof(buf_destip)); + } + } else if ( PR_IsNetAddrType( conn->cin_destaddr, PR_IpAddrV4Mapped ) ) { PRNetAddr v4destaddr; memset( &v4destaddr, 0, sizeof( v4destaddr ) ); v4destaddr.inet.family = PR_AF_INET; |