|
|
ff86aa |
From be52bd06949cb2a386fda147d24155581708ef1a Mon Sep 17 00:00:00 2001
|
|
|
ff86aa |
From: Ray Strode <rstrode@redhat.com>
|
|
|
ff86aa |
Date: Fri, 10 Oct 2014 13:30:56 -0400
|
|
|
ff86aa |
Subject: [PATCH] main: show splash when init=/bin/sh
|
|
|
ff86aa |
|
|
|
ff86aa |
but quit after switch root. The keeps luks
|
|
|
ff86aa |
working.
|
|
|
ff86aa |
---
|
|
|
ff86aa |
src/main.c | 23 ++++++++++++++++++++---
|
|
|
ff86aa |
1 file changed, 20 insertions(+), 3 deletions(-)
|
|
|
ff86aa |
|
|
|
ff86aa |
diff --git a/src/main.c b/src/main.c
|
|
|
ff86aa |
index fb91bf2..4101550 100644
|
|
|
ff86aa |
--- a/src/main.c
|
|
|
ff86aa |
+++ b/src/main.c
|
|
|
ff86aa |
@@ -135,60 +135,64 @@ static ply_boot_splash_t *load_theme (state_t *state,
|
|
|
ff86aa |
static ply_boot_splash_t *show_theme (state_t *state,
|
|
|
ff86aa |
const char *theme_path);
|
|
|
ff86aa |
|
|
|
ff86aa |
static void attach_splash_to_seats (state_t *state,
|
|
|
ff86aa |
ply_boot_splash_t *splash);
|
|
|
ff86aa |
static bool attach_to_running_session (state_t *state);
|
|
|
ff86aa |
static void detach_from_running_session (state_t *state);
|
|
|
ff86aa |
static void on_escape_pressed (state_t *state);
|
|
|
ff86aa |
static void dump_details_and_quit_splash (state_t *state);
|
|
|
ff86aa |
static void update_display (state_t *state);
|
|
|
ff86aa |
|
|
|
ff86aa |
static void on_error_message (ply_buffer_t *debug_buffer,
|
|
|
ff86aa |
const void *bytes,
|
|
|
ff86aa |
size_t number_of_bytes);
|
|
|
ff86aa |
static ply_buffer_t *debug_buffer;
|
|
|
ff86aa |
static char *debug_buffer_path = NULL;
|
|
|
ff86aa |
static char *pid_file = NULL;
|
|
|
ff86aa |
static void toggle_between_splash_and_details (state_t *state);
|
|
|
ff86aa |
#ifdef PLY_ENABLE_SYSTEMD_INTEGRATION
|
|
|
ff86aa |
static void tell_systemd_to_print_details (state_t *state);
|
|
|
ff86aa |
static void tell_systemd_to_stop_printing_details (state_t *state);
|
|
|
ff86aa |
#endif
|
|
|
ff86aa |
static const char * get_cache_file_for_mode (ply_mode_t mode);
|
|
|
ff86aa |
static void on_escape_pressed (state_t *state);
|
|
|
ff86aa |
static void on_enter (state_t *state,
|
|
|
ff86aa |
const char *line);
|
|
|
ff86aa |
static void on_keyboard_input (state_t *state,
|
|
|
ff86aa |
const char *keyboard_input,
|
|
|
ff86aa |
size_t character_size);
|
|
|
ff86aa |
static void on_backspace (state_t *state);
|
|
|
ff86aa |
+static void on_quit (state_t *state,
|
|
|
ff86aa |
+ bool retain_splash,
|
|
|
ff86aa |
+ ply_trigger_t *quit_trigger);
|
|
|
ff86aa |
+static bool sh_is_init (state_t *state);
|
|
|
ff86aa |
|
|
|
ff86aa |
static void
|
|
|
ff86aa |
on_session_output (state_t *state,
|
|
|
ff86aa |
const char *output,
|
|
|
ff86aa |
size_t size)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_buffer_append_bytes (state->boot_buffer, output, size);
|
|
|
ff86aa |
if (state->boot_splash != NULL)
|
|
|
ff86aa |
ply_boot_splash_update_output (state->boot_splash,
|
|
|
ff86aa |
output, size);
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
static void
|
|
|
ff86aa |
on_session_hangup (state_t *state)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_trace ("got hang up on terminal session fd");
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
static void
|
|
|
ff86aa |
on_update (state_t *state,
|
|
|
ff86aa |
const char *status)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_trace ("updating status to '%s'", status);
|
|
|
ff86aa |
ply_progress_status_update (state->progress,
|
|
|
ff86aa |
status);
|
|
|
ff86aa |
if (state->boot_splash != NULL)
|
|
|
ff86aa |
ply_boot_splash_update_status (state->boot_splash,
|
|
|
ff86aa |
status);
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
@@ -626,60 +630,67 @@ on_ignore_keystroke (state_t *state,
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_keystroke_watch_t* keystroke_trigger = ply_list_node_get_data (node);
|
|
|
ff86aa |
if ((!keystroke_trigger->keys && !keys) ||
|
|
|
ff86aa |
(keystroke_trigger->keys && keys && strcmp(keystroke_trigger->keys, keys)==0))
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_trigger_pull (keystroke_trigger->trigger, NULL);
|
|
|
ff86aa |
ply_list_remove_node (state->keystroke_triggers, node);
|
|
|
ff86aa |
return;
|
|
|
ff86aa |
}
|
|
|
ff86aa |
}
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
static void
|
|
|
ff86aa |
on_progress_pause (state_t *state)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_trace ("pausing progress");
|
|
|
ff86aa |
ply_progress_pause (state->progress);
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
static void
|
|
|
ff86aa |
on_progress_unpause (state_t *state)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_trace ("unpausing progress");
|
|
|
ff86aa |
ply_progress_unpause (state->progress);
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
static void
|
|
|
ff86aa |
on_newroot (state_t *state,
|
|
|
ff86aa |
const char *root_dir)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
+ if (sh_is_init (state))
|
|
|
ff86aa |
+ {
|
|
|
ff86aa |
+ ply_trace ("new root mounted at \"%s\", exiting since init= a shell", root_dir);
|
|
|
ff86aa |
+ on_quit (state, false, ply_trigger_new (NULL));
|
|
|
ff86aa |
+ return;
|
|
|
ff86aa |
+ }
|
|
|
ff86aa |
+
|
|
|
ff86aa |
ply_trace ("new root mounted at \"%s\", switching to it", root_dir);
|
|
|
ff86aa |
chdir(root_dir);
|
|
|
ff86aa |
chroot(".");
|
|
|
ff86aa |
chdir("/");
|
|
|
ff86aa |
ply_progress_load_cache (state->progress, get_cache_file_for_mode (state->mode));
|
|
|
ff86aa |
if (state->boot_splash != NULL)
|
|
|
ff86aa |
ply_boot_splash_root_mounted (state->boot_splash);
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
static const char *
|
|
|
ff86aa |
get_cache_file_for_mode (ply_mode_t mode)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
const char *filename;
|
|
|
ff86aa |
|
|
|
ff86aa |
switch ((int)mode)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
case PLY_MODE_BOOT:
|
|
|
ff86aa |
filename = BOOT_DURATION_FILE;
|
|
|
ff86aa |
break;
|
|
|
ff86aa |
case PLY_MODE_SHUTDOWN:
|
|
|
ff86aa |
filename = SHUTDOWN_DURATION_FILE;
|
|
|
ff86aa |
break;
|
|
|
ff86aa |
case PLY_MODE_UPDATES:
|
|
|
ff86aa |
filename = NULL;
|
|
|
ff86aa |
break;
|
|
|
ff86aa |
default:
|
|
|
ff86aa |
ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__);
|
|
|
ff86aa |
abort ();
|
|
|
ff86aa |
break;
|
|
|
ff86aa |
}
|
|
|
ff86aa |
@@ -781,70 +792,76 @@ prepare_logging (state_t *state)
|
|
|
ff86aa |
if (state->number_of_errors > 0)
|
|
|
ff86aa |
spool_error (state);
|
|
|
ff86aa |
}
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
static void
|
|
|
ff86aa |
on_system_initialized (state_t *state)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_trace ("system now initialized, opening log");
|
|
|
ff86aa |
state->system_initialized = true;
|
|
|
ff86aa |
|
|
|
ff86aa |
prepare_logging (state);
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
static void
|
|
|
ff86aa |
on_error (state_t *state)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_trace ("encountered error during boot up");
|
|
|
ff86aa |
|
|
|
ff86aa |
if (state->system_initialized && state->number_of_errors == 0)
|
|
|
ff86aa |
spool_error (state);
|
|
|
ff86aa |
else
|
|
|
ff86aa |
ply_trace ("not spooling because number of errors %d", state->number_of_errors);
|
|
|
ff86aa |
|
|
|
ff86aa |
state->number_of_errors++;
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
static bool
|
|
|
ff86aa |
plymouth_should_ignore_show_splash_calls (state_t *state)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
- const char *init_string;
|
|
|
ff86aa |
- size_t length;
|
|
|
ff86aa |
-
|
|
|
ff86aa |
ply_trace ("checking if plymouth should be running");
|
|
|
ff86aa |
if (state->mode != PLY_MODE_BOOT || command_line_has_argument (state->kernel_command_line, "plymouth.force-splash"))
|
|
|
ff86aa |
return false;
|
|
|
ff86aa |
|
|
|
ff86aa |
if (command_line_has_argument (state->kernel_command_line, "plymouth.ignore-show-splash"))
|
|
|
ff86aa |
return true;
|
|
|
ff86aa |
|
|
|
ff86aa |
+ return false;
|
|
|
ff86aa |
+}
|
|
|
ff86aa |
+
|
|
|
ff86aa |
+static bool
|
|
|
ff86aa |
+sh_is_init (state_t *state)
|
|
|
ff86aa |
+{
|
|
|
ff86aa |
+ const char *init_string;
|
|
|
ff86aa |
+ size_t length;
|
|
|
ff86aa |
+
|
|
|
ff86aa |
init_string = command_line_get_string_after_prefix (state->kernel_command_line, "init=");
|
|
|
ff86aa |
|
|
|
ff86aa |
if (init_string)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
length = strcspn (init_string, " \n");
|
|
|
ff86aa |
if (length > 2 && ply_string_has_prefix (init_string + length - 2, "sh"))
|
|
|
ff86aa |
return true;
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
return false;
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
static bool
|
|
|
ff86aa |
plymouth_should_show_default_splash (state_t *state)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_trace ("checking if plymouth should show default splash");
|
|
|
ff86aa |
|
|
|
ff86aa |
const char const *strings[] = {
|
|
|
ff86aa |
"single", "1", "s", "S", "-S", NULL
|
|
|
ff86aa |
};
|
|
|
ff86aa |
int i;
|
|
|
ff86aa |
|
|
|
ff86aa |
if (state->should_force_details)
|
|
|
ff86aa |
return false;
|
|
|
ff86aa |
|
|
|
ff86aa |
for (i = 0; strings[i] != NULL; i++)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
if (command_line_has_argument (state->kernel_command_line, strings[i]))
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_trace ("no default splash because kernel command line has option \"%s\"", strings[i]);
|
|
|
ff86aa |
--
|
|
|
ff86aa |
1.8.3.1
|
|
|
ff86aa |
|