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