mrc0mmand / rpms / openldap

Forked from rpms/openldap 3 years ago
Clone

Blame SOURCES/openldap-cbinding-ITS-8573-allow-all-libldap-options-in-tools-o-option.patch

ef2d9b
NOTE: The patch has been adjusted to match the base code before backporting.
ef2d9b
ef2d9b
From 8a259e3df16def3f05828f355e98a5089cd6e6d0 Mon Sep 17 00:00:00 2001
ef2d9b
From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= <ondra@openldap.org>
ef2d9b
Date: Thu, 14 Jun 2018 16:14:15 +0100
ef2d9b
Subject: [PATCH] ITS#8573 allow all libldap options in tools -o option
ef2d9b
ef2d9b
---
ef2d9b
 clients/tools/common.c     |  15 ++-
ef2d9b
 doc/devel/args             |   2 +-
ef2d9b
 doc/man/man1/ldapcompare.1 |   9 +-
ef2d9b
 doc/man/man1/ldapdelete.1  |   9 +-
ef2d9b
 doc/man/man1/ldapexop.1    |   9 +-
ef2d9b
 doc/man/man1/ldapmodify.1  |   9 +-
ef2d9b
 doc/man/man1/ldapmodrdn.1  |   9 +-
ef2d9b
 doc/man/man1/ldappasswd.1  |   9 +-
ef2d9b
 doc/man/man1/ldapsearch.1  |   9 +-
ef2d9b
 doc/man/man1/ldapwhoami.1  |  13 ++-
ef2d9b
 doc/man/man8/slapcat.8     |   2 +-
ef2d9b
 include/ldap_pvt.h         |   5 +
ef2d9b
 libraries/libldap/init.c   | 231 ++++++++++++++++++++++---------------
ef2d9b
 servers/slapd/slapcommon.c |   5 +-
ef2d9b
 14 files changed, 200 insertions(+), 136 deletions(-)
ef2d9b
ef2d9b
diff --git a/clients/tools/common.c b/clients/tools/common.c
ef2d9b
index 1cd8a2c1b..b1edffdaf 100644
ef2d9b
--- a/clients/tools/common.c
ef2d9b
+++ b/clients/tools/common.c
ef2d9b
@@ -374,9 +374,9 @@ N_("  -I         use SASL Interactive mode\n"),
ef2d9b
 N_("  -n         show what would be done but don't actually do it\n"),
ef2d9b
 N_("  -N         do not use reverse DNS to canonicalize SASL host name\n"),
ef2d9b
 N_("  -O props   SASL security properties\n"),
ef2d9b
-N_("  -o <opt>[=<optparam>] general options\n"),
ef2d9b
+N_("  -o <opt>[=<optparam>] any libldap ldap.conf options, plus\n"),
ef2d9b
+N_("             ldif_wrap=<width> (in columns, or \"no\" for no wrapping)\n"),
ef2d9b
 N_("             nettimeout=<timeout> (in seconds, or \"none\" or \"max\")\n"),
ef2d9b
-N_("             ldif-wrap=<width> (in columns, or \"no\" for no wrapping)\n"),
ef2d9b
 N_("  -p port    port on LDAP server\n"),
ef2d9b
 N_("  -Q         use SASL Quiet mode\n"),
ef2d9b
 N_("  -R realm   SASL realm\n"),
ef2d9b
@@ -838,6 +838,11 @@ tool_args( int argc, char **argv )
ef2d9b
 			if ( (cvalue = strchr( control, '=' )) != NULL ) {
ef2d9b
 				*cvalue++ = '\0';
ef2d9b
 			}
ef2d9b
+			for ( next=control; *next; next++ ) {
ef2d9b
+				if ( *next == '-' ) {
ef2d9b
+					*next = '_';
ef2d9b
+				}
ef2d9b
+			}
ef2d9b
 
ef2d9b
 			if ( strcasecmp( control, "nettimeout" ) == 0 ) {
ef2d9b
 				if( nettimeout.tv_sec != -1 ) {
ef2d9b
@@ -867,7 +872,7 @@ tool_args( int argc, char **argv )
ef2d9b
 	 				exit( EXIT_FAILURE );
ef2d9b
  				}
ef2d9b
 
ef2d9b
-			} else if ( strcasecmp( control, "ldif-wrap" ) == 0 ) {
ef2d9b
+			} else if ( strcasecmp( control, "ldif_wrap" ) == 0 ) {
ef2d9b
 				if ( cvalue == 0 ) {
ef2d9b
 					ldif_wrap = LDIF_LINE_WIDTH;
ef2d9b
 
ef2d9b
@@ -878,13 +883,13 @@ tool_args( int argc, char **argv )
ef2d9b
 					unsigned int u;
ef2d9b
 					if ( lutil_atou( &u, cvalue ) ) {
ef2d9b
 						fprintf( stderr,
ef2d9b
-							_("Unable to parse ldif-wrap=\"%s\"\n"), cvalue );
ef2d9b
+							_("Unable to parse ldif_wrap=\"%s\"\n"), cvalue );
ef2d9b
 		 				exit( EXIT_FAILURE );
ef2d9b
 					}
ef2d9b
 					ldif_wrap = (ber_len_t)u;
ef2d9b
 				}
ef2d9b
 
ef2d9b
-			} else {
ef2d9b
+			} else if ( ldap_pvt_conf_option( control, cvalue, 1 ) ) {
ef2d9b
 				fprintf( stderr, "Invalid general option name: %s\n",
ef2d9b
 					control );
ef2d9b
 				usage();
ef2d9b
diff --git a/doc/devel/args b/doc/devel/args
ef2d9b
index 9796fe528..c5aa02f11 100644
ef2d9b
--- a/doc/devel/args
ef2d9b
+++ b/doc/devel/args
ef2d9b
@@ -28,7 +28,7 @@ ldapwhoami       * DE**HI**  NO QR  UVWXYZ   def*h*** *nop*    vwxy
ef2d9b
 	-h host
ef2d9b
 	-n no-op
ef2d9b
 	-N no (SASLprep) normalization of simple bind password
ef2d9b
-	-o general options (currently nettimeout and ldif-wrap only)
ef2d9b
+	-o general libldap options (plus ldif_wrap and nettimeout for backwards comp.)
ef2d9b
 	-p port
ef2d9b
 	-v verbose
ef2d9b
 	-V version
ef2d9b
diff --git a/doc/man/man1/ldapcompare.1 b/doc/man/man1/ldapcompare.1
ef2d9b
index 9e66cd4b2..a0e58d7c3 100644
ef2d9b
--- a/doc/man/man1/ldapcompare.1
ef2d9b
+++ b/doc/man/man1/ldapcompare.1
ef2d9b
@@ -186,13 +186,14 @@ Compare extensions:
ef2d9b
 .TP
ef2d9b
 .BI \-o \ opt \fR[= optparam \fR]
ef2d9b
 
ef2d9b
-Specify general options.
ef2d9b
-
ef2d9b
-General options:
ef2d9b
+Specify any
ef2d9b
+.BR ldap.conf (5)
ef2d9b
+option or one of the following:
ef2d9b
 .nf
ef2d9b
   nettimeout=<timeout>  (in seconds, or "none" or "max")
ef2d9b
-  ldif-wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
+  ldif_wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
 .fi
ef2d9b
+
ef2d9b
 .TP
ef2d9b
 .BI \-O \ security-properties
ef2d9b
 Specify SASL security properties.
ef2d9b
diff --git a/doc/man/man1/ldapdelete.1 b/doc/man/man1/ldapdelete.1
ef2d9b
index 394d35275..85dbf4360 100644
ef2d9b
--- a/doc/man/man1/ldapdelete.1
ef2d9b
+++ b/doc/man/man1/ldapdelete.1
ef2d9b
@@ -192,13 +192,14 @@ Delete extensions:
ef2d9b
 .TP
ef2d9b
 .BI \-o \ opt \fR[= optparam \fR]
ef2d9b
 
ef2d9b
-Specify general options.
ef2d9b
-
ef2d9b
-General options:
ef2d9b
+Specify any
ef2d9b
+.BR ldap.conf (5)
ef2d9b
+option or one of the following:
ef2d9b
 .nf
ef2d9b
   nettimeout=<timeout>  (in seconds, or "none" or "max")
ef2d9b
-  ldif-wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
+  ldif_wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
 .fi
ef2d9b
+
ef2d9b
 .TP
ef2d9b
 .BI \-O \ security-properties
ef2d9b
 Specify SASL security properties.
ef2d9b
diff --git a/doc/man/man1/ldapexop.1 b/doc/man/man1/ldapexop.1
ef2d9b
index 503d681ca..26e1730a8 100644
ef2d9b
--- a/doc/man/man1/ldapexop.1
ef2d9b
+++ b/doc/man/man1/ldapexop.1
ef2d9b
@@ -189,13 +189,14 @@ Specify general extensions.  \'!\' indicates criticality.
ef2d9b
 .TP
ef2d9b
 .BI \-o \ opt \fR[= optparam \fR]
ef2d9b
 
ef2d9b
-Specify general options.
ef2d9b
-
ef2d9b
-General options:
ef2d9b
+Specify any
ef2d9b
+.BR ldap.conf (5)
ef2d9b
+option or one of the following:
ef2d9b
 .nf
ef2d9b
   nettimeout=<timeout>  (in seconds, or "none" or "max")
ef2d9b
-  ldif-wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
+  ldif_wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
 .fi
ef2d9b
+
ef2d9b
 .TP
ef2d9b
 .BI \-O \ security-properties
ef2d9b
 Specify SASL security properties.
ef2d9b
diff --git a/doc/man/man1/ldapmodify.1 b/doc/man/man1/ldapmodify.1
ef2d9b
index 2792d460b..6c277d89c 100644
ef2d9b
--- a/doc/man/man1/ldapmodify.1
ef2d9b
+++ b/doc/man/man1/ldapmodify.1
ef2d9b
@@ -255,13 +255,14 @@ Modify extensions:
ef2d9b
 .TP
ef2d9b
 .BI \-o \ opt \fR[= optparam \fR]]
ef2d9b
 
ef2d9b
-Specify general options.
ef2d9b
-
ef2d9b
-General options:
ef2d9b
+Specify any
ef2d9b
+.BR ldap.conf (5)
ef2d9b
+option or one of the following:
ef2d9b
 .nf
ef2d9b
   nettimeout=<timeout>  (in seconds, or "none" or "max")
ef2d9b
-  ldif-wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
+  ldif_wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
 .fi
ef2d9b
+
ef2d9b
 .TP
ef2d9b
 .BI \-O \ security-properties
ef2d9b
 Specify SASL security properties.
ef2d9b
diff --git a/doc/man/man1/ldapmodrdn.1 b/doc/man/man1/ldapmodrdn.1
ef2d9b
index 5d0f3fcd9..b24e500fe 100644
ef2d9b
--- a/doc/man/man1/ldapmodrdn.1
ef2d9b
+++ b/doc/man/man1/ldapmodrdn.1
ef2d9b
@@ -186,13 +186,14 @@ Modrdn extensions:
ef2d9b
 .TP
ef2d9b
 .BI \-o \ opt \fR[= optparam \fR]
ef2d9b
 
ef2d9b
-Specify general options.
ef2d9b
-
ef2d9b
-General options:
ef2d9b
+Specify any
ef2d9b
+.BR ldap.conf (5)
ef2d9b
+option or one of the following:
ef2d9b
 .nf
ef2d9b
   nettimeout=<timeout>  (in seconds, or "none" or "max")
ef2d9b
-  ldif-wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
+  ldif_wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
 .fi
ef2d9b
+
ef2d9b
 .TP
ef2d9b
 .BI \-O \ security-properties
ef2d9b
 Specify SASL security properties.
ef2d9b
diff --git a/doc/man/man1/ldappasswd.1 b/doc/man/man1/ldappasswd.1
ef2d9b
index 36857ab8f..a2805e57b 100644
ef2d9b
--- a/doc/man/man1/ldappasswd.1
ef2d9b
+++ b/doc/man/man1/ldappasswd.1
ef2d9b
@@ -188,13 +188,14 @@ Passwd Modify extensions:
ef2d9b
 .TP
ef2d9b
 .BI \-o \ opt \fR[= optparam \fR]]
ef2d9b
 
ef2d9b
-Specify general options.
ef2d9b
-
ef2d9b
-General options:
ef2d9b
+Specify any
ef2d9b
+.BR ldap.conf (5)
ef2d9b
+option or one of the following:
ef2d9b
 .nf
ef2d9b
   nettimeout=<timeout>  (in seconds, or "none" or "max")
ef2d9b
-  ldif-wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
+  ldif_wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
 .fi
ef2d9b
+
ef2d9b
 .TP
ef2d9b
 .BI \-O \ security-properties
ef2d9b
 Specify SASL security properties.
ef2d9b
diff --git a/doc/man/man1/ldapsearch.1 b/doc/man/man1/ldapsearch.1
ef2d9b
index 036ce6245..1914eafbf 100644
ef2d9b
--- a/doc/man/man1/ldapsearch.1
ef2d9b
+++ b/doc/man/man1/ldapsearch.1
ef2d9b
@@ -332,13 +332,14 @@ Search extensions:
ef2d9b
 .TP
ef2d9b
 .BI \-o \ opt \fR[= optparam \fR]
ef2d9b
 
ef2d9b
-Specify general options.
ef2d9b
-
ef2d9b
-General options:
ef2d9b
+Specify any
ef2d9b
+.BR ldap.conf (5)
ef2d9b
+option or one of the following:
ef2d9b
 .nf
ef2d9b
   nettimeout=<timeout>  (in seconds, or "none" or "max")
ef2d9b
-  ldif-wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
+  ldif_wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
 .fi
ef2d9b
+
ef2d9b
 .TP
ef2d9b
 .BI \-O \ security-properties
ef2d9b
 Specify SASL security properties.
ef2d9b
diff --git a/doc/man/man1/ldapwhoami.1 b/doc/man/man1/ldapwhoami.1
ef2d9b
index 5912af5ba..2c8cfded2 100644
ef2d9b
--- a/doc/man/man1/ldapwhoami.1
ef2d9b
+++ b/doc/man/man1/ldapwhoami.1
ef2d9b
@@ -143,13 +143,18 @@ WhoAmI extensions:
ef2d9b
 .TP
ef2d9b
 .BI \-o \ opt \fR[= optparam \fR]
ef2d9b
 
ef2d9b
-Specify general options.
ef2d9b
-
ef2d9b
-General options:
ef2d9b
+Specify any
ef2d9b
+.BR ldap.conf (5)
ef2d9b
+option or one of the following:
ef2d9b
 .nf
ef2d9b
   nettimeout=<timeout>  (in seconds, or "none" or "max")
ef2d9b
-  ldif-wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
+  ldif_wrap=<width>     (in columns, or "no" for no wrapping)
ef2d9b
 .fi
ef2d9b
+
ef2d9b
+.B -o
ef2d9b
+option that can be passed here, check
ef2d9b
+.BR ldap.conf (5)
ef2d9b
+for details.
ef2d9b
 .TP
ef2d9b
 .BI \-O \ security-properties
ef2d9b
 Specify SASL security properties.
ef2d9b
diff --git a/doc/man/man8/slapcat.8 b/doc/man/man8/slapcat.8
ef2d9b
index 57c41deff..2085e9176 100644
ef2d9b
--- a/doc/man/man8/slapcat.8
ef2d9b
+++ b/doc/man/man8/slapcat.8
ef2d9b
@@ -149,7 +149,7 @@ Possible generic options/values are:
ef2d9b
               syslog\-level=<level> (see `\-S' in slapd(8))
ef2d9b
               syslog\-user=<user>   (see `\-l' in slapd(8))
ef2d9b
 
ef2d9b
-              ldif-wrap={no|<n>}
ef2d9b
+              ldif_wrap={no|<n>}
ef2d9b
 
ef2d9b
 .in
ef2d9b
 \fIn\fP is the number of columns allowed for the LDIF output
ef2d9b
diff --git a/include/ldap_pvt.h b/include/ldap_pvt.h
ef2d9b
index 31f37277c..e86b032cb 100644
ef2d9b
--- a/include/ldap_pvt.h
ef2d9b
+++ b/include/ldap_pvt.h
ef2d9b
@@ -326,6 +326,11 @@ struct ldifrecord;
ef2d9b
 LDAP_F ( int ) ldap_pvt_discard LDAP_P((
ef2d9b
 	struct ldap *ld, ber_int_t msgid ));
ef2d9b
 
ef2d9b
+/* init.c */
ef2d9b
+LDAP_F( int )
ef2d9b
+ldap_pvt_conf_option LDAP_P((
ef2d9b
+	char *cmd, char *opt, int userconf ));
ef2d9b
+
ef2d9b
 /* messages.c */
ef2d9b
 LDAP_F( BerElement * )
ef2d9b
 ldap_get_message_ber LDAP_P((
ef2d9b
diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c
ef2d9b
index 548d2c1cb..4a7e81bdb 100644
ef2d9b
--- a/libraries/libldap/init.c
ef2d9b
+++ b/libraries/libldap/init.c
ef2d9b
@@ -147,6 +147,141 @@ static const struct ol_attribute {
ef2d9b
 #define MAX_LDAP_ATTR_LEN  sizeof("GSSAPI_ALLOW_REMOTE_PRINCIPAL")
ef2d9b
 #define MAX_LDAP_ENV_PREFIX_LEN 8
ef2d9b
 
ef2d9b
+static int
ef2d9b
+ldap_int_conf_option(
ef2d9b
+	struct ldapoptions *gopts,
ef2d9b
+	char *cmd, char *opt, int userconf )
ef2d9b
+{
ef2d9b
+	int i;
ef2d9b
+
ef2d9b
+	for(i=0; attrs[i].type != ATTR_NONE; i++) {
ef2d9b
+		void *p;
ef2d9b
+
ef2d9b
+		if( !userconf && attrs[i].useronly ) {
ef2d9b
+			continue;
ef2d9b
+		}
ef2d9b
+
ef2d9b
+		if(strcasecmp(cmd, attrs[i].name) != 0) {
ef2d9b
+			continue;
ef2d9b
+		}
ef2d9b
+
ef2d9b
+		switch(attrs[i].type) {
ef2d9b
+		case ATTR_BOOL:
ef2d9b
+			if((strcasecmp(opt, "on") == 0)
ef2d9b
+				|| (strcasecmp(opt, "yes") == 0)
ef2d9b
+				|| (strcasecmp(opt, "true") == 0))
ef2d9b
+			{
ef2d9b
+				LDAP_BOOL_SET(gopts, attrs[i].offset);
ef2d9b
+
ef2d9b
+			} else {
ef2d9b
+				LDAP_BOOL_CLR(gopts, attrs[i].offset);
ef2d9b
+			}
ef2d9b
+
ef2d9b
+			break;
ef2d9b
+
ef2d9b
+		case ATTR_INT: {
ef2d9b
+			char *next;
ef2d9b
+			long l;
ef2d9b
+			p = &((char *) gopts)[attrs[i].offset];
ef2d9b
+			l = strtol( opt, &next, 10 );
ef2d9b
+			if ( next != opt && next[ 0 ] == '\0' ) {
ef2d9b
+				* (int*) p = l;
ef2d9b
+			}
ef2d9b
+			} break;
ef2d9b
+
ef2d9b
+		case ATTR_KV: {
ef2d9b
+				const struct ol_keyvalue *kv;
ef2d9b
+
ef2d9b
+				for(kv = attrs[i].data;
ef2d9b
+					kv->key != NULL;
ef2d9b
+					kv++) {
ef2d9b
+
ef2d9b
+					if(strcasecmp(opt, kv->key) == 0) {
ef2d9b
+						p = &((char *) gopts)[attrs[i].offset];
ef2d9b
+						* (int*) p = kv->value;
ef2d9b
+						break;
ef2d9b
+					}
ef2d9b
+				}
ef2d9b
+			} break;
ef2d9b
+
ef2d9b
+		case ATTR_STRING:
ef2d9b
+			p = &((char *) gopts)[attrs[i].offset];
ef2d9b
+			if (* (char**) p != NULL) LDAP_FREE(* (char**) p);
ef2d9b
+			* (char**) p = LDAP_STRDUP(opt);
ef2d9b
+			break;
ef2d9b
+		case ATTR_OPTION:
ef2d9b
+			ldap_set_option( NULL, attrs[i].offset, opt );
ef2d9b
+			break;
ef2d9b
+		case ATTR_SASL:
ef2d9b
+#ifdef HAVE_CYRUS_SASL
ef2d9b
+			ldap_int_sasl_config( gopts, attrs[i].offset, opt );
ef2d9b
+#endif
ef2d9b
+			break;
ef2d9b
+		case ATTR_GSSAPI:
ef2d9b
+#ifdef HAVE_GSSAPI
ef2d9b
+			ldap_int_gssapi_config( gopts, attrs[i].offset, opt );
ef2d9b
+#endif
ef2d9b
+			break;
ef2d9b
+		case ATTR_TLS:
ef2d9b
+#ifdef HAVE_TLS
ef2d9b
+			ldap_int_tls_config( NULL, attrs[i].offset, opt );
ef2d9b
+#endif
ef2d9b
+			break;
ef2d9b
+		case ATTR_OPT_TV: {
ef2d9b
+			struct timeval tv;
ef2d9b
+			char *next;
ef2d9b
+			tv.tv_usec = 0;
ef2d9b
+			tv.tv_sec = strtol( opt, &next, 10 );
ef2d9b
+			if ( next != opt && next[ 0 ] == '\0' && tv.tv_sec > 0 ) {
ef2d9b
+				(void)ldap_set_option( NULL, attrs[i].offset, (const void *)&tv );
ef2d9b
+			}
ef2d9b
+			} break;
ef2d9b
+		case ATTR_OPT_INT: {
ef2d9b
+			long l;
ef2d9b
+			char *next;
ef2d9b
+			l = strtol( opt, &next, 10 );
ef2d9b
+			if ( next != opt && next[ 0 ] == '\0' && l > 0 && (long)((int)l) == l ) {
ef2d9b
+				int v = (int)l;
ef2d9b
+				(void)ldap_set_option( NULL, attrs[i].offset, (const void *)&v );
ef2d9b
+			}
ef2d9b
+			} break;
ef2d9b
+		}
ef2d9b
+
ef2d9b
+		break;
ef2d9b
+	}
ef2d9b
+
ef2d9b
+	if ( attrs[i].type == ATTR_NONE ) {
ef2d9b
+		Debug( LDAP_DEBUG_TRACE, "ldap_int_tls_config: "
ef2d9b
+				"unknown option '%s'",
ef2d9b
+				cmd, 0, 0 );
ef2d9b
+		return 1;
ef2d9b
+	}
ef2d9b
+
ef2d9b
+	return 0;
ef2d9b
+}
ef2d9b
+
ef2d9b
+int
ef2d9b
+ldap_pvt_conf_option(
ef2d9b
+	char *cmd, char *opt, int userconf )
ef2d9b
+{
ef2d9b
+	struct ldapoptions *gopts;
ef2d9b
+	int rc = LDAP_OPT_ERROR;
ef2d9b
+
ef2d9b
+	/* Get pointer to global option structure */
ef2d9b
+	gopts = LDAP_INT_GLOBAL_OPT();
ef2d9b
+	if (NULL == gopts) {
ef2d9b
+		return LDAP_NO_MEMORY;
ef2d9b
+	}
ef2d9b
+
ef2d9b
+	if ( gopts->ldo_valid != LDAP_INITIALIZED ) {
ef2d9b
+		ldap_int_initialize(gopts, NULL);
ef2d9b
+		if ( gopts->ldo_valid != LDAP_INITIALIZED )
ef2d9b
+			return LDAP_LOCAL_ERROR;
ef2d9b
+	}
ef2d9b
+
ef2d9b
+	return ldap_int_conf_option( gopts, cmd, opt, userconf );
ef2d9b
+}
ef2d9b
+
ef2d9b
 static void openldap_ldap_init_w_conf(
ef2d9b
 	const char *file, int userconf )
ef2d9b
 {
ef2d9b
@@ -212,101 +347,7 @@ static void openldap_ldap_init_w_conf(
ef2d9b
 		while(isspace((unsigned char)*start)) start++;
ef2d9b
 		opt = start;
ef2d9b
 
ef2d9b
-		for(i=0; attrs[i].type != ATTR_NONE; i++) {
ef2d9b
-			void *p;
ef2d9b
-
ef2d9b
-			if( !userconf && attrs[i].useronly ) {
ef2d9b
-				continue;
ef2d9b
-			}
ef2d9b
-
ef2d9b
-			if(strcasecmp(cmd, attrs[i].name) != 0) {
ef2d9b
-				continue;
ef2d9b
-			}
ef2d9b
-
ef2d9b
-			switch(attrs[i].type) {
ef2d9b
-			case ATTR_BOOL:
ef2d9b
-				if((strcasecmp(opt, "on") == 0) 
ef2d9b
-					|| (strcasecmp(opt, "yes") == 0)
ef2d9b
-					|| (strcasecmp(opt, "true") == 0))
ef2d9b
-				{
ef2d9b
-					LDAP_BOOL_SET(gopts, attrs[i].offset);
ef2d9b
-
ef2d9b
-				} else {
ef2d9b
-					LDAP_BOOL_CLR(gopts, attrs[i].offset);
ef2d9b
-				}
ef2d9b
-
ef2d9b
-				break;
ef2d9b
-
ef2d9b
-			case ATTR_INT: {
ef2d9b
-				char *next;
ef2d9b
-				long l;
ef2d9b
-				p = &((char *) gopts)[attrs[i].offset];
ef2d9b
-				l = strtol( opt, &next, 10 );
ef2d9b
-				if ( next != opt && next[ 0 ] == '\0' ) {
ef2d9b
-					* (int*) p = l;
ef2d9b
-				}
ef2d9b
-				} break;
ef2d9b
-
ef2d9b
-			case ATTR_KV: {
ef2d9b
-					const struct ol_keyvalue *kv;
ef2d9b
-
ef2d9b
-					for(kv = attrs[i].data;
ef2d9b
-						kv->key != NULL;
ef2d9b
-						kv++) {
ef2d9b
-
ef2d9b
-						if(strcasecmp(opt, kv->key) == 0) {
ef2d9b
-							p = &((char *) gopts)[attrs[i].offset];
ef2d9b
-							* (int*) p = kv->value;
ef2d9b
-							break;
ef2d9b
-						}
ef2d9b
-					}
ef2d9b
-				} break;
ef2d9b
-
ef2d9b
-			case ATTR_STRING:
ef2d9b
-				p = &((char *) gopts)[attrs[i].offset];
ef2d9b
-				if (* (char**) p != NULL) LDAP_FREE(* (char**) p);
ef2d9b
-				* (char**) p = LDAP_STRDUP(opt);
ef2d9b
-				break;
ef2d9b
-			case ATTR_OPTION:
ef2d9b
-				ldap_set_option( NULL, attrs[i].offset, opt );
ef2d9b
-				break;
ef2d9b
-			case ATTR_SASL:
ef2d9b
-#ifdef HAVE_CYRUS_SASL
ef2d9b
-			   	ldap_int_sasl_config( gopts, attrs[i].offset, opt );
ef2d9b
-#endif
ef2d9b
-				break;
ef2d9b
-			case ATTR_GSSAPI:
ef2d9b
-#ifdef HAVE_GSSAPI
ef2d9b
-				ldap_int_gssapi_config( gopts, attrs[i].offset, opt );
ef2d9b
-#endif
ef2d9b
-				break;
ef2d9b
-			case ATTR_TLS:
ef2d9b
-#ifdef HAVE_TLS
ef2d9b
-			   	ldap_int_tls_config( NULL, attrs[i].offset, opt );
ef2d9b
-#endif
ef2d9b
-				break;
ef2d9b
-			case ATTR_OPT_TV: {
ef2d9b
-				struct timeval tv;
ef2d9b
-				char *next;
ef2d9b
-				tv.tv_usec = 0;
ef2d9b
-				tv.tv_sec = strtol( opt, &next, 10 );
ef2d9b
-				if ( next != opt && next[ 0 ] == '\0' && tv.tv_sec > 0 ) {
ef2d9b
-					(void)ldap_set_option( NULL, attrs[i].offset, (const void *)&tv );
ef2d9b
-				}
ef2d9b
-				} break;
ef2d9b
-			case ATTR_OPT_INT: {
ef2d9b
-				long l;
ef2d9b
-				char *next;
ef2d9b
-				l = strtol( opt, &next, 10 );
ef2d9b
-				if ( next != opt && next[ 0 ] == '\0' && l > 0 && (long)((int)l) == l ) {
ef2d9b
-					int v = (int)l;
ef2d9b
-					(void)ldap_set_option( NULL, attrs[i].offset, (const void *)&v );
ef2d9b
-				}
ef2d9b
-				} break;
ef2d9b
-			}
ef2d9b
-
ef2d9b
-			break;
ef2d9b
-		}
ef2d9b
+		ldap_int_conf_option( gopts, cmd, opt, userconf );
ef2d9b
 	}
ef2d9b
 
ef2d9b
 	fclose(fp);
ef2d9b
diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c
ef2d9b
index 87ea0ea06..39384e5e9 100644
ef2d9b
--- a/servers/slapd/slapcommon.c
ef2d9b
+++ b/servers/slapd/slapcommon.c
ef2d9b
@@ -228,7 +228,8 @@ parse_slapopt( int tool, int *mode )
ef2d9b
 			break;
ef2d9b
 		}
ef2d9b
 
ef2d9b
-	} else if ( strncasecmp( optarg, "ldif-wrap", len ) == 0 ) {
ef2d9b
+	} else if ( ( strncasecmp( optarg, "ldif_wrap", len ) == 0 ) ||
ef2d9b
+			( strncasecmp( optarg, "ldif-wrap", len ) == 0 ) ) {
ef2d9b
 		switch ( tool ) {
ef2d9b
 		case SLAPCAT:
ef2d9b
 			if ( strcasecmp( p, "no" ) == 0 ) {
ef2d9b
@@ -237,7 +238,7 @@ parse_slapopt( int tool, int *mode )
ef2d9b
 			} else {
ef2d9b
 				unsigned int u;
ef2d9b
 				if ( lutil_atou( &u, p ) ) {
ef2d9b
-					Debug( LDAP_DEBUG_ANY, "unable to parse ldif-wrap=\"%s\".\n", p, 0, 0 );
ef2d9b
+					Debug( LDAP_DEBUG_ANY, "unable to parse ldif_wrap=\"%s\".\n", p, 0, 0 );
ef2d9b
 					return -1;
ef2d9b
 				}
ef2d9b
 				ldif_wrap = (ber_len_t)u;
ef2d9b
-- 
ef2d9b
2.26.2
ef2d9b