summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Giudici <fgiudici@redhat.com>2017-04-20 10:17:34 +0200
committerFrancesco Giudici <fgiudici@redhat.com>2017-04-20 12:41:08 +0200
commit4bdb6b026a808ab718258e17d20d0472f3fcdd76 (patch)
tree02825c0c0f5762e5f36ac4573204717c37619f5c
parent6dfb3e9ffb69cb3d6943a14dbede0520dc7147ce (diff)
downloadNetworkManager-4bdb6b026a808ab718258e17d20d0472f3fcdd76.tar.gz
nmcli: show secrets when the --show-secrets option is put after the connection id
'nmcli connection show <con_id1> --show-secrets' secrets were not shown. 'nmcli connection show <con_id1> --show-secrets <con_id2>' secrets were shown only for connection ids following the "--show-secrets" option (so only for 'con_id2'). Fix these behaviors showing secrets for all connections also if the "--show-secrets" option is put after the connection ids.
-rw-r--r--clients/cli/connections.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 211d936305..6d679f7d99 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -1727,6 +1727,23 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
g_free (nmc->required_fields);
nmc->required_fields = NULL;
+ /* Before printing the connections check if we have a "--show-secret"
+ * option after the connection ids */
+ if (!nmc->nmc_config.show_secrets && !nmc->complete) {
+ int argc_cp = argc;
+ char **argv_cp = argv;
+
+ do {
+ if ( nm_streq (*argv_cp, "id")
+ || nm_streq (*argv_cp, "uuid")
+ || nm_streq (*argv_cp, "path")
+ || nm_streq (*argv_cp, "apath")) {
+ argc_cp--;
+ argv_cp++;
+ }
+ } while (next_arg (nmc, &argc_cp, &argv_cp, NULL) != -1);
+ }
+
while (argc > 0) {
const GPtrArray *connections;
gboolean res;