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

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