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;