plymouth/plymouth-redirect-null.patch
Raymond Wooninck cd407a8cec Accepting request 178568 from home:fcrozat:branches:Base:System
- Add plymouth-close: do not try to close negative fd.
- Add plymouth-close-unredirect.patch: do not leak fd when stopping
  redirection of /dev/console (bnc#811185)
- Add plymouth-redirect-null.patch: redirect plymouth standard io
  to /dev/null (bnc#811185)
- Add plymouth-exit-code.patch: ignore exit code in ExecStartPost.
- Add plymouth-terminal-session-close.patch: do no try to close
  terminal session fd if already closed.

OBS-URL: https://build.opensuse.org/request/show/178568
OBS-URL: https://build.opensuse.org/package/show/Base:System/plymouth?expand=0&rev=107
2013-06-11 20:12:23 +00:00

177 lines
5.5 KiB
Diff

From 0d610f91e2bfc85f2e9a4c037adc91306e4faf62 Mon Sep 17 00:00:00 2001
From: Frederic Crozat <fcrozat@suse.com>
Date: Mon, 10 Jun 2013 18:44:08 +0200
Subject: [PATCH] main: redirect standard io to /dev/null
do not redirect standard io to console tty anymore, it can cause issue
with Xorg grabbing tty
(https://bugzilla.novell.com/show_bug.cgi?id=811185).
Initial patch by Ray Strode
---
src/main.c | 87 +++++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 55 insertions(+), 32 deletions(-)
diff --git a/src/main.c b/src/main.c
index e0d087c..2a9c84d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -616,7 +616,7 @@ get_cache_file_for_mode (ply_mode_t mode)
filename = NULL;
break;
default:
- fprintf (stderr, "Unhandled case in %s line %d\n", __FILE__, __LINE__);
+ ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__);
abort ();
break;
}
@@ -640,7 +640,7 @@ get_log_file_for_mode (ply_mode_t mode)
filename = _PATH_DEVNULL;
break;
default:
- fprintf (stderr, "Unhandled case in %s line %d\n", __FILE__, __LINE__);
+ ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__);
abort ();
break;
}
@@ -664,7 +664,7 @@ get_log_spool_file_for_mode (ply_mode_t mode)
filename = NULL;
break;
default:
- fprintf (stderr, "Unhandled case in %s line %d\n", __FILE__, __LINE__);
+ ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__);
abort ();
break;
}
@@ -1098,6 +1098,13 @@ deactivate_splash (state_t *state)
ply_terminal_stop_watching_for_vt_changes (state->local_console_terminal);
ply_terminal_set_buffered_input (state->local_console_terminal);
ply_terminal_ignore_mode_changes (state->local_console_terminal, true);
+ ply_terminal_close (state->local_console_terminal);
+ }
+
+ /* do not let any tty opened where we could write after deactivate */
+ if (command_line_has_argument (state->kernel_command_line, "plymouth.debug"))
+ {
+ ply_logger_close_file (ply_logger_get_error_default ());
}
state->is_inactive = true;
@@ -1191,6 +1198,7 @@ on_reactivate (state_t *state)
if (state->local_console_terminal != NULL)
{
+ ply_terminal_open (state->local_console_terminal);
ply_terminal_watch_for_vt_changes (state->local_console_terminal);
ply_terminal_set_unbuffered_input (state->local_console_terminal);
ply_terminal_ignore_mode_changes (state->local_console_terminal, false);
@@ -1890,6 +1898,33 @@ check_verbosity (state_t *state)
ply_logger_set_output_fd (ply_logger_get_error_default (), fd);
}
free (stream_copy);
+ } else {
+ const char* device;
+ char *file;
+
+ if (state->kernel_console_tty != NULL)
+ device = state->kernel_console_tty;
+ else
+ device = state->default_tty;
+
+ ply_trace ("redirecting debug output to %s", device);
+
+ if (strncmp (device, "/dev/", strlen ("/dev/")) == 0)
+ file = strdup (device);
+ else
+ asprintf (&file, "/dev/%s", device);
+
+ fd = open (file, O_RDWR | O_APPEND);
+
+ if (fd < 0)
+ {
+ ply_trace ("could not redirected debug output to %s: %m", device);
+ }
+ else {
+ ply_logger_set_output_fd (ply_logger_get_error_default (), fd);
+ }
+
+ free (file);
}
}
else
@@ -2157,21 +2192,11 @@ check_for_consoles (state_t *state,
}
static bool
-redirect_standard_io_to_device (const char *device)
+redirect_standard_io_to_dev_null (void)
{
int fd;
- char *file;
- ply_trace ("redirecting stdio to %s", device);
-
- if (strncmp (device, "/dev/", strlen ("/dev/")) == 0)
- file = strdup (device);
- else
- asprintf (&file, "/dev/%s", device);
-
- fd = open (file, O_RDWR | O_APPEND);
-
- free (file);
+ fd = open ("/dev/null", O_RDWR | O_APPEND);
if (fd < 0)
return false;
@@ -2214,19 +2239,6 @@ initialize_environment (state_t *state)
if (!get_kernel_command_line (state))
return false;
- check_verbosity (state);
- check_logging (state);
-
- ply_trace ("source built on %s", __DATE__);
-
- state->keystroke_triggers = ply_list_new ();
- state->entry_triggers = ply_list_new ();
- state->entry_buffer = ply_buffer_new();
- state->pixel_displays = ply_list_new ();
- state->text_displays = ply_list_new ();
- state->messages = ply_list_new ();
- state->keyboard = NULL;
-
if (!state->default_tty)
{
if (state->mode == PLY_MODE_SHUTDOWN)
@@ -2247,12 +2259,23 @@ initialize_environment (state_t *state)
}
}
+ check_verbosity (state);
+ check_logging (state);
+
+ ply_trace ("source built on %s", __DATE__);
+
+ state->keystroke_triggers = ply_list_new ();
+ state->entry_triggers = ply_list_new ();
+ state->entry_buffer = ply_buffer_new();
+ state->pixel_displays = ply_list_new ();
+ state->text_displays = ply_list_new ();
+ state->messages = ply_list_new ();
+ state->keyboard = NULL;
+
+
check_for_consoles (state, state->default_tty, false);
- if (state->kernel_console_tty != NULL)
- redirect_standard_io_to_device (state->kernel_console_tty);
- else
- redirect_standard_io_to_device (state->default_tty);
+ redirect_standard_io_to_dev_null ();
ply_trace ("Making sure " PLYMOUTH_RUNTIME_DIR " exists");
if (!ply_create_directory (PLYMOUTH_RUNTIME_DIR))
--
1.8.1.4