summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2012-02-29 21:44:31 +0000
committerArthur de Jong <arthur@arthurdejong.org>2012-02-29 21:44:31 +0000
commitb38f1d04a4543a6c2a85583d70e6e443db1d9917 (patch)
treed6978513654a4a9e275502cb844af240ce0549ee
parent4e00bb707dcc04ed05ec6e965f02a36a3b481f64 (diff)
log the first 10 search results in debug mode to make debugging easier (patch by Matthijs Kooijman)
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1625 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--nslcd/myldap.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/nslcd/myldap.c b/nslcd/myldap.c
index 8342c64..70d5c0b 100644
--- a/nslcd/myldap.c
+++ b/nslcd/myldap.c
@@ -75,6 +75,9 @@
/* the maximum number of searches per session */
#define MAX_SEARCHES_IN_SESSION 4
+/* the maximum number of dn's to log to the debug log for each search */
+#define MAX_DEBUG_LOG_DNS 10
+
/* This refers to a current LDAP session that contains the connection
information. */
struct ldap_session
@@ -116,6 +119,8 @@ struct myldap_search
struct berval *cookie;
/* to indicate that we can retry the search from myldap_get_entry() */
int may_retry_search;
+ /* the number of resutls returned so far */
+ int count;
};
/* The maximum number of calls to myldap_get_values() that may be
@@ -249,6 +254,7 @@ static MYLDAP_SEARCH *myldap_search_new(
search->may_retry_search=1;
/* clear result entry */
search->entry=NULL;
+ search->count=0;
/* return the new search struct */
return search;
}
@@ -1116,6 +1122,11 @@ MYLDAP_ENTRY *myldap_get_entry(MYLDAP_SEARCH *search,int *rcp)
search->entry=myldap_entry_new(search);
if (rcp!=NULL)
*rcp=LDAP_SUCCESS;
+ /* log the first couple of dns in the result (but not all, to
+ prevent swamping the log) */
+ if (search->count<MAX_DEBUG_LOG_DNS)
+ log_log(LOG_DEBUG,"ldap_result(): %s",myldap_get_dn(search->entry));
+ search->count++;
search->may_retry_search=0;
return search->entry;
case LDAP_RES_SEARCH_RESULT:
@@ -1178,7 +1189,11 @@ MYLDAP_ENTRY *myldap_get_entry(MYLDAP_SEARCH *search,int *rcp)
/* check if there are more pages to come */
if ((search->cookie==NULL)||(search->cookie->bv_len==0))
{
- log_log(LOG_DEBUG,"ldap_result(): end of results");
+ if (search->count>MAX_DEBUG_LOG_DNS)
+ log_log(LOG_DEBUG,"ldap_result(): ... %d more results",
+ search->count-MAX_DEBUG_LOG_DNS);
+ log_log(LOG_DEBUG,"ldap_result(): end of results (%d total)",
+ search->count);
/* we are at the end of the search, no more results */
myldap_search_close(search);
if (rcp!=NULL)