Explorar o código

Related: 214238
Summary: Make fallback SASL path work for 64-bit Linux default location.

Nathan Kinder %!s(int64=19) %!d(string=hai) anos
pai
achega
22ad5a9a93

+ 27 - 3
ldap/servers/slapd/charray.c

@@ -269,10 +269,21 @@ charray_dup( char **a )
 
 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 @@ str2charray( char *str, char *brkstr )
 
     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;
 

+ 2 - 2
ldap/servers/slapd/saslbind.c

@@ -560,7 +560,7 @@ static int ids_sasl_getpluginpath(sasl_conn_t *conn, const char **path)
     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 @@ char **ids_sasl_listmech(Slapi_PBlock *pb)
         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);

+ 1 - 0
ldap/servers/slapd/slapi-private.h

@@ -760,6 +760,7 @@ int charray_inlist( char **a, char *s );
 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 );