[Fedora-directory-commits] ldapserver/ldap/servers/slapd charray.c, 1.4, 1.5 saslbind.c, 1.18, 1.19 slapi-private.h, 1.11, 1.12

Nathan Kinder (nkinder) fedora-directory-commits at redhat.com
Tue Nov 7 04:42:58 UTC 2006


Author: nkinder

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv13155/ldap/servers/slapd

Modified Files:
	charray.c saslbind.c slapi-private.h 
Log Message:
Related: 214238
Summary: Make fallback SASL path work for 64-bit Linux default location.



Index: charray.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/charray.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- charray.c	19 Apr 2005 22:07:36 -0000	1.4
+++ charray.c	7 Nov 2006 04:42:55 -0000	1.5
@@ -270,9 +270,20 @@
 char **
 str2charray( char *str, char *brkstr )
 {
+    return( str2charray_ext( str, brkstr, 1 ));
+}
+
+/*
+ * extended version of str2charray lets you disallow
+ * duplicate values into the array.
+ */
+char **
+str2charray_ext( char *str, char *brkstr, int allow_dups )
+{
     char    **res;
     char    *s;
-    int    i;
+    int    i, j;
+    int dup_found = 0;
     char * iter = NULL;
 
     i = 1;
@@ -284,9 +295,22 @@
 
     res = (char **) slapi_ch_malloc( (i + 1) * sizeof(char *) );
     i = 0;
-    for ( s = ldap_utf8strtok_r( str, brkstr , &iter); s != NULL; 
+    for ( s = ldap_utf8strtok_r( str, brkstr , &iter); s != NULL;
             s = ldap_utf8strtok_r( NULL, brkstr , &iter) ) {
-        res[i++] = slapi_ch_strdup( s );
+        dup_found = 0;
+        /* Always copy the first value into the array */
+        if ( (!allow_dups) && (i != 0) ) {
+            /* Check for duplicates */
+            for ( j = 0; j < i; j++ ) {
+                if ( strncmp( res[j], s, strlen( s ) ) == 0 ) {
+                    dup_found = 1;
+                    break;
+                }
+            }
+        }
+
+        if ( !dup_found )
+            res[i++] = slapi_ch_strdup( s );
     }
     res[i] = NULL;
 


Index: saslbind.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/saslbind.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- saslbind.c	6 Nov 2006 19:33:42 -0000	1.18
+++ saslbind.c	7 Nov 2006 04:42:55 -0000	1.19
@@ -560,7 +560,7 @@
     char *pluginpath = config_get_saslpath();
     if ((!pluginpath) || (*pluginpath == '\0')) {
         if (!(pluginpath = getenv("SASL_PATH"))) {
-            pluginpath = "/usr/lib/sasl2";
+            pluginpath = "/usr/lib64/sasl2:/usr/lib/sasl2";
         }
     }
     *path = pluginpath;
@@ -744,7 +744,7 @@
         LDAPDebug(LDAP_DEBUG_TRACE, "sasl library mechs: %s\n", str, 0, 0);
         /* merge into result set */
         dupstr = slapi_ch_strdup(str);
-        others = str2charray(dupstr, ",");
+        others = str2charray_ext(dupstr, ",", 0 /* don't list duplicate mechanisms */);
         charray_merge(&ret, others, 1);
         charray_free(others);
         slapi_ch_free((void**)&dupstr);


Index: slapi-private.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-private.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- slapi-private.h	15 Sep 2006 22:45:11 -0000	1.11
+++ slapi-private.h	7 Nov 2006 04:42:55 -0000	1.12
@@ -760,6 +760,7 @@
 int charray_utf8_inlist( char **a, char *s );
 char ** charray_dup( char **a );
 char ** str2charray( char *str, char *brkstr );
+char ** str2charray_ext( char *str, char *brkstr, int allow_dups );
 int charray_remove(char **a,const char *s);
 char ** cool_charray_dup( char **a );
 void cool_charray_free( char **array );




More information about the Fedora-directory-commits mailing list