Skip to contentSkip to conversation

Fix for ldap_search when multiple cn's are in one LDAP entry.

PATCH In review Chris Feist 2 participants 2 messages Dec 10, 2004 – Jan 6, 2005 Kernel automounter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix for ldap_search when multiple cn's are in one LDAP entry.

This patch fixes a bug in the ldap search which will only use the first mount point found in an LDAP entry.

For example if an ldap entry looks like this:

dn: cn=%T%I_apps, nisMapName=auto_home, ou=foo.bar
nismapname: auto_home
objectClass: top
objectClass: nisobject
nismapentry: foo.bar.ti.com:/vol/vol6/TI_apps
cn: %T%I_apps
cn: TI_apps

Then the auto_home map will only be used in /%T%I_apps

If you try to cd into TI_apps you'll just get an error. The patch forces ldap_search to iterate through all of the different cn's in an entry so you can cd into either %T%I_apps or TI_apps and the proper directory will still be automounted.

Thanks,
Chris

modules/lookup_ldap.c renamed from modules/lookup_ldap.c.orig +8 -4
@@ -154,7 +154,7 @@
 			struct lookup_context *context)
 {
 	struct lookup_context *ctxt = (struct lookup_context *) context;
-	int rv, i, l, count;
+	int rv, i, j, l, count, keycount;
 	time_t age = time(NULL);
 	char *query;
 	LDAPMessage *result, *e;
@@ -250,10 +250,14 @@
 		}
 
 		count = ldap_count_values(values);
+		keycount = ldap_count_values(keyValue);
 		for (i = 0; i < count; i++) {
-			if (**keyValue == '/' && strlen(*keyValue) == 1)
-				**keyValue = '*';
-			cache_update(*keyValue, values[i], age);
+		  	for (j = 0; j < keycount; j++) {
+				if (*(keyValue[j]) == '/' &&
+				    strlen(keyValue[j]) == 1)
+			  		*(keyValue[j]) = '*';
+				cache_update(keyValue[j], values[i], age);
+			}
 		}
 		ldap_value_free(values);
 

_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs

maintainer
#1 lore raw
Quoted 13 lines · Chris Feist

This patch fixes a bug in the ldap search which will only use the first mount point found in an LDAP entry.

For example if an ldap entry looks like this:

dn: cn=%T%I_apps, nisMapName=auto_home, ou=foo.bar
nismapname: auto_home
objectClass: top
objectClass: nisobject
nismapentry: foo.bar.ti.com:/vol/vol6/TI_apps
cn: %T%I_apps
cn: TI_apps

Quoted 1 line

Then the auto_home map will only be used in /%T%I_apps

But the key is unique by definition.

I'll add this patch but I'm not sure it's correct wrt autofs map definition.

Comments?

Ian