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

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