From: Ray Strode Date: Thu, 21 Aug 2008 18:11:24 +0000 (-0400) Subject: Add --prompt option to ask-for-password client command X-Git-Tag: 0.6.0~182 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbe8e595d399bf7b39e7634032812794cc6b583d;p=thirdparty%2Fplymouth.git Add --prompt option to ask-for-password client command We want to be able to ask the user a question instead of assuming they know what question to answer. This will be important if /opt and /home get encrypted with different passwords. --- diff --git a/src/client/ply-boot-client.c b/src/client/ply-boot-client.c index f863fa70..cc105455 100644 --- a/src/client/ply-boot-client.c +++ b/src/client/ply-boot-client.c @@ -543,6 +543,8 @@ ply_boot_client_tell_daemon_system_is_initialized (ply_boot_client_t void ply_boot_client_ask_daemon_for_password (ply_boot_client_t *client, + + const char *prompt, ply_boot_client_answer_handler_t handler, ply_boot_client_response_handler_t failed_handler, void *user_data) @@ -550,7 +552,7 @@ ply_boot_client_ask_daemon_for_password (ply_boot_client_t *cli assert (client != NULL); ply_boot_client_queue_request (client, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PASSWORD, - NULL, (ply_boot_client_response_handler_t) + prompt, (ply_boot_client_response_handler_t) handler, failed_handler, user_data); } diff --git a/src/client/ply-boot-client.h b/src/client/ply-boot-client.h index 75b165fd..09996efa 100644 --- a/src/client/ply-boot-client.h +++ b/src/client/ply-boot-client.h @@ -64,6 +64,7 @@ void ply_boot_client_tell_daemon_to_change_root (ply_boot_client_t ply_boot_client_response_handler_t failed_handler, void *user_data); void ply_boot_client_ask_daemon_for_password (ply_boot_client_t *client, + const char *prompt, ply_boot_client_answer_handler_t handler, ply_boot_client_response_handler_t failed_handler, void *user_data); diff --git a/src/client/plymouth.c b/src/client/plymouth.c index a1ce52f3..2ba457c6 100644 --- a/src/client/plymouth.c +++ b/src/client/plymouth.c @@ -48,6 +48,7 @@ typedef struct { state_t *state; char *command; + char *prompt; } answer_state_t; static char ** @@ -127,6 +128,7 @@ answer_via_command (answer_state_t *answer_state, close (command_input_sender_fd); dup2 (command_input_receiver_fd, STDIN_FILENO); } + execvp (args[0], args); ply_trace ("could not run command: %m"); _exit (127); @@ -174,6 +176,7 @@ on_answer (answer_state_t *answer_state, WEXITSTATUS (exit_status) != 0)) { ply_boot_client_ask_daemon_for_password (answer_state->state->client, + answer_state->prompt, (ply_boot_client_answer_handler_t) on_answer, (ply_boot_client_response_handler_t) @@ -218,6 +221,7 @@ on_multiple_answers (answer_state_t *answer_state, if (need_to_ask_user) { ply_boot_client_ask_daemon_for_password (answer_state->state->client, + answer_state->prompt, (ply_boot_client_answer_handler_t) on_answer, (ply_boot_client_response_handler_t) @@ -272,11 +276,14 @@ on_password_request (state_t *state, program = NULL; ply_command_parser_get_command_options (state->command_parser, command, - "command", &program, NULL); + "command", &program, + "prompt", &prompt, + NULL); answer_state = calloc (1, sizeof (answer_state_t)); answer_state->state = state; answer_state->command = program; + answer_state->prompt = prompt; if (answer_state->command != NULL) { @@ -290,6 +297,7 @@ on_password_request (state_t *state, else { ply_boot_client_ask_daemon_for_password (state->client, + answer_state->prompt, (ply_boot_client_answer_handler_t) on_answer, (ply_boot_client_response_handler_t) @@ -334,6 +342,8 @@ main (int argc, (ply_command_handler_t) on_password_request, &state, "command", "Command to send password to via standard input", + PLY_COMMAND_OPTION_TYPE_STRING, + "prompt", "Message to display when asking for password", PLY_COMMAND_OPTION_TYPE_STRING, NULL); if (!ply_command_parser_parse_arguments (state.command_parser, state.loop, argv, argc)) @@ -439,6 +449,7 @@ main (int argc, answer_state.state = &state; ply_boot_client_ask_daemon_for_password (state.client, + NULL, (ply_boot_client_answer_handler_t) on_answer, (ply_boot_client_response_handler_t)