Blame SOURCES/openldap-Revert-ITS-8618-Remove-deprecated-h-and-p.patch

976c7e
From e1782a92cc0e6dde404fa5fb18cb8dba46887fc0 Mon Sep 17 00:00:00 2001
976c7e
From: Simon Pichugin <spichugi@redhat.com>
976c7e
Date: Thu, 26 May 2022 17:17:39 -0700
976c7e
Subject: [PATCH] Revert "ITS#8618 - Remove deprecated -h and -p options to
976c7e
 client tools"
976c7e
976c7e
Except tests. For tests, use -H option.
976c7e
---
976c7e
 clients/tools/common.c     | 53 +++++++++++++++++++++++++++++++++++++-
976c7e
 clients/tools/common.h     |  2 ++
976c7e
 doc/man/man1/ldapcompare.1 | 12 +++++++++
976c7e
 doc/man/man1/ldapdelete.1  | 12 +++++++++
976c7e
 doc/man/man1/ldapexop.1    | 12 +++++++++
976c7e
 doc/man/man1/ldapmodify.1  | 16 ++++++++++++
976c7e
 doc/man/man1/ldapmodrdn.1  | 12 +++++++++
976c7e
 doc/man/man1/ldappasswd.1  | 12 +++++++++
976c7e
 doc/man/man1/ldapsearch.1  | 12 +++++++++
976c7e
 doc/man/man1/ldapwhoami.1  | 12 +++++++++
976c7e
 10 files changed, 154 insertions(+), 1 deletion(-)
976c7e
976c7e
diff --git a/clients/tools/common.c b/clients/tools/common.c
976c7e
index b88f219b3..28178d64c 100644
976c7e
--- a/clients/tools/common.c
976c7e
+++ b/clients/tools/common.c
976c7e
@@ -71,6 +71,8 @@ char		*prog = NULL;
976c7e
 
976c7e
 /* connection */
976c7e
 char		*ldapuri = NULL;
976c7e
+char		*ldaphost = NULL;
976c7e
+int  		ldapport = 0;
976c7e
 int		use_tls = 0;
976c7e
 int		protocol = -1;
976c7e
 int		version = 0;
976c7e
@@ -348,6 +350,7 @@ N_("             [!]sessiontracking[=<username>]\n")
976c7e
 N_("             abandon, cancel, ignore (SIGINT sends abandon/cancel,\n"
976c7e
    "             or ignores response; if critical, doesn't wait for SIGINT.\n"
976c7e
    "             not really controls)\n")
976c7e
+N_("  -h host    LDAP server (deprecated in favor of \"-H\")\n"),
976c7e
 N_("  -H URI     LDAP Uniform Resource Identifier(s)\n"),
976c7e
 N_("  -I         use SASL Interactive mode\n"),
976c7e
 N_("  -n         show what would be done but don't actually do it\n"),
976c7e
@@ -356,6 +359,7 @@ N_("  -O props   SASL security properties\n"),
976c7e
 N_("  -o <opt>[=<optparam>] any libldap ldap.conf options, plus\n"),
976c7e
 N_("             ldif_wrap=<width> (in columns, or \"no\" for no wrapping)\n"),
976c7e
 N_("             nettimeout=<timeout> (in seconds, or \"none\" or \"max\")\n"),
976c7e
+N_("  -p port    port on LDAP server (deprecated in favor of \"-H\")\n"),
976c7e
 N_("  -Q         use SASL Quiet mode\n"),
976c7e
 N_("  -R realm   SASL realm\n"),
976c7e
 N_("  -U authcid SASL authentication identity\n"),
976c7e
@@ -774,6 +778,13 @@ tool_args( int argc, char **argv )
976c7e
 			}
976c7e
 			infile = optarg;
976c7e
 			break;
976c7e
+		case 'h':	/* ldap host */
976c7e
+			if( ldaphost != NULL ) {
976c7e
+				fprintf( stderr, "%s: -h previously specified\n", prog );
976c7e
+				exit( EXIT_FAILURE );
976c7e
+			}
976c7e
+			ldaphost = optarg;
976c7e
+			break;
976c7e
 		case 'H':	/* ldap URI */
976c7e
 			if( ldapuri != NULL ) {
976c7e
 				fprintf( stderr, "%s: -H previously specified\n", prog );
976c7e
@@ -887,6 +898,18 @@ tool_args( int argc, char **argv )
976c7e
 			exit( EXIT_FAILURE );
976c7e
 #endif
976c7e
 			break;
976c7e
+		case 'p':
976c7e
+			if( ldapport ) {
976c7e
+				fprintf( stderr, "%s: -p previously specified\n", prog );
976c7e
+				exit( EXIT_FAILURE );
976c7e
+			}
976c7e
+			ival = strtol( optarg, &next, 10 );
976c7e
+			if ( next == NULL || next[0] != '\0' ) {
976c7e
+				fprintf( stderr, "%s: unable to parse port number \"%s\"\n", prog, optarg );
976c7e
+				exit( EXIT_FAILURE );
976c7e
+			}
976c7e
+			ldapport = ival;
976c7e
+			break;
976c7e
 		case 'P':
976c7e
 			ival = strtol( optarg, &next, 10 );
976c7e
 			if ( next == NULL || next[0] != '\0' ) {
976c7e
@@ -1121,6 +1144,22 @@ tool_args( int argc, char **argv )
976c7e
 #endif
976c7e
 	}
976c7e
 
976c7e
+	if( ldapuri == NULL ) {
976c7e
+		if( ldapport && ( ldaphost == NULL )) {
976c7e
+			fprintf( stderr, "%s: -p without -h is invalid.\n", prog );
976c7e
+			exit( EXIT_FAILURE );
976c7e
+		}
976c7e
+	} else {
976c7e
+		if( ldaphost != NULL ) {
976c7e
+			fprintf( stderr, "%s: -H incompatible with -h\n", prog );
976c7e
+			exit( EXIT_FAILURE );
976c7e
+		}
976c7e
+		if( ldapport ) {
976c7e
+			fprintf( stderr, "%s: -H incompatible with -p\n", prog );
976c7e
+			exit( EXIT_FAILURE );
976c7e
+		}
976c7e
+	}
976c7e
+
976c7e
 	if( protocol == LDAP_VERSION2 ) {
976c7e
 		if( assertctl || authzid || manageDIT || manageDSAit ||
976c7e
 #ifdef LDAP_CONTROL_OBSOLETE_PROXY_AUTHZ
976c7e
@@ -1191,7 +1230,19 @@ tool_conn_setup( int dont, void (*private_setup)( LDAP * ) )
976c7e
 	if ( !dont ) {
976c7e
 		int rc;
976c7e
 
976c7e
-		if ( ldapuri != NULL ) {
976c7e
+		if( ( ldaphost != NULL || ldapport ) && ( ldapuri == NULL ) ) {
976c7e
+			/* construct URL */
976c7e
+			LDAPURLDesc url;
976c7e
+			memset( &url, 0, sizeof(url));
976c7e
+
976c7e
+			url.lud_scheme = "ldap";
976c7e
+			url.lud_host = ldaphost;
976c7e
+			url.lud_port = ldapport;
976c7e
+			url.lud_scope = LDAP_SCOPE_DEFAULT;
976c7e
+
976c7e
+			ldapuri = ldap_url_desc2str( &url );
976c7e
+
976c7e
+		} else if ( ldapuri != NULL ) {
976c7e
 			LDAPURLDesc	*ludlist, **ludp;
976c7e
 			char		**urls = NULL;
976c7e
 			int		nurls = 0;
976c7e
diff --git a/clients/tools/common.h b/clients/tools/common.h
976c7e
index c4377da17..41c3d874a 100644
976c7e
--- a/clients/tools/common.h
976c7e
+++ b/clients/tools/common.h
976c7e
@@ -61,6 +61,8 @@ extern char		*prog;
976c7e
 
976c7e
 /* connection */
976c7e
 extern char		*ldapuri;
976c7e
+extern char		*ldaphost;
976c7e
+extern int		ldapport;
976c7e
 extern int		use_tls;
976c7e
 extern int		protocol;
976c7e
 extern int		version;
976c7e
diff --git a/doc/man/man1/ldapcompare.1 b/doc/man/man1/ldapcompare.1
976c7e
index b15b0c4f8..b7747ad8c 100644
976c7e
--- a/doc/man/man1/ldapcompare.1
976c7e
+++ b/doc/man/man1/ldapcompare.1
976c7e
@@ -31,6 +31,10 @@ ldapcompare \- LDAP compare tool
976c7e
 [\c
976c7e
 .BI \-H \ ldapuri\fR]
976c7e
 [\c
976c7e
+.BI \-h \ ldaphost\fR]
976c7e
+[\c
976c7e
+.BI \-p \ ldapport\fR]
976c7e
+[\c
976c7e
 .BR \-P \ { 2 \||\| 3 }]
976c7e
 [\c
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
976c7e
@@ -139,6 +143,14 @@ Specify URI(s) referring to the ldap server(s); only the protocol/host/port
976c7e
 fields are allowed; a list of URI, separated by whitespace or commas
976c7e
 is expected.
976c7e
 .TP
976c7e
+.BI \-h \ ldaphost
976c7e
+Specify an alternate host on which the ldap server is running.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
+.BI \-p \ ldapport
976c7e
+Specify an alternate TCP port where the ldap server is listening.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
 .BR \-P \ { 2 \||\| 3 }
976c7e
 Specify the LDAP protocol version to use.
976c7e
 .TP
976c7e
diff --git a/doc/man/man1/ldapdelete.1 b/doc/man/man1/ldapdelete.1
976c7e
index e12cc56bb..84dbd882c 100644
976c7e
--- a/doc/man/man1/ldapdelete.1
976c7e
+++ b/doc/man/man1/ldapdelete.1
976c7e
@@ -37,6 +37,10 @@ ldapdelete \- LDAP delete entry tool
976c7e
 [\c
976c7e
 .BI \-H \ ldapuri\fR]
976c7e
 [\c
976c7e
+.BI \-h \ ldaphost\fR]
976c7e
+[\c
976c7e
+.BI \-p \ ldapport\fR]
976c7e
+[\c
976c7e
 .BR \-P \ { 2 \||\| 3 }]
976c7e
 [\c
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
976c7e
@@ -145,6 +149,14 @@ Specify URI(s) referring to the ldap server(s); only the protocol/host/port
976c7e
 fields are allowed; a list of URI, separated by whitespace or commas
976c7e
 is expected.
976c7e
 .TP
976c7e
+.BI \-h \ ldaphost
976c7e
+Specify an alternate host on which the ldap server is running.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
+.BI \-p \ ldapport
976c7e
+Specify an alternate TCP port where the ldap server is listening.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
 .BR \-P \ { 2 \||\| 3 }
976c7e
 Specify the LDAP protocol version to use.
976c7e
 .TP
976c7e
diff --git a/doc/man/man1/ldapexop.1 b/doc/man/man1/ldapexop.1
976c7e
index 2040c3e45..26e1730a8 100644
976c7e
--- a/doc/man/man1/ldapexop.1
976c7e
+++ b/doc/man/man1/ldapexop.1
976c7e
@@ -42,6 +42,10 @@ ldapexop
976c7e
 [\c
976c7e
 .BI \-H \ URI\fR]
976c7e
 [\c
976c7e
+.BI \-h \ ldaphost\fR]
976c7e
+[\c
976c7e
+.BI \-p \ ldapport\fR]
976c7e
+[\c
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
976c7e
 [\c
976c7e
 .BI \-o \ opt \fR[= optparam \fR]]
976c7e
@@ -156,6 +160,14 @@ Specify URI(s) referring to the ldap server(s); only the protocol/host/port
976c7e
 fields are allowed; a list of URI, separated by whitespace or commas
976c7e
 is expected.
976c7e
 .TP
976c7e
+.BI \-h \ ldaphost
976c7e
+Specify the host on which the ldap server is running.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
+.BI \-p \ ldapport
976c7e
+Specify the TCP port where the ldap server is listening.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
976c7e
 Specify general extensions.  \'!\' indicates criticality.
976c7e
 .nf
976c7e
diff --git a/doc/man/man1/ldapmodify.1 b/doc/man/man1/ldapmodify.1
976c7e
index 1104e9f2a..affc661ea 100644
976c7e
--- a/doc/man/man1/ldapmodify.1
976c7e
+++ b/doc/man/man1/ldapmodify.1
976c7e
@@ -37,6 +37,10 @@ ldapmodify, ldapadd \- LDAP modify entry and LDAP add entry tools
976c7e
 [\c
976c7e
 .BI \-H \ ldapuri\fR]
976c7e
 [\c
976c7e
+.BI \-h \ ldaphost\fR]
976c7e
+[\c
976c7e
+.BI \-p \ ldapport\fR]
976c7e
+[\c
976c7e
 .BR \-P \ { 2 \||\| 3 }]
976c7e
 [\c
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
976c7e
@@ -93,6 +97,10 @@ ldapmodify, ldapadd \- LDAP modify entry and LDAP add entry tools
976c7e
 [\c
976c7e
 .BI \-H \ ldapuri\fR]
976c7e
 [\c
976c7e
+.BI \-h \ ldaphost\fR]
976c7e
+[\c
976c7e
+.BI \-p \ ldapport\fR]
976c7e
+[\c
976c7e
 .BR \-P \ { 2 \||\| 3 }]
976c7e
 [\c
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
976c7e
@@ -204,6 +212,14 @@ Specify URI(s) referring to the ldap server(s); only the protocol/host/port
976c7e
 fields are allowed; a list of URI, separated by whitespace or commas
976c7e
 is expected.
976c7e
 .TP
976c7e
+.BI \-h \ ldaphost
976c7e
+Specify an alternate host on which the ldap server is running.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
+.BI \-p \ ldapport
976c7e
+Specify an alternate TCP port where the ldap server is listening.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
 .BR \-P \ { 2 \||\| 3 }
976c7e
 Specify the LDAP protocol version to use.
976c7e
 .TP
976c7e
diff --git a/doc/man/man1/ldapmodrdn.1 b/doc/man/man1/ldapmodrdn.1
976c7e
index 777c539ad..0226db5d2 100644
976c7e
--- a/doc/man/man1/ldapmodrdn.1
976c7e
+++ b/doc/man/man1/ldapmodrdn.1
976c7e
@@ -37,6 +37,10 @@ ldapmodrdn \- LDAP rename entry tool
976c7e
 [\c
976c7e
 .BI \-H \ ldapuri\fR]
976c7e
 [\c
976c7e
+.BI \-h \ ldaphost\fR]
976c7e
+[\c
976c7e
+.BI \-p \ ldapport\fR]
976c7e
+[\c
976c7e
 .BR \-P \ { 2 \||\| 3 }]
976c7e
 [\c
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
976c7e
@@ -139,6 +143,14 @@ Specify URI(s) referring to the ldap server(s); only the protocol/host/port
976c7e
 fields are allowed; a list of URI, separated by whitespace or commas
976c7e
 is expected.
976c7e
 .TP
976c7e
+.BI \-h \ ldaphost
976c7e
+Specify an alternate host on which the ldap server is running.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
+.BI \-p \ ldapport
976c7e
+Specify an alternate TCP port where the ldap server is listening.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
 .BR \-P \ { 2 \||\| 3 }
976c7e
 Specify the LDAP protocol version to use.
976c7e
 .TP
976c7e
diff --git a/doc/man/man1/ldappasswd.1 b/doc/man/man1/ldappasswd.1
976c7e
index d1aea0c8b..c9cea59c5 100644
976c7e
--- a/doc/man/man1/ldappasswd.1
976c7e
+++ b/doc/man/man1/ldappasswd.1
976c7e
@@ -39,6 +39,10 @@ ldappasswd \- change the password of an LDAP entry
976c7e
 [\c
976c7e
 .BI \-H \ ldapuri\fR]
976c7e
 [\c
976c7e
+.BI \-h \ ldaphost\fR]
976c7e
+[\c
976c7e
+.BI \-p \ ldapport\fR]
976c7e
+[\c
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
976c7e
 [\c
976c7e
 .BR \-E \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
976c7e
@@ -144,6 +148,14 @@ Specify URI(s) referring to the ldap server(s); only the protocol/host/port
976c7e
 fields are allowed; a list of URI, separated by whitespace or commas
976c7e
 is expected.
976c7e
 .TP
976c7e
+.BI \-h \ ldaphost
976c7e
+Specify an alternate host on which the ldap server is running.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
+.BI \-p \ ldapport
976c7e
+Specify an alternate TCP port where the ldap server is listening.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
976c7e
 .TP
976c7e
 .BR \-E \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
976c7e
diff --git a/doc/man/man1/ldapsearch.1 b/doc/man/man1/ldapsearch.1
976c7e
index 7f3ec4095..7496602b8 100644
976c7e
--- a/doc/man/man1/ldapsearch.1
976c7e
+++ b/doc/man/man1/ldapsearch.1
976c7e
@@ -57,6 +57,10 @@ ldapsearch \- LDAP search tool
976c7e
 [\c
976c7e
 .BI \-H \ ldapuri\fR]
976c7e
 [\c
976c7e
+.BI \-h \ ldaphost\fR]
976c7e
+[\c
976c7e
+.BI \-p \ ldapport\fR]
976c7e
+[\c
976c7e
 .BR \-P \ { 2 \||\| 3 }]
976c7e
 [\c
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
976c7e
@@ -277,6 +281,14 @@ DNS SRV records, according to RFC 2782.  The DN must be a non-empty
976c7e
 sequence of AVAs whose attribute type is "dc" (domain component),
976c7e
 and must be escaped according to RFC 2396.
976c7e
 .TP
976c7e
+.BI \-h \ ldaphost
976c7e
+Specify an alternate host on which the ldap server is running.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
+.BI \-p \ ldapport
976c7e
+Specify an alternate TCP port where the ldap server is listening.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
 .BR \-P \ { 2 \||\| 3 }
976c7e
 Specify the LDAP protocol version to use.
976c7e
 .TP
976c7e
diff --git a/doc/man/man1/ldapwhoami.1 b/doc/man/man1/ldapwhoami.1
976c7e
index 49b1187b2..adbc3f52c 100644
976c7e
--- a/doc/man/man1/ldapwhoami.1
976c7e
+++ b/doc/man/man1/ldapwhoami.1
976c7e
@@ -27,6 +27,10 @@ ldapwhoami \- LDAP who am i? tool
976c7e
 [\c
976c7e
 .BI \-H \ ldapuri\fR]
976c7e
 [\c
976c7e
+.BI \-h \ ldaphost\fR]
976c7e
+[\c
976c7e
+.BI \-p \ ldapport\fR]
976c7e
+[\c
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
976c7e
 [\c
976c7e
 .BR \-E \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
976c7e
@@ -99,6 +103,14 @@ Specify URI(s) referring to the ldap server(s); only the protocol/host/port
976c7e
 fields are allowed; a list of URI, separated by whitespace or commas
976c7e
 is expected.
976c7e
 .TP
976c7e
+.BI \-h \ ldaphost
976c7e
+Specify an alternate host on which the ldap server is running.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
+.BI \-p \ ldapport
976c7e
+Specify an alternate TCP port where the ldap server is listening.
976c7e
+Deprecated in favor of \fB\-H\fP.
976c7e
+.TP
976c7e
 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
976c7e
 .TP
976c7e
 .BR \-E \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
976c7e
-- 
976c7e
2.35.3
976c7e