summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorCory Benfield <lukasaoz@gmail.com>2016-06-04 20:46:38 -0700
committerCory Benfield <lukasaoz@gmail.com>2017-06-19 08:42:10 +0100
commit729ef85611d2490da8f10ea546279c961e6de4a6 (patch)
tree8cd746344b82e010444f7888dbfe250d82990ca8 /apps
parentedcdf38bd09f77160f0ec3e5bdd9d9525daf6f25 (diff)
s_client accepts host/port as positional argument.
This allows the user to provide the target host and optional port to openssl s_client as an optional positional argument, rather than as the argument to the -connect flag. This rationalises the user experience of s_client: given that the only logical purpose of s_client is to connect to a host, it is difficult to understand why there is an (effectively mandatory) command option to pass to make that happen. This patch forbids providing *both* -connect and the positional argument, because it would likely be too difficult to reconcile. Otherwise, using the positional argument behaves exactly the same as using -connect does. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1171)
Diffstat (limited to 'apps')
-rw-r--r--apps/s_client.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/apps/s_client.c b/apps/s_client.c
index ad0eaec562..1d11f0932a 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -1421,8 +1421,22 @@ int s_client_main(int argc, char **argv)
}
}
argc = opt_num_rest();
- if (argc != 0)
+ if (argc == 1) {
+ /* If there's a positional argument, it's the equivalent of
+ * OPT_CONNECT.
+ * Don't allow -connect and a separate argument.
+ */
+ if (connectstr != NULL) {
+ BIO_printf(bio_err,
+ "%s: must not provide both -connect option and target parameter\n",
+ prog);
+ goto opthelp;
+ }
+ connect_type = use_inet;
+ connectstr = *opt_rest();
+ } else if (argc != 0) {
goto opthelp;
+ }
#ifndef OPENSSL_NO_NEXTPROTONEG
if (min_version == TLS1_3_VERSION && next_proto_neg_in != NULL) {
@@ -1434,7 +1448,7 @@ int s_client_main(int argc, char **argv)
int res;
char *tmp_host = host, *tmp_port = port;
if (connectstr == NULL) {
- BIO_printf(bio_err, "%s: -proxy requires use of -connect\n", prog);
+ BIO_printf(bio_err, "%s: -proxy requires use of -connect or target parameter\n", prog);
goto opthelp;
}
res = BIO_parse_hostserv(proxystr, &host, &port, BIO_PARSE_PRIO_HOST);
@@ -1459,7 +1473,7 @@ int s_client_main(int argc, char **argv)
OPENSSL_free(tmp_port);
if (!res) {
BIO_printf(bio_err,
- "%s: -connect argument malformed or ambiguous\n",
+ "%s: -connect argument or target parameter malformed or ambiguous\n",
prog);
goto end;
}