autofs-5.0.5 - fix paged ldap map read

From: Ian Kent <raven@themaw.net>

With certain LDAP configurations autofs can loop indefinitely
when trying to perform a paged result query to get the map.
---

 CHANGELOG             |    1 +
 modules/lookup_ldap.c |   13 ++++---------
 2 files changed, 5 insertions(+), 9 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index 347d7d7..ec76475 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -62,6 +62,7 @@
 - fix mountd vers retry.
 - fix expire race.
 - replace GPLv3 code.
+- fix paged ldap map read.
 
 03/09/2009 autofs-5.0.5
 -----------------------
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 6ddd30b..1b77e03 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -2349,27 +2349,22 @@ static int read_one_map(struct autofs_point *ap,
 	      MODPREFIX "searching for \"%s\" under \"%s\"", sp.query, ctxt->qdn);
 
 	sp.cookie = NULL;
-	sp.pageSize = 1000;
+	sp.pageSize = 2000;
 	sp.morePages = FALSE;
 	sp.totalCount = 0;
 	sp.result = NULL;
 
 	do {
 		rv = do_paged_query(&sp, ctxt);
-		if (rv == LDAP_SIZELIMIT_EXCEEDED) {
-			debug(ap->logopt, MODPREFIX "result size exceed");
-			if (sp.result)
-				ldap_msgfree(sp.result);
-			continue;
-		}
 
-		if (rv == LDAP_ADMINLIMIT_EXCEEDED) {
+		if (rv == LDAP_ADMINLIMIT_EXCEEDED ||
+		    rv == LDAP_SIZELIMIT_EXCEEDED) {
 			if (sp.result)
 				ldap_msgfree(sp.result);
 			sp.pageSize = sp.pageSize / 2;
 			if (sp.pageSize < 5) {
 				debug(ap->logopt, MODPREFIX
-				      "administrative result size too small");
+				      "result size too small");
 				unbind_ldap_connection(ap->logopt, sp.ldap, ctxt);
 				*result_ldap = rv;
 				free(sp.query);