configure | 20 +-
configure.ac | 2
include/libadminutil/admutil-int.h | 3
lib/libadminutil/admutil.c | 349 +++++++++++++++++++++++++++++++++++--
lib/libadminutil/uginfo.c | 30 ++-
tests/psetread.c | 83 +++++++-
tests/psetreadssl.c | 3
tests/psetwrite.c | 8
tests/retrieveSIE.c | 12 +
tests/retrieveSIEssl.c | 1
10 files changed, 472 insertions(+), 39 deletions(-)
New commits:
commit 663e32b60804cdeb7c0a97a3b9633c675e39fcac
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Fri Oct 4 09:52:59 2013 -0600
bump version to 1.1.19
diff --git a/configure b/configure
index 370f109..27ef738 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for 389-adminutil 1.1.18.
+# Generated by GNU Autoconf 2.69 for 389-adminutil 1.1.19.
#
# Report bugs to <
http://bugzilla.redhat.com/>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='389-adminutil'
PACKAGE_TARNAME='389-adminutil'
-PACKAGE_VERSION='1.1.18'
-PACKAGE_STRING='389-adminutil 1.1.18'
+PACKAGE_VERSION='1.1.19'
+PACKAGE_STRING='389-adminutil 1.1.19'
PACKAGE_BUGREPORT='http://bugzilla.redhat.com/'
PACKAGE_URL=''
@@ -1378,7 +1378,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures 389-adminutil 1.1.18 to adapt to many kinds of systems.
+\`configure' configures 389-adminutil 1.1.19 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1448,7 +1448,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of 389-adminutil 1.1.18:";;
+ short | recursive ) echo "Configuration of 389-adminutil 1.1.19:";;
esac
cat <<\_ACEOF
@@ -1583,7 +1583,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-389-adminutil configure 1.1.18
+389-adminutil configure 1.1.19
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2173,7 +2173,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by 389-adminutil $as_me 1.1.18, which was
+It was created by 389-adminutil $as_me 1.1.19, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3000,7 +3000,7 @@ fi
# Define the identity of the package.
PACKAGE='389-adminutil'
- VERSION='1.1.18'
+ VERSION='1.1.19'
cat >>confdefs.h <<_ACEOF
@@ -19147,7 +19147,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by 389-adminutil $as_me 1.1.18, which was
+This file was extended by 389-adminutil $as_me 1.1.19, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -19204,7 +19204,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //;
s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-389-adminutil config.status 1.1.18
+389-adminutil config.status 1.1.19
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index 32b6222..90f9aaf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([389-adminutil], [1.1.18], [
http://bugzilla.redhat.com/])
+AC_INIT([389-adminutil], [1.1.19], [
http://bugzilla.redhat.com/])
AM_INIT_AUTOMAKE([1.9 foreign subdir-objects])
AM_MAINTAINER_MODE
AC_CANONICAL_HOST
commit 8647ad892755d49c8cecd27964372ae94f9fe566
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Fri Oct 4 09:30:21 2013 -0600
fix compiler warnings - enhancements to test ticket 47415
Fixed compiler warnings. Added code to test ticket 47415
diff --git a/tests/psetread.c b/tests/psetread.c
index 7d01e15..9509fa4 100644
--- a/tests/psetread.c
+++ b/tests/psetread.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include "libadminutil/admutil.h"
+#include "libadminutil/distadm.h"
#include "libadminutil/srvutil.h"
static void
@@ -44,12 +45,16 @@ dump_pset_node(PsetHndl pset, char *nodeName)
}
iter = nodeAttrs;
- while (attrPtr = *iter++) {
+ while ((attrPtr = *iter++)) {
char *p = NULL;
int ii = 0;
- for (p = attrPtr->attrVal[0]; attrPtr->attrVal &&
attrPtr->attrVal[ii];
+ if (!attrPtr->attrVal) {
+ fprintf(stderr, "%s: no values\n", attrPtr->attrName);
+ continue;
+ }
+ for (p = attrPtr->attrVal[0]; attrPtr->attrVal && p;
p = attrPtr->attrVal[++ii]) {
- fprintf(stderr, "%s: %s\n", attrPtr->attrName,
attrPtr->attrVal[ii]);
+ fprintf(stderr, "%s: %s\n", attrPtr->attrName, p);
}
}
@@ -59,14 +64,24 @@ localdone:
return;
}
+int
main(int ac, char **av)
{
int _ai=ADMUTIL_Init();
+ AttrNameList nameList = NULL;
+ AdmldapInfo ldapInfo = NULL;
PsetHndl pset = NULL;
char *configdir = NULL;
int rval = 0;
char buf[BUFSIZ];
+ char fname[BUFSIZ];
+ char *host;
+ char *userdn;
+ char *passwd;
+ char **p;
+ int ii = 0;
+ (void)_ai;
if (ac > 1) {
configdir = strdup(*(av+1));
}
@@ -79,16 +94,66 @@ main(int ac, char **av)
fprintf(stdout, "%s: configdir: %s\n", *av, configdir);
}
- pset = psetCreate("slapd-localhost", configdir, NULL, NULL, &rval);
- fprintf(stderr, "pset operation returned [%d: %s]\n", rval,
psetErrorString(rval, NULL, buf, sizeof(buf), NULL));
- if (!pset || (rval && (rval != PSET_LOCAL_OPEN_FAIL))) { /* no local file for
slapd - OK */
+ /*
+ * get the LDAP information from admin server config info
+ */
+ ldapInfo = admldapBuildInfo(configdir, &rval);
+ if (NULL == ldapInfo) {
+ fprintf(stderr, "ERROR: empty ldapInfo\n");
+ rval = 1;
goto done;
}
- dump_pset_node(pset, "");
- dump_pset_node(pset, "configuration");
+ if (ADM_GetUserDNString(&rval, &userdn) || !userdn) {
+ fprintf(stderr, "ERROR: could not get current userdn %d\n", rval);
+ goto done;
+ }
+ /* override - cannot use siedn any more for auth */
+ admldapSetSIEDN(ldapInfo, userdn);
- psetDelete(pset);
+ if (ADM_GetCurrentPassword(&rval, &passwd)) {
+ fprintf(stderr, "ERROR: could not get current password %d\n", rval);
+ goto done;
+ }
+
+ host = admldapGetHost(ldapInfo);
+ /*
+ * get servers' DNs belonging to the Admin Server
+ */
+ nameList = getServerDNList(ldapInfo);
+ for (p = nameList; p && *p; p++) {
+ PR_snprintf(fname, sizeof(fname), "%s/%d.1.pset", configdir, ii);
+ pset = psetRealCreate(ldapInfo, host, admldapGetPort(ldapInfo),
+ *p, userdn, passwd, fname, &rval);
+ fprintf(stderr, "pset operation returned [%d: %s]\n", rval,
psetErrorString(rval, NULL, buf, sizeof(buf), NULL));
+ if (!pset || rval) {
+ deleteAttrNameList(nameList);
+ PL_strfree(host);
+ goto done;
+ }
+
+ dump_pset_node(pset, "");
+ dump_pset_node(pset, "configuration");
+
+ psetDelete(pset);
+
+ PR_snprintf(fname, sizeof(fname), "%s/%d.2.pset", configdir, ii);
+ pset = psetRealCreate(ldapInfo, host, admldapGetPort(ldapInfo),
+ "cn=config", userdn, passwd, fname, &rval);
+ fprintf(stderr, "pset operation returned [%d: %s]\n", rval,
psetErrorString(rval, NULL, buf, sizeof(buf), NULL));
+ if (!pset || rval) {
+ deleteAttrNameList(nameList);
+ PL_strfree(host);
+ goto done;
+ }
+
+ dump_pset_node(pset, "");
+ dump_pset_node(pset, "configuration");
+
+ psetDelete(pset);
+ ++ii;
+ }
+ PL_strfree(host);
pset = psetCreate(NULL, configdir, NULL, NULL, &rval); /* admin-serv */
fprintf(stderr, "pset operation returned [%d: %s]\n", rval,
psetErrorString(rval, NULL, buf, sizeof(buf), NULL));
if (!pset || (rval && (rval != PSET_LOCAL_OPEN_FAIL))) { /* no local file for
slapd - OK */
diff --git a/tests/psetreadssl.c b/tests/psetreadssl.c
index 3f5f04e..864fcb7 100644
--- a/tests/psetreadssl.c
+++ b/tests/psetreadssl.c
@@ -56,7 +56,7 @@ dump_pset_node(PsetHndl pset, char *nodeName)
if (attrPtr->attrVal) {
for (p = attrPtr->attrVal[0]; attrPtr->attrVal &&
attrPtr->attrVal[ii];
p = attrPtr->attrVal[++ii]) {
- fprintf(stderr, "%s: %s\n", attrPtr->attrName,
attrPtr->attrVal[ii]);
+ fprintf(stderr, "%s: %s\n", attrPtr->attrName, p);
}
}
}
@@ -77,6 +77,7 @@ main(int ac, char **av)
int rval = 0;
char buf[BUFSIZ];
+ (void)_ai;
if (ac > 1) {
configdir = strdup(*(av+1));
}
diff --git a/tests/psetwrite.c b/tests/psetwrite.c
index 1064631..abc065e 100644
--- a/tests/psetwrite.c
+++ b/tests/psetwrite.c
@@ -28,6 +28,7 @@
#include <string.h>
#include "libadminutil/psetc.h"
#include "libadminutil/admutil.h"
+#include "libadminutil/distadm.h"
#include "libadminutil/srvutil.h"
static void
@@ -45,12 +46,12 @@ dump_pset_node(PsetHndl pset, char *nodeName)
}
iter = nodeAttrs;
- while (attrPtr = *iter++) {
+ while ((attrPtr = *iter++)) {
char *p = NULL;
int ii = 0;
for (p = attrPtr->attrVal[0]; attrPtr->attrVal &&
attrPtr->attrVal[ii];
p = attrPtr->attrVal[++ii]) {
- fprintf(stderr, "%s: %s\n", attrPtr->attrName,
attrPtr->attrVal[ii]);
+ fprintf(stderr, "%s: %s\n", attrPtr->attrName, p);
}
}
@@ -67,7 +68,7 @@ main(int ac, char **av)
PsetHndl pset = NULL;
char *configdir = NULL;
int rval = 0;
- AttributeList updateList = NULL, addList = NULL;
+ AttributeList updateList = NULL;
char *attrs[] = {
"configuration.nsAdminCacheLifetime",
"configuration.nsAdminAccessHosts",
@@ -89,6 +90,7 @@ main(int ac, char **av)
ValueType ocList = NULL;
char buf[BUFSIZ];
+ (void)_ai;
if (ac > 1) {
configdir = strdup(*(av+1));
}
diff --git a/tests/retrieveSIE.c b/tests/retrieveSIE.c
index 1676f6c..10f4ddc 100644
--- a/tests/retrieveSIE.c
+++ b/tests/retrieveSIE.c
@@ -27,19 +27,22 @@
#include <stdlib.h>
#include <string.h>
#include "libadminutil/admutil.h"
+#include "libadminutil/distadm.h"
#include "libadminutil/srvutil.h"
+int
main(int ac, char **av)
{
int _ai=ADMUTIL_Init();
AdmldapInfo ldapInfo = NULL;
AttrNameList nameList = NULL;
char *configdir = NULL;
- int len = 0;
+ char *userdn;
int rval = 0;
char **p;
int siecnt = 0;
+ (void)_ai;
if (ac > 1) {
configdir = strdup(*(av+1));
}
@@ -61,6 +64,13 @@ main(int ac, char **av)
goto done;
}
+ if (ADM_GetUserDNString(&rval, &userdn) || !userdn) {
+ fprintf(stderr, "ERROR: could not get current userdn %d\n", rval);
+ goto done;
+ }
+ /* override - cannot use siedn any more for auth */
+ admldapSetSIEDN(ldapInfo, userdn);
+
/*
* get servers' DNs belonging to the Admin Server
*/
diff --git a/tests/retrieveSIEssl.c b/tests/retrieveSIEssl.c
index de1e9a9..98d8440 100644
--- a/tests/retrieveSIEssl.c
+++ b/tests/retrieveSIEssl.c
@@ -50,6 +50,7 @@ main(int ac, char **av)
char *userdn;
char *passwd;
+ (void)_ai;
if (ac > 1) {
configdir = strdup(*(av+1));
}
commit e86bde45c26eed149d344c8761d02e351773d877
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Fri Oct 4 08:14:25 2013 -0600
Ticket #47415 "Manage certificates" crashes admin server
https://fedorahosted.org/389/ticket/47415
Reviewed by: nkinder (Thanks!)
Branch: master
Fix Description: Use the mozldap version of ldap_explode*. Copied the code
from dsgw, and modified it slightly to work with adminutil. Also added
checking for NULL where admldap_ldap_explode is used, and added some
rudimentary debug printing.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/include/libadminutil/admutil-int.h b/include/libadminutil/admutil-int.h
index ef38230..8048b6d 100644
--- a/include/libadminutil/admutil-int.h
+++ b/include/libadminutil/admutil-int.h
@@ -187,4 +187,7 @@ int admutil_ldap_bind(
int *msgidp /* pass in non-NULL for async handling */
);
+char **admldap_ldap_explode( const char *dn, const int notypes, const int nametype );
+char **admldap_ldap_explode_dn( const char *dn, const int notypes );
+char **admldap_ldap_explode_rdn( const char *rdn, const int notypes );
#endif /* __ADMUTIL_INT_H__ */
diff --git a/lib/libadminutil/admutil.c b/lib/libadminutil/admutil.c
index bf04c10..f296b1f 100644
--- a/lib/libadminutil/admutil.c
+++ b/lib/libadminutil/admutil.c
@@ -16,6 +16,48 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * mozldap_ldap_explode, mozldap_ldap_explode_dn, mozldap_ldap_explode_rdn
+ * and ldap_utf8 functions
+ * are from the file ldap/libraries/libldap/getdn.c in the Mozilla LDAP C SDK
+ *
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998-1999
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * Copyright (c) 1994 Regents of the University of Michigan.
+ * All rights reserved.
+ *
* END COPYRIGHT BLOCK **/
#include <stdio.h>
#include <time.h>
@@ -337,22 +379,36 @@ dn2AttrName(char* dn, char* rootDN)
memset(buf, '\0', sizeof(buf));
- dnList = ldap_explode_dn(dn, 1);
- rootList = ldap_explode_dn(rootDN, 1);
+ dnList = admldap_ldap_explode_dn(dn, 1);
+ rootList = admldap_ldap_explode_dn(rootDN, 1);
- while (rootList[rootLen]) rootLen++;
- while (dnList[dnLen]) dnLen++;
+ if (rootList && dnList) {
+ while (rootList[rootLen]) rootLen++;
+ while (dnList[dnLen]) dnLen++;
- attrLen = dnLen - rootLen;
+ attrLen = dnLen - rootLen;
- while (attrLen > 0) {
- if (attrLen == 1)
- PR_snprintf(buf, sizeof(buf), "%s%s", buf, dnList[0]);
- else
- PR_snprintf(buf, sizeof(buf), "%s%s.", buf, dnList[attrLen-1]);
- attrLen--;
+ while (attrLen > 0) {
+ if (attrLen == 1)
+ PR_snprintf(buf, sizeof(buf), "%s%s", buf, dnList[0]);
+ else
+ PR_snprintf(buf, sizeof(buf), "%s%s.", buf, dnList[attrLen-1]);
+ attrLen--;
+ }
+ } else {
+ char *envvar = PR_GetEnv("ADMINUTIL_DEBUG");
+ if (!dnList) {
+ if (envvar && (*envvar == '1')) {
+ fprintf(stderr, "dn2attrName: Error: invalid dn [%s]\n", dn);
+ }
+ }
+ if (!rootList) {
+ if (envvar && (*envvar == '1')) {
+ fprintf(stderr, "dn2attrName: Error: invalid rootDN [%s]\n", rootDN);
+ }
+ }
+ PL_strncpy(buf, "unknown", sizeof(buf));
}
-
admutil_strsFree(dnList);
admutil_strsFree(rootList);
@@ -380,6 +436,11 @@ attrName2dn(char* attrName, char* rootDN)
rdn = attrPtr+1;
}
else rdn = buf;
+ /* NOTE: FIXME
https://fedorahosted.org/389/ticket/47546 */
+ /* This allows you to create bad DNs
+ ** no escaping for the rdn value
+ ** spaces after the comma
+ */
if (result[0] == '\0')
PR_snprintf(resultPtr, sizeof(result), "cn=%s", rdn);
else
@@ -2533,6 +2594,270 @@ done:
return rc;
}
+#if defined(USE_OPENLDAP)
+#define LDAP_DN 1
+#define LDAP_RDN 2
+
+#define INQUOTE 1
+#define OUTQUOTE 2
+
+#define LDAP_UTF8LEN(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8len (s) : 1)
+
+static char UTF8len[64]
+= {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6};
+
+static char*
+ldap_utf8next (char* s)
+ /* Return a pointer to the character immediately following *s.
+ Handle any valid UTF-8 character, including '\0' and ASCII.
+ Try to handle a misaligned pointer or a malformed character.
+ */
+{
+ register unsigned char* next = (unsigned char*)s;
+ switch (UTF8len [(*next >> 2) & 0x3F]) {
+ case 0: /* erroneous: s points to the middle of a character. */
+ case 6: if ((*++next & 0xC0) != 0x80) break;
+ case 5: if ((*++next & 0xC0) != 0x80) break;
+ case 4: if ((*++next & 0xC0) != 0x80) break;
+ case 3: if ((*++next & 0xC0) != 0x80) break;
+ case 2: if ((*++next & 0xC0) != 0x80) break;
+ case 1: ++next;
+ }
+ return (char*) next;
+}
+
+static int
+ldap_utf8len (const char* s)
+ /* Return the number of char's in the character at *s. */
+{
+ return ldap_utf8next((char*)s) - s;
+}
+
+static int
+ldap_utf8isspace( char* s )
+{
+ register unsigned char *c = (unsigned char*)s;
+ int len = ldap_utf8len(s);
+
+ if (len == 0) {
+ return 0;
+ } else if (len == 1) {
+ switch (*c) {
+ case 0x09:
+ case 0x0A:
+ case 0x0B:
+ case 0x0C:
+ case 0x0D:
+ case 0x20:
+ return 1;
+ default:
+ return 0;
+ }
+ } else if (len == 2) {
+ if (*c == 0xc2) {
+ return *(c+1) == 0x80;
+ }
+ } else if (len == 3) {
+ if (*c == 0xE2) {
+ c++;
+ if (*c == 0x80) {
+ c++;
+ return (*c>=0x80 && *c<=0x8a);
+ }
+ } else if (*c == 0xE3) {
+ return (*(c+1)==0x80) && (*(c+2)==0x80);
+ } else if (*c==0xEF) {
+ return (*(c+1)==0xBB) && (*(c+2)==0xBF);
+ }
+ return 0;
+ }
+
+ /* should never reach here */
+ return 0;
+}
+
+static char **
+mozldap_ldap_explode( const char *dn, const int notypes, const int nametype )
+{
+ char *p, *q, *rdnstart, **rdns = NULL;
+ size_t plen = 0;
+ int state = 0;
+ int count = 0;
+ int startquote = 0;
+ int endquote = 0;
+ int len = 0;
+ int goteq = 0;
+
+ if ( dn == NULL ) {
+ dn = "";
+ }
+
+ while ( ldap_utf8isspace( (char *)dn )) { /* ignore leading spaces */
+ ++dn;
+ }
+
+ p = rdnstart = (char *) dn;
+ state = OUTQUOTE;
+
+ do {
+ p += plen;
+ plen = 1;
+ switch ( *p ) {
+ case '\\':
+ if ( *++p == '\0' )
+ p--;
+ else
+ plen = LDAP_UTF8LEN(p);
+ break;
+ case '"':
+ if ( state == INQUOTE )
+ state = OUTQUOTE;
+ else
+ state = INQUOTE;
+ break;
+ case '+': if ( nametype != LDAP_RDN ) break;
+ case ';':
+ case ',':
+ case '\0':
+ if ( state == OUTQUOTE ) {
+ /*
+ * semicolon and comma are not valid RDN
+ * separators.
+ */
+ if ( nametype == LDAP_RDN &&
+ ( *p == ';' || *p == ',' ||
!goteq)) {
+ admutil_strsFree( rdns );
+ return NULL;
+ }
+ if ( (*p == ',' || *p == ';') &&
!goteq ) {
+ /* If we get here, we have a case similar
+ * to
<attr>=<value>,<string>,<attr>=<value>
+ * This is not a valid dn */
+ admutil_strsFree( rdns );
+ return NULL;
+ }
+ goteq = 0;
+ ++count;
+ if ( rdns == NULL ) {
+ if (( rdns = (char **)PR_Malloc( 8
+ * sizeof( char *))) == NULL )
+ return( NULL );
+ } else if ( count >= 8 ) {
+ if (( rdns = (char **)PR_Realloc(
+ (char *)rdns, (count+1) *
+ sizeof( char *))) == NULL )
+ return( NULL );
+ }
+ rdns[ count ] = NULL;
+ endquote = 0;
+ if ( notypes ) {
+ for ( q = rdnstart;
+ q < p && *q != '='; ++q )
{
+ ;
+ }
+ if ( q < p ) { /* *q == '=' */
+ rdnstart = ++q;
+ }
+ if ( *rdnstart == '"' ) {
+ startquote = 1;
+ ++rdnstart;
+ }
+
+ if ( (*(p-1) == '"') &&
startquote ) {
+ endquote = 1;
+ --p;
+ }
+ }
+
+ len = p - rdnstart;
+ if (( rdns[ count-1 ] = (char *)PR_Calloc(
+ 1, len + 1 )) != NULL ) {
+ memcpy( rdns[ count-1 ], rdnstart,
+ len );
+ if ( !endquote ) {
+ /* trim trailing spaces */
+ while ( len > 0 &&
+ ldap_utf8isspace(
+ &rdns[count-1][len-1] )) {
+ --len;
+ }
+ }
+ rdns[ count-1 ][ len ] = '\0';
+ }
+
+ /*
+ * Don't forget to increment 'p' back to
where
+ * it should be. If we don't, then we will
+ * never get past an "end quote."
+ */
+ if ( endquote == 1 )
+ p++;
+
+ rdnstart = *p ? p + 1 : p;
+ while ( ldap_utf8isspace( rdnstart ))
+ ++rdnstart;
+ }
+ break;
+ case '=':
+ if ( state == OUTQUOTE ) {
+ goteq = 1;
+ }
+ /* FALL */
+ default:
+ plen = LDAP_UTF8LEN(p);
+ break;
+ }
+ } while ( *p );
+
+ return( rdns );
+}
+
+static char **
+mozldap_ldap_explode_dn( const char *dn, const int notypes )
+{
+ return( mozldap_ldap_explode( dn, notypes, LDAP_DN ) );
+}
+
+static char **
+mozldap_ldap_explode_rdn( const char *rdn, const int notypes )
+{
+ return( mozldap_ldap_explode( rdn, notypes, LDAP_RDN ) );
+}
+#endif /* USE_OPENLDAP */
+
+char **
+admldap_ldap_explode( const char *dn, const int notypes, const int nametype )
+{
+#if defined(USE_OPENLDAP)
+ return mozldap_ldap_explode(dn, notypes, nametype);
+#else
+ return ldap_explode(dn, notypes, nametype);
+#endif
+}
+
+char **
+admldap_ldap_explode_dn( const char *dn, const int notypes )
+{
+#if defined(USE_OPENLDAP)
+ return mozldap_ldap_explode_dn(dn, notypes);
+#else
+ return ldap_explode_dn(dn, notypes);
+#endif
+}
+
+char **
+admldap_ldap_explode_rdn( const char *rdn, const int notypes )
+{
+#if defined(USE_OPENLDAP)
+ return mozldap_ldap_explode_rdn(rdn, notypes);
+#else
+ return ldap_explode_rdn(rdn, notypes);
+#endif
+}
+
/*
emacs settings
Local Variables:
diff --git a/lib/libadminutil/uginfo.c b/lib/libadminutil/uginfo.c
index 926f302..f699e57 100644
--- a/lib/libadminutil/uginfo.c
+++ b/lib/libadminutil/uginfo.c
@@ -169,7 +169,14 @@ admldapGetAdmGroupUGDN(char* sieDN)
int dnLen = 0;
char *dnbuf = NULL;
- dnList = ldap_explode_dn(sieDN, 0);
+ dnList = admldap_ldap_explode_dn(sieDN, 0);
+ if (!dnList) {
+ char *envvar = PR_GetEnv("ADMINUTIL_DEBUG");
+ if (envvar && (*envvar == '1')) {
+ fprintf(stderr, "Error: could not parse sieDN [%s]\n", sieDN);
+ }
+ return PL_strdup(sieDN);
+ }
while (dnList && dnList[dnLen]) dnLen++;
if (dnLen >= 5) {
@@ -178,6 +185,12 @@ admldapGetAdmGroupUGDN(char* sieDN)
dnList[dnLen-3],
dnList[dnLen-2],
dnList[dnLen-1]);
+ } else {
+ char *envvar = PR_GetEnv("ADMINUTIL_DEBUG");
+ if (envvar && (*envvar == '1')) {
+ fprintf(stderr, "Error: invalid sieDN [%s]\n", sieDN);
+ }
+ dnbuf = PL_strdup(sieDN);
}
admutil_strsFree(dnList);
return dnbuf;
@@ -190,13 +203,26 @@ admldapGetDomainUGDN(char* sieDN)
int dnLen = 0;
char *dnbuf = NULL;
- dnList = ldap_explode_dn(sieDN, 0);
+ dnList = admldap_ldap_explode_dn(sieDN, 0);
+ if (!dnList) {
+ char *envvar = PR_GetEnv("ADMINUTIL_DEBUG");
+ if (envvar && (*envvar == '1')) {
+ fprintf(stderr, "Error: could not parse sieDN [%s]\n", sieDN);
+ }
+ return PL_strdup(sieDN);
+ }
while (dnList && dnList[dnLen]) dnLen++;
if (dnLen >= 3) {
dnbuf = PR_smprintf("cn=UserDirectory,ou=Global Preferences,%s,%s",
dnList[dnLen-2],
dnList[dnLen-1]);
+ } else {
+ char *envvar = PR_GetEnv("ADMINUTIL_DEBUG");
+ if (envvar && (*envvar == '1')) {
+ fprintf(stderr, "Error: invalid sieDN [%s]\n", sieDN);
+ }
+ dnbuf = PL_strdup(sieDN);
}
admutil_strsFree(dnList);