]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Add --prompt option to ask-for-password client command
authorRay Strode <rstrode@redhat.com>
Thu, 21 Aug 2008 18:11:24 +0000 (14:11 -0400)
committerRay Strode <rstrode@redhat.com>
Wed, 27 Aug 2008 14:55:36 +0000 (10:55 -0400)
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.

src/client/ply-boot-client.c
src/client/ply-boot-client.h
src/client/plymouth.c

index f863fa70b6881ab72ff859349a8b0a3342fa2f02..cc105455a22c8119c1127914634142d7c5a7fe83 100644 (file)
@@ -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);
 }
 
index 75b165fdf0c72ffe96a383dc5e2630065f5df17f..09996efa3b322ad295bae494c5204a3007e7cf73 100644 (file)
@@ -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);
index a1ce52f34248a6c92fde67c5467f5e35fef15761..2ba457c6ce880b11eac1c1933c9c37e00d45ab46 100644 (file)
@@ -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)