[Fedora-directory-commits] ldapserver/ldap/servers/slapd util.c, 1.28, 1.29

Noriko Hosoi nhosoi at fedoraproject.org
Mon Mar 9 16:35:38 UTC 2009


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26816

Modified Files:
	util.c 
Log Message:
Resolves: #488856
Summary: slapi_ldap_init_ext needs to be modified due to the build failure on Solaris
Description: instead of replacing client_callbacks, set sasl path to SASL_PATH
using putenv.



Index: util.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/util.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- util.c	4 Feb 2009 18:21:01 -0000	1.28
+++ util.c	9 Mar 2009 16:35:35 -0000	1.29
@@ -916,23 +916,6 @@
     return SASL_OK;
 }
 
-/* copied from mozldap libldap/saslbind.c - except 
-   SASL_CB_GETPATH added as last item (before SASL_CB_LIST_END
-   This allows us to set the sasl path used for outgoing
-   client connections */
-sasl_callback_t slapd_client_callbacks[] = {
-        { SASL_CB_GETOPT, slapd_sasl_fail, NULL },
-        { SASL_CB_GETREALM, NULL, NULL },
-        { SASL_CB_USER, NULL, NULL },
-        { SASL_CB_CANON_USER, NULL, NULL },
-        { SASL_CB_AUTHNAME, NULL, NULL },
-        { SASL_CB_PASS, NULL, NULL },
-        { SASL_CB_ECHOPROMPT, NULL, NULL },
-        { SASL_CB_NOECHOPROMPT, NULL, NULL },
-        { SASL_CB_GETPATH, slapd_sasl_getpluginpath, NULL },
-        { SASL_CB_LIST_END, NULL, NULL }
-};
-
 /*
   Perform LDAP init and return an LDAP* handle.  If ldapurl is given,
   that is used as the basis for the protocol, host, port, and whether
@@ -947,6 +930,10 @@
   filename is the ldapi file name - if this is given, and no other options
   are given, ldapi is assumed.
  */
+/* util_sasl_path: the string argument for putenv.
+   It must be a global or a static */
+char util_sasl_path[MAXPATHLEN];
+
 LDAP *
 slapi_ldap_init_ext(
     const char *ldapurl, /* full ldap url */
@@ -962,16 +949,36 @@
     LDAPURLDesc	*ludp = NULL;
     LDAP *ld = NULL;
     int rc = 0;
-    extern sasl_callback_t *client_callbacks;
 
     /* We need to provide a sasl path used for client connections, especially
        if the server is not set up to be a sasl server - since mozldap provides
-       no way to override the default path programatically, we replace its
-       client callback list with our own so that we can provide a CB_GETPATH
-       callback */
-    if (client_callbacks != slapd_client_callbacks) {
-	client_callbacks = slapd_client_callbacks;
+       no way to override the default path programatically, we set the sasl
+       path to the environment variable SASL_PATH. */
+    char *configpluginpath = config_get_saslpath();
+    char *pluginpath = configpluginpath;
+    char *pp = NULL;
+
+    if (NULL == pluginpath || (*pluginpath == '\0')) {
+	    slapi_log_error(SLAPI_LOG_FATAL, "slapi_ldap_init_ext",
+			"configpluginpath == NULL\n");
+        if (!(pluginpath = getenv("SASL_PATH"))) {
+#if defined(LINUX) && defined(__LP64__)
+            pluginpath = "/usr/lib64/sasl2";
+#else
+            pluginpath = "/usr/lib/sasl2";
+#endif
+        }
+    }
+    if ('\0' == util_sasl_path[0] || /* first time */
+        NULL == (pp = strchr(util_sasl_path, '=')) || /* invalid arg for putenv */
+        (0 != strcmp(++pp, pluginpath)) /* sasl_path has been updated */ ) {
+        PR_snprintf(util_sasl_path, sizeof(util_sasl_path),
+                                        "SASL_PATH=%s", pluginpath);
+	    slapi_log_error(SLAPI_LOG_FATAL, "slapi_ldap_init_ext",
+			"putenv(%s)\n", util_sasl_path);
+        putenv(util_sasl_path);
     }
+    slapi_ch_free_string(&configpluginpath);
 
     /* if ldapurl is given, parse it */
     if (ldapurl && ((rc = ldap_url_parse_no_defaults(ldapurl, &ludp, 0)) ||




More information about the Fedora-directory-commits mailing list