From d369a650ab59cb03c8230d9dfefa9a7c0010f921 Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Wed, 18 Sep 2019 15:18:31 -0700 Subject: [PATCH] =?UTF-8?q?client:=20Don=E2=80=99t=20prompt=20for=20secret?= =?UTF-8?q?s=20if=20'--dontask'=20is=20used?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/agent.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/client/agent.c b/client/agent.c index 121a16ae..5844acdd 100644 --- a/client/agent.c +++ b/client/agent.c @@ -50,6 +50,19 @@ static struct pending_op { struct l_queue *saved_input; } pending_op; +static struct l_dbus_message *agent_error(const char *text) +{ + display_error(text); + + if (!command_is_interactive_mode()) { + command_set_exit_status(EXIT_FAILURE); + + l_main_quit(); + } + + return NULL; +} + static struct l_dbus_message *release_method_call(struct l_dbus *dbus, struct l_dbus_message *message, void *user_data) @@ -94,6 +107,11 @@ static struct l_dbus_message *request_passphrase_method_call( if (reply) return reply; + if (command_option_get(COMMAND_OPTION_DONTASK, NULL)) + return agent_error("No passphrase is provided as " + "'--"COMMAND_OPTION_PASSPHRASE"' " + "command-line option.\n"); + l_dbus_message_get_arguments(message, "o", &path); if (!path) return NULL; @@ -130,6 +148,11 @@ static struct l_dbus_message *request_private_key_passphrase_method_call( if (reply) return reply; + if (command_option_get(COMMAND_OPTION_DONTASK, NULL)) + return agent_error("No passphrase is provided as " + "'--"COMMAND_OPTION_PASSPHRASE"' " + "command-line option.\n"); + l_dbus_message_get_arguments(message, "o", &path); if (!path) return NULL; @@ -187,6 +210,12 @@ static struct l_dbus_message *request_username_and_password_method_call( if (reply) return reply; + if (command_option_get(COMMAND_OPTION_DONTASK, NULL)) + return agent_error("No username or password is provided as " + "'--"COMMAND_OPTION_USERNAME"' or " + "'--"COMMAND_OPTION_PASSWORD"' " + "command-line option.\n"); + l_dbus_message_get_arguments(message, "o", &path); if (!path) return NULL; @@ -241,6 +270,11 @@ static struct l_dbus_message *request_user_password_method_call( if (reply) return reply; + if (command_option_get(COMMAND_OPTION_DONTASK, NULL)) + return agent_error("No password is provided as " + "'--"COMMAND_OPTION_PASSWORD"' " + "command-line option.\n"); + l_dbus_message_get_arguments(message, "os", &path, &username); if (!path || !username) return NULL;