Blame SOURCES/fix-ask-password-race.patch

01552a
From e0e098f6b1240979f7da473f8966cd8043bce576 Mon Sep 17 00:00:00 2001
01552a
From: Ray Strode <rstrode@redhat.com>
01552a
Date: Thu, 6 Mar 2014 10:02:21 -0500
01552a
Subject: [PATCH] main: call update_display when splash is shown
01552a
01552a
we need to call update display any time a splash is shown,
01552a
because there may be a pending password request.
01552a
01552a
The code attempted to do this in show_splash, but did it before
01552a
the splash was assigned to running state, so function was a noop.
01552a
01552a
This commit moves it a little later in code after the splash is
01552a
properly assigned.
01552a
---
01552a
 src/main.c | 4 +++-
01552a
 1 file changed, 3 insertions(+), 1 deletion(-)
01552a
01552a
diff --git a/src/main.c b/src/main.c
01552a
index ccb8b63..fb91bf2 100644
01552a
--- a/src/main.c
01552a
+++ b/src/main.c
01552a
@@ -294,60 +294,61 @@ load_settings (state_t     *state,
01552a
           ply_trace ("Splash delay is set to %lf", state->splash_delay);
01552a
           state->splash_delay = atof (delay_string);
01552a
         }
01552a
     }
01552a
 
01552a
   settings_loaded = true;
01552a
 out:
01552a
   ply_key_file_free (key_file);
01552a
 
01552a
   return settings_loaded;
01552a
 }
01552a
 
01552a
 static void
01552a
 show_detailed_splash (state_t *state)
01552a
 {
01552a
   ply_boot_splash_t *splash;
01552a
 
01552a
   if (state->boot_splash != NULL)
01552a
     return;
01552a
 
01552a
   ply_trace ("Showing detailed splash screen");
01552a
   splash = show_theme (state, NULL);
01552a
 
01552a
   if (splash == NULL)
01552a
     {
01552a
       ply_trace ("Could not start detailed splash screen, this could be a problem.");
01552a
       return;
01552a
     }
01552a
 
01552a
   state->boot_splash = splash;
01552a
+  update_display (state);
01552a
 }
01552a
 
01552a
 static const char *
01552a
 command_line_get_string_after_prefix (const char *command_line,
01552a
                                       const char *prefix)
01552a
 {
01552a
   char *argument;
01552a
 
01552a
   argument = strstr (command_line, prefix);
01552a
 
01552a
   if (argument == NULL)
01552a
     return NULL;
01552a
 
01552a
   if (argument == command_line ||
01552a
       argument[-1] == ' ')
01552a
     return argument + strlen (prefix);
01552a
 
01552a
   return NULL;
01552a
 }
01552a
 
01552a
 static bool
01552a
 command_line_has_argument (const char *command_line,
01552a
                            const char *argument)
01552a
 {
01552a
     const char *string;
01552a
 
01552a
     string = command_line_get_string_after_prefix (command_line, argument);
01552a
 
01552a
     if (string == NULL)
01552a
       return false;
01552a
@@ -450,60 +451,62 @@ show_default_splash (state_t *state)
01552a
     {
01552a
       ply_trace ("Trying distribution default splash");
01552a
       state->boot_splash = show_theme (state, state->distribution_default_splash_path);
01552a
     }
01552a
 
01552a
   if (state->boot_splash == NULL)
01552a
     {
01552a
       ply_trace ("Trying old scheme for default splash");
01552a
       state->boot_splash = show_theme (state, PLYMOUTH_THEME_PATH "default.plymouth");
01552a
     }
01552a
 
01552a
   if (state->boot_splash == NULL)
01552a
     {
01552a
       ply_trace ("Could not start default splash screen,"
01552a
                  "showing text splash screen");
01552a
       state->boot_splash = show_theme (state, PLYMOUTH_THEME_PATH "text/text.plymouth");
01552a
     }
01552a
 
01552a
   if (state->boot_splash == NULL)
01552a
     {
01552a
       ply_trace ("Could not start text splash screen,"
01552a
                  "showing built-in splash screen");
01552a
       state->boot_splash = show_theme (state, NULL);
01552a
     }
01552a
 
01552a
   if (state->boot_splash == NULL)
01552a
     {
01552a
       ply_error ("plymouthd: could not start boot splash: %m");
01552a
       return;
01552a
     }
01552a
+
01552a
+  update_display (state);
01552a
 }
01552a
 
01552a
 static void
01552a
 cancel_pending_delayed_show (state_t *state)
01552a
 {
01552a
   if (isnan (state->splash_delay))
01552a
     return;
01552a
 
01552a
   ply_event_loop_stop_watching_for_timeout (state->loop,
01552a
                                             (ply_event_loop_timeout_handler_t)
01552a
                                             show_splash,
01552a
                                             state);
01552a
   state->splash_delay = NAN;
01552a
 }
01552a
 
01552a
 static void
01552a
 on_ask_for_password (state_t      *state,
01552a
                      const char   *prompt,
01552a
                      ply_trigger_t *answer)
01552a
 {
01552a
   ply_entry_trigger_t *entry_trigger;
01552a
 
01552a
   if (state->boot_splash == NULL)
01552a
     {
01552a
       /* Waiting to be shown, boot splash will
01552a
        * arrive shortly so just sit tight
01552a
        */
01552a
       if (state->is_shown)
01552a
         {
01552a
           bool has_open_seats;
01552a
@@ -1671,61 +1674,60 @@ show_theme (state_t           *state,
01552a
     splash = load_theme (state, theme_path);
01552a
   else
01552a
     splash = load_built_in_theme (state);
01552a
 
01552a
   if (splash == NULL)
01552a
     return NULL;
01552a
 
01552a
   attach_splash_to_seats (state, splash);
01552a
   ply_device_manager_activate_renderers (state->device_manager);
01552a
 
01552a
   if (state->mode == PLY_MODE_SHUTDOWN)
01552a
     splash_mode = PLY_BOOT_SPLASH_MODE_SHUTDOWN;
01552a
   else
01552a
     splash_mode = PLY_BOOT_SPLASH_MODE_BOOT_UP;
01552a
 
01552a
   if (!ply_boot_splash_show (splash, splash_mode))
01552a
     {
01552a
       ply_save_errno ();
01552a
       ply_boot_splash_free (splash);
01552a
       ply_restore_errno ();
01552a
       return NULL;
01552a
     }
01552a
 
01552a
 #ifdef PLY_ENABLE_SYSTEMD_INTEGRATION
01552a
   if (state->is_attached)
01552a
     tell_systemd_to_print_details (state);
01552a
 #endif
01552a
 
01552a
   ply_device_manager_activate_keyboards (state->device_manager);
01552a
   show_messages (state);
01552a
-  update_display (state);
01552a
 
01552a
   return splash;
01552a
 }
01552a
 
01552a
 static bool
01552a
 attach_to_running_session (state_t *state)
01552a
 {
01552a
   ply_terminal_session_t *session;
01552a
   ply_terminal_session_flags_t flags;
01552a
   bool should_be_redirected;
01552a
 
01552a
   flags = 0;
01552a
 
01552a
   should_be_redirected = !state->no_boot_log;
01552a
 
01552a
   if (should_be_redirected)
01552a
     flags |= PLY_TERMINAL_SESSION_FLAGS_REDIRECT_CONSOLE;
01552a
 
01552a
  if (state->session == NULL)
01552a
    {
01552a
      ply_trace ("creating new terminal session");
01552a
      session = ply_terminal_session_new (NULL);
01552a
 
01552a
      ply_terminal_session_attach_to_event_loop (session, state->loop);
01552a
    }
01552a
  else
01552a
    {
01552a
      session = state->session;
01552a
      ply_trace ("session already created");
01552a
    }
01552a
-- 
01552a
1.8.3.1
01552a