I am in the process extending the capability of the accesslog overlay
to include logging of the client IP address of each request/op. I have
successfully implemented this on 2.3.42. The next step is to optionally
record the IP address of the server fielding the request. I'm
particularly interested which server back-ldap is using to respond to
the request.
The closest I have come to finding the back-end server is li->li_url but
this is just the uri list as config'd in slapd.conf. I'm hoping to find
some assistance in determining the back-end server.
Here is the changes that have been made to
2.3.43/servers/slapd/overlays/accesslog.c:
###BEGIN DIFF###
35d34
< #include "../back-ldap/back-ldap.h"
167c166
< *ad_reqReferral, *ad_reqOld, *ad_reqClient, *ad_reqServer;
---
> *ad_reqReferral, *ad_reqOld;
321,328d319
< { "( " LOG_SCHEMA_AT ".30 NAME 'reqClient' "
< "DESC 'Client Source Address' "
< "SYNTAX OMsDirectoryString "
< "SINGLE-VALUE )", &ad_reqClient },
< { "( " LOG_SCHEMA_AT ".31 NAME 'reqServer' "
< "DESC 'Destination Server Address' "
< "SYNTAX OMsDirectoryString "
< "SINGLE-VALUE )", &ad_reqServer },
345c336
< "reqResult $ reqMessage $ reqReferral $ reqClient $
reqServer) )",
---
> "reqResult $ reqMessage $ reqReferral ) )",
839,863d829
< //jfinn(a)searshc.com: Log Client IP Address/Hostname/URI to "reqClient"
< // attribute.
<
< BerValue clientIP;
< clientIP.bv_val = malloc(255);
< strcpy(clientIP.bv_val,op->o_hdr->oh_conn->c_peer_name.bv_val);
< strtok(clientIP.bv_val, "="); // use strtok to sanitize
the string
< clientIP.bv_val = strtok (NULL, ":"); // IP=x.x.x.x:XXXX ---> x.x.x.x
< clientIP.bv_len = strlen (clientIP.bv_val);
< attr_merge_one( e, ad_reqClient, &clientIP, NULL );
<
< // end Client IP address logging
<
< //jfinn(a)searshc.com: Log Server IP Address/Hostname/URI to "reqServer"
< // attribute for use with back-ldap backend.
< ldapinfo_t *ldap_info = (ldapinfo_t *)op->o_bd->be_private;
< BerValue serverIP;
< serverIP.bv_val = malloc(255);
< // ldap_info->li_uri is just the URI string as config'd in slapd.conf.
< serverIP.bv_val = ldap_info->li_uri;
< serverIP.bv_len = strlen(serverIP.bv_val);
< attr_merge_one( e, ad_reqServer, &serverIP, NULL );
<
< // end Server IP address logging
<
###END DIFF###
Thanks in advance for your assistance!
Jim Finn
This message, including any attachments, is the property of Sears Holdings Corporation and/or one of its subsidiaries. It is confidential and may contain proprietary or legally privileged information. If you are not the intended recipient, please delete it without reading the contents. Thank you.