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