]> git.sur5r.net Git - openldap/commitdiff
Import ITS#2691 patch from HEAD
authorHoward Chu <hyc@openldap.org>
Sat, 13 Sep 2003 10:38:23 +0000 (10:38 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 13 Sep 2003 10:38:23 +0000 (10:38 +0000)
contrib/ldapsasl/ldapdb.c

index f0f7e4069bf56190b24429b12e48422f19b36a77..6a35873602a1acdf08a311b2fe1a7b995ea709ba 100644 (file)
@@ -208,6 +208,7 @@ int ldapdb_auxprop_plug_init(const sasl_utils_t *utils,
 {
     ldapctx tmp, *p;
     const char *s;
+    unsigned len;
 
     if(!out_version || !plug) return SASL_BADPARAM;
 
@@ -217,13 +218,27 @@ int ldapdb_auxprop_plug_init(const sasl_utils_t *utils,
     if(!tmp.uri) return SASL_BADPARAM;
 
     utils->getopt(utils->getopt_context, ldapdb, "ldapdb_id",
-               (const char **)&tmp.id.bv_val, (unsigned *)&tmp.id.bv_len);
+               (const char **)&tmp.id.bv_val, &len);
+    tmp.id.bv_len = len;
     utils->getopt(utils->getopt_context, ldapdb, "ldapdb_pw",
-               (const char **)&tmp.pw.bv_val, (unsigned *)&tmp.pw.bv_len);
+               (const char **)&tmp.pw.bv_val, &len);
+    tmp.pw.bv_len = len;
     utils->getopt(utils->getopt_context, ldapdb, "ldapdb_mech",
-               (const char **)&tmp.mech.bv_val, (unsigned *)&tmp.mech.bv_len);
-    utils->getopt(utils->getopt_context, ldapdb, "ldapdb_rc", &s, NULL);
-    if(s && setenv("LDAPRC", s, 1)) return SASL_BADPARAM;
+               (const char **)&tmp.mech.bv_val, &len);
+    tmp.mech.bv_len = len;
+    utils->getopt(utils->getopt_context, ldapdb, "ldapdb_rc", &s, &len);
+    if(s)
+    {
+       char *str = utils->malloc(sizeof("LDAPRC=")+len);
+       if (!str) return SASL_NOMEM;
+       strcpy( str, "LDAPRC=" );
+       strcpy( str + sizeof("LDAPRC=")-1, s );
+       if (putenv(str))
+       {
+           utils->free(str);
+           return SASL_NOMEM;
+       }
+    }
 
     p = utils->malloc(sizeof(ldapctx));
     if (!p) return SASL_NOMEM;