commit d369a650ab59cb03c8230d9dfefa9a7c0010f921
parent 62d286a7458f22ec3e0360671d553ad6ff783d57
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date: Wed, 18 Sep 2019 15:18:31 -0700
client: Don’t prompt for secrets if '--dontask' is used
Diffstat:
1 file changed, 34 insertions(+), 0 deletions(-)
diff --git 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;