rpms/plymouth/F-12 work-better-with-passwords-and-custom-init.patch, NONE, 1.1 plymouth.spec, 1.170, 1.171

Ray Strode rstrode at fedoraproject.org
Tue Jan 26 06:24:07 UTC 2010


Author: rstrode

Update of /cvs/pkgs/rpms/plymouth/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv23334

Modified Files:
	plymouth.spec 
Added Files:
	work-better-with-passwords-and-custom-init.patch 
Log Message:
- Work better with encrypted root and init=foo


work-better-with-passwords-and-custom-init.patch:
 b/src/client/ply-boot-client.c |   40 +++++++----
 b/src/client/plymouth.c        |   39 +++++++++++
 b/src/main.c                   |    3 
 src/client/plymouth.c          |  139 +++++++++++++++++++++++++++++------------
 src/main.c                     |   19 ++++-
 5 files changed, 179 insertions(+), 61 deletions(-)

--- NEW FILE work-better-with-passwords-and-custom-init.patch ---
>From e9c7b34fba3d1a1ccd65749c2c5ee04ab4977751 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode at redhat.com>
Date: Mon, 25 Jan 2010 17:29:31 -0500
Subject: [PATCH 1/6] [client] debug mode if plymouth:debug in /proc/cmdline

We currently do this for the daemon.  We should do it for
the client as well.
---
 src/client/plymouth.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/client/plymouth.c b/src/client/plymouth.c
index 8669fd2..aa20b3e 100644
--- a/src/client/plymouth.c
+++ b/src/client/plymouth.c
@@ -37,11 +37,16 @@
 #include "ply-logger.h"
 #include "ply-utils.h"
 
+#ifndef PLY_MAX_COMMAND_LINE_SIZE
+#define PLY_MAX_COMMAND_LINE_SIZE 512
+#endif
+
 typedef struct
 {
   ply_event_loop_t     *loop;
   ply_boot_client_t    *client;
   ply_command_parser_t *command_parser;
+  char kernel_command_line[PLY_MAX_COMMAND_LINE_SIZE];
 } state_t;
 
 typedef struct
@@ -624,6 +629,32 @@ on_quit_request (state_t    *state,
                                        on_failure, state);
 }
 
+static bool
+get_kernel_command_line (state_t *state)
+{
+  int fd;
+
+  ply_trace ("opening /proc/cmdline");
+  fd = open ("proc/cmdline", O_RDONLY);
+
+  if (fd < 0)
+    {
+      ply_trace ("couldn't open it: %m");
+      return false;
+    }
+
+  ply_trace ("reading kernel command line");
+  if (read (fd, state->kernel_command_line, sizeof (state->kernel_command_line)) < 0)
+    {
+      ply_trace ("couldn't read it: %m");
+      return false;
+    }
+
+  ply_trace ("Kernel command line is: '%s'", state->kernel_command_line);
+  close (fd);
+  return true;
+}
+
 int
 main (int    argc,
       char **argv)
@@ -776,6 +807,13 @@ main (int    argc,
       return 0;
     }
 
+  if (get_kernel_command_line (&state))
+    {
+      if (strstr (state.kernel_command_line, "plymouth:debug") != NULL
+          && !ply_is_tracing ())
+        ply_toggle_tracing ();
+    }
+
   if (should_be_verbose && !ply_is_tracing ())
     ply_toggle_tracing ();
 
-- 
1.6.6


>From 6a9c53419527e88edef1e2a1ed9347a16cd4f59b Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode at redhat.com>
Date: Mon, 25 Jan 2010 17:06:53 -0500
Subject: [PATCH 2/6] [client] Don't exit right away if daemon unavailable

We're going to want to be able to carry on in some cases
even if the daemon isn't there.
---
 src/client/ply-boot-client.c |   40 ++++++++++++++++++++++++++--------------
 src/client/plymouth.c        |   23 ++++++-----------------
 2 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/src/client/ply-boot-client.c b/src/client/ply-boot-client.c
index 917a619..fef7fb1 100644
--- a/src/client/ply-boot-client.c
+++ b/src/client/ply-boot-client.c
@@ -466,16 +466,14 @@ ply_boot_client_queue_request (ply_boot_client_t                  *client,
                                ply_boot_client_response_handler_t  failed_handler,
                                void                               *user_data)
 {
-  ply_boot_client_request_t *request;
-
   assert (client != NULL);
   assert (client->loop != NULL);
-  assert (client->socket_fd >= 0);
   assert (request_command != NULL);
   assert (request_argument == NULL || strlen (request_argument) <= UCHAR_MAX);
   assert (handler != NULL);
 
-  if (client->daemon_can_take_request_watch == NULL)
+  if (client->daemon_can_take_request_watch == NULL &&
+      client->socket_fd >= 0)
     {
       assert (ply_list_get_length (client->requests_to_send) == 0);
       client->daemon_can_take_request_watch = 
@@ -486,10 +484,22 @@ ply_boot_client_queue_request (ply_boot_client_t                  *client,
                                    NULL, client);
     }
 
-  request = ply_boot_client_request_new (client, request_command,
-                                         request_argument, 
-                                         handler, failed_handler, user_data);
-  ply_list_append_data (client->requests_to_send, request);
+  if (!client->is_connected)
+    {
+      if (failed_handler != NULL)
+        {
+          failed_handler (user_data, client);
+        }
+    }
+  else
+    {
+      ply_boot_client_request_t *request;
+
+      request = ply_boot_client_request_new (client, request_command,
+                                             request_argument,
+                                             handler, failed_handler, user_data);
+      ply_list_append_data (client->requests_to_send, request);
+    }
 }
 
 void
@@ -748,15 +758,17 @@ ply_boot_client_attach_to_event_loop (ply_boot_client_t *client,
   assert (client != NULL);
   assert (loop != NULL);
   assert (client->loop == NULL);
-  assert (client->socket_fd >= 0);
 
   client->loop = loop;
 
-  ply_event_loop_watch_fd (client->loop, client->socket_fd,
-                           PLY_EVENT_LOOP_FD_STATUS_NONE,
-                           NULL, 
-                           (ply_event_handler_t) ply_boot_client_on_hangup,
-                           client);
+  if (client->socket_fd >= 0)
+    {
+      ply_event_loop_watch_fd (client->loop, client->socket_fd,
+                               PLY_EVENT_LOOP_FD_STATUS_NONE,
+                               NULL,
+                               (ply_event_handler_t) ply_boot_client_on_hangup,
+                               client);
+    }
 
   ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t) 
                                  ply_boot_client_detach_from_event_loop,
diff --git a/src/client/plymouth.c b/src/client/plymouth.c
index aa20b3e..c00ddda 100644
--- a/src/client/plymouth.c
+++ b/src/client/plymouth.c
@@ -661,6 +661,7 @@ main (int    argc,
 {
   state_t state = { 0 };
   bool should_help, should_quit, should_ping, should_sysinit, should_ask_for_password, should_show_splash, should_hide_splash, should_wait, should_be_verbose, report_error, should_get_plugin_path;
+  bool is_connected;
   char *status, *chroot_dir, *ignore_keystroke;
   int exit_code;
 
@@ -823,24 +824,12 @@ main (int    argc,
       return 0;
     }
 
-  if (!ply_boot_client_connect (state.client,
-                                (ply_boot_client_disconnect_handler_t)
-                                on_disconnect, &state))
+  is_connected = ply_boot_client_connect (state.client,
+                                          (ply_boot_client_disconnect_handler_t)
+                                          on_disconnect, &state);
+  if (!is_connected && should_ping)
     {
-      if (should_ping)
-         return 1;
-
-#if 0
-      ply_save_errno ();
-
-      if (errno == ECONNREFUSED)
-        ply_error ("error: boot status daemon not running "
-                   "(use --ping to check ahead of time)");
-      else
-        ply_error ("could not connect to boot status daemon: %m");
-      ply_restore_errno ();
-#endif
-      return errno;
+      return 1;
     }
 
   ply_boot_client_attach_to_event_loop (state.client, state.loop);
-- 
1.6.6


>From 33b761ebe04e032741966afdd4058b717e96b08a Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode at redhat.com>
Date: Mon, 25 Jan 2010 17:07:56 -0500
Subject: [PATCH 3/6] [client] Run ask-for-password command unconditionally

Even if we can't contact the daemon, we should still run the
ask-for-password command.  This is because the command may
do things important for boot up to continue like unlocking
the root partition.
---
 src/client/plymouth.c |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/src/client/plymouth.c b/src/client/plymouth.c
index c00ddda..657feb0 100644
--- a/src/client/plymouth.c
+++ b/src/client/plymouth.c
@@ -186,9 +186,48 @@ on_success (state_t *state)
 }
 
 static void
-on_password_answer_failure (password_answer_state_t *answer_state, ply_boot_client_t *client)
+on_password_answer_failure (password_answer_state_t *answer_state,
+                            ply_boot_client_t       *client)
 {
-  ply_event_loop_exit (answer_state->state->loop, 1);
+  /* plymouthd isn't running for some reason.  If there is a command
+   * to run, we'll run it anyway, because it might be important for
+   * boot up to continue (to decrypt the root partition or whatever)
+   */
+  if (answer_state->command != NULL)
+    {
+      int exit_status;
+      bool command_started;
+
+      exit_status = 127;
+      command_started = false;
+      while (answer_state->number_of_tries_left > 0)
+        {
+          command_started = answer_via_command (answer_state->command, NULL,
+                                                &exit_status);
+
+          if (command_started && WIFEXITED (exit_status) &&
+              WEXITSTATUS (exit_status) == 0)
+            {
+              break;
+            }
+
+          answer_state->number_of_tries_left--;
+        }
+
+      if (command_started && WIFSIGNALED (exit_status))
+        {
+          raise (WTERMSIG (exit_status));
+        }
+      else
+        {
+          ply_event_loop_exit (answer_state->state->loop,
+                               WEXITSTATUS (exit_status));
+        }
+    }
+  else
+    {
+      ply_event_loop_exit (answer_state->state->loop, 1);
+    }
 }
 
 static void
-- 
1.6.6


>From 001a4b823cabba9754094c4197d23a3028483a94 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode at redhat.com>
Date: Tue, 26 Jan 2010 01:03:38 -0500
Subject: [PATCH 4/6] [client] add debugging statements

---
 src/client/plymouth.c |   62 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/src/client/plymouth.c b/src/client/plymouth.c
index 657feb0..c069526 100644
--- a/src/client/plymouth.c
+++ b/src/client/plymouth.c
@@ -125,6 +125,9 @@ answer_via_command (char           *command,
   pid_t pid;
   int command_input_sender_fd, command_input_receiver_fd;
 
+
+  ply_trace ("running command '%s'", command);
+
   /* answer may be NULL which means,
    * "The daemon can't ask the user questions,
    *   do all the prompting from the client"
@@ -189,6 +192,8 @@ static void
 on_password_answer_failure (password_answer_state_t *answer_state,
                             ply_boot_client_t       *client)
 {
+  ply_trace ("password answer failure");
+
   /* plymouthd isn't running for some reason.  If there is a command
    * to run, we'll run it anyway, because it might be important for
    * boot up to continue (to decrypt the root partition or whatever)
@@ -198,6 +203,8 @@ on_password_answer_failure (password_answer_state_t *answer_state,
       int exit_status;
       bool command_started;
 
+      ply_trace ("daemon not available, running command on our own");
+
       exit_status = 127;
       command_started = false;
       while (answer_state->number_of_tries_left > 0)
@@ -208,14 +215,17 @@ on_password_answer_failure (password_answer_state_t *answer_state,
           if (command_started && WIFEXITED (exit_status) &&
               WEXITSTATUS (exit_status) == 0)
             {
+              ply_trace ("command was successful");
               break;
             }
 
+          ply_trace ("command failed");
           answer_state->number_of_tries_left--;
         }
 
       if (command_started && WIFSIGNALED (exit_status))
         {
+          ply_trace ("command died with signal %s", strsignal (WTERMSIG (exit_status)));
           raise (WTERMSIG (exit_status));
         }
       else
@@ -371,22 +381,31 @@ on_multiple_password_answers (password_answer_state_t     *answer_state,
 
   assert (answer_state->command != NULL);
 
+  ply_trace ("on multiple password answers");
+
   need_to_ask_user = true;
 
   if (answers != NULL)
-    for (i = 0; answers[i] != NULL; i++)
-      {
-        bool command_started;
-        exit_status = 127;
-        command_started = answer_via_command (answer_state->command, answers[i],
-                                              &exit_status);
-        if (command_started && WIFEXITED (exit_status) &&
-            WEXITSTATUS (exit_status) == 0)
-          {
-            need_to_ask_user = false;
-            break;
-          }
-      }
+    {
+      ply_trace ("daemon has a few candidate passwords for us to try");
+      for (i = 0; answers[i] != NULL; i++)
+        {
+          bool command_started;
+          exit_status = 127;
+          command_started = answer_via_command (answer_state->command, answers[i],
+                                                &exit_status);
+          if (command_started && WIFEXITED (exit_status) &&
+              WEXITSTATUS (exit_status) == 0)
+            {
+              need_to_ask_user = false;
+              break;
+            }
+        }
+    }
+  else
+    {
+      ply_trace ("daemon has no candidate passwords for us to try");
+    }
 
   if (need_to_ask_user)
     {
@@ -419,6 +438,7 @@ on_disconnect (state_t *state)
       status = 2;
   }
 
+  ply_trace ("disconnect");
   ply_event_loop_exit (state->loop, status);
 }
 
@@ -426,6 +446,9 @@ static void
 on_password_request_execute (password_answer_state_t *password_answer_state,
                              ply_boot_client_t       *client)
 {
+  ply_trace ("executing password request (command %s)",
+             password_answer_state->command);
+
   if (password_answer_state->command != NULL)
     {
       ply_boot_client_ask_daemon_for_cached_passwords (client,
@@ -459,7 +482,8 @@ on_password_request (state_t    *state,
   program = NULL;
   number_of_tries = 0;
   dont_pause = false;
-  
+
+  ply_trace ("Password request");
   ply_command_parser_get_command_options (state->command_parser,
                                           command,
                                           "command", &program,
@@ -866,9 +890,15 @@ main (int    argc,
   is_connected = ply_boot_client_connect (state.client,
                                           (ply_boot_client_disconnect_handler_t)
                                           on_disconnect, &state);
-  if (!is_connected && should_ping)
+  if (!is_connected)
     {
-      return 1;
+      ply_trace ("daemon not running");
+
+      if (should_ping)
+        {
+          ply_trace ("ping failed");
+          return 1;
+        }
     }
 
   ply_boot_client_attach_to_event_loop (state.client, state.loop);
-- 
1.6.6


>From f57fc3dcc56f4dc9731c1fdef1187a5b30e2ea5b Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode at redhat.com>
Date: Tue, 26 Jan 2010 01:10:09 -0500
Subject: [PATCH 5/6] [main] Send CTRL-C instead of NULL for password cancel

We'll want to use NULL for "daemon can't ask"
---
 src/client/plymouth.c |    4 +++-
 src/main.c            |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/client/plymouth.c b/src/client/plymouth.c
index c069526..2d44294 100644
--- a/src/client/plymouth.c
+++ b/src/client/plymouth.c
@@ -41,6 +41,8 @@
 #define PLY_MAX_COMMAND_LINE_SIZE 512
 #endif
 
+#define KEY_CTRL_C ('\100' ^'C')
+
 typedef struct
 {
   ply_event_loop_t     *loop;
@@ -248,7 +250,7 @@ on_password_answer (password_answer_state_t   *answer_state,
   int exit_status;
 
   exit_status = 127;
-  if (answer != NULL)  /* a NULL answer means the user quit */
+  if (answer != NULL && answer[0] != KEY_CTRL_C)  /* a CTRL-C answer means the user canceled */
     {
       if (answer_state->command != NULL)
         {
diff --git a/src/main.c b/src/main.c
index 1103b8e..e3cafc0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -888,7 +888,7 @@ on_keyboard_input (state_t                  *state,
       if (character_size == 1 && ( keyboard_input[0] == '\x3' || keyboard_input[0] == '\x4' ))
         {
           ply_entry_trigger_t* entry_trigger = ply_list_node_get_data (node);
-          ply_trigger_pull (entry_trigger->trigger, NULL);
+          ply_trigger_pull (entry_trigger->trigger, "\x3");
           ply_buffer_clear (state->entry_buffer);
           ply_list_remove_node (state->entry_triggers, node);
           free (entry_trigger);
-- 
1.6.6


>From 8ccb7f17549c3a6e6199420cf90c8c0a2e1af666 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode at redhat.com>
Date: Tue, 26 Jan 2010 01:13:33 -0500
Subject: [PATCH 6/6] [main] Defer password requests to client if daemon unavailable

There are times when plymouthd isn't in a position to ask for
the password (for instance, if the initramfs is about to run
init=/bin/bash or something).  In those cases, any password
requests need to be handled by the client.
---
 src/client/plymouth.c |    4 ++++
 src/main.c            |   18 ++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/client/plymouth.c b/src/client/plymouth.c
index 2d44294..a520901 100644
--- a/src/client/plymouth.c
+++ b/src/client/plymouth.c
@@ -283,6 +283,10 @@ on_password_answer (password_answer_state_t   *answer_state,
           exit_status = 0;
         }
     }
+  else if (answer == NULL)
+    {
+      on_password_answer_failure (answer_state, answer_state->state->client);
+    }
 
   if (WIFSIGNALED (exit_status))
     raise (WTERMSIG (exit_status));
diff --git a/src/main.c b/src/main.c
index e3cafc0..af956ee 100644
--- a/src/main.c
+++ b/src/main.c
@@ -251,8 +251,17 @@ on_ask_for_password (state_t      *state,
                      const char   *prompt,
                      ply_trigger_t *answer)
 {
-  ply_entry_trigger_t *entry_trigger =
-                                  calloc (1, sizeof (ply_entry_trigger_t));
+  ply_entry_trigger_t *entry_trigger;
+
+  /* No splash, client will have to get password
+   */
+  if (state->boot_splash == NULL)
+    {
+      ply_trigger_pull (answer, NULL);
+      return;
+    }
+
+  entry_trigger = calloc (1, sizeof (ply_entry_trigger_t));
   entry_trigger->type = PLY_ENTRY_TRIGGER_TYPE_PASSWORD;
   entry_trigger->prompt = prompt;
   entry_trigger->trigger = answer;
@@ -265,8 +274,9 @@ on_ask_question (state_t      *state,
                  const char   *prompt,
                  ply_trigger_t *answer)
 {
-  ply_entry_trigger_t *entry_trigger =
-                                  calloc (1, sizeof (ply_entry_trigger_t));
+  ply_entry_trigger_t *entry_trigger;
+
+  entry_trigger = calloc (1, sizeof (ply_entry_trigger_t));
   entry_trigger->type = PLY_ENTRY_TRIGGER_TYPE_QUESTION;
   entry_trigger->prompt = prompt;
   entry_trigger->trigger = answer;
-- 
1.6.6



Index: plymouth.spec
===================================================================
RCS file: /cvs/pkgs/rpms/plymouth/F-12/plymouth.spec,v
retrieving revision 1.170
retrieving revision 1.171
diff -u -p -r1.170 -r1.171
--- plymouth.spec	25 Jan 2010 18:24:16 -0000	1.170
+++ plymouth.spec	26 Jan 2010 06:24:05 -0000	1.171
@@ -6,7 +6,7 @@
 Summary: Graphical Boot Animation and Logger
 Name: plymouth
 Version: 0.8.0
-Release: 0.2009.29.09.19.2%{?dist}
+Release: 0.2009.29.09.19.3%{?dist}
 License: GPLv2+
 Group: System Environment/Base
 Source0: http://freedesktop.org/software/plymouth/releases/%{name}-%{version}.tar.bz2
@@ -45,6 +45,7 @@ Patch9: dont-unlink-devnull.patch
 Patch10: fix-hvc0-console.patch
 Patch11: force-raw-mode.patch
 Patch12: keyboard-fixes.patch
+Patch13: work-better-with-passwords-and-custom-init.patch
 
 %description
 Plymouth provides an attractive graphical boot animation in
@@ -265,6 +266,7 @@ plugin.
 %patch10 -p1 -b .fix-hvc0-console
 %patch11 -p1 -b .force-raw-mode
 %patch12 -p1 -b .keyboard-fixes
+%patch13 -p1 -b .work-better-with-passwords-and-custom-init
 
 %build
 %configure --enable-tracing --disable-tests --without-boot-entry \
@@ -486,6 +488,9 @@ fi
 %defattr(-, root, root)
 
 %changelog
+* Tue Jan 26 2010 Ray Strode <rstrode at redhat.com> 0.8.0-0.2009.29.09.19.3
+- Work better with encrypted root and init=foo
+
 * Mon Jan 25 2010 Ray Strode <rstrode at redhat.com> 0.8.0-0.2009.29.09.19.2
 - Backport keyboard fixes
 



More information about the scm-commits mailing list