diff --git a/plymouth-close-unredirect.patch b/plymouth-close-unredirect.patch new file mode 100644 index 0000000..8a75926 --- /dev/null +++ b/plymouth-close-unredirect.patch @@ -0,0 +1,34 @@ +From 41560df672d0aeb954874b6d0aa81849ab35ca71 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Mon, 10 Jun 2013 10:44:56 -0400 +Subject: [PATCH] terminal-session: plug /dev/console fd leak + +When we stop redirecting console messages, we temporarly open +/dev/console. We don't ever close it. + +This commit fixes that. +--- + src/libply/ply-terminal-session.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/libply/ply-terminal-session.c b/src/libply/ply-terminal-session.c +index 3d43709..e7377e9 100644 +--- a/src/libply/ply-terminal-session.c ++++ b/src/libply/ply-terminal-session.c +@@ -213,8 +213,12 @@ ply_terminal_session_unredirect_console (ply_terminal_session_t *session) + assert (session->console_is_redirected); + + fd = open ("/dev/console", O_RDWR | O_NOCTTY); +- if (fd >= 0) ++ if (fd >= 0) { + ioctl (fd, TIOCCONS); ++ close (fd); ++ } else { ++ ply_trace ("couldn't open /dev/console to stop redirecting it: %m"); ++ } + + session->console_is_redirected = false; + } +-- +1.8.1.4 + diff --git a/plymouth-close.patch b/plymouth-close.patch new file mode 100644 index 0000000..cd380e0 --- /dev/null +++ b/plymouth-close.patch @@ -0,0 +1,27 @@ +From 5784c8ff0c425b0948b653541c58fb8493515aa7 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Thu, 6 Jun 2013 10:08:55 -0400 +Subject: [PATCH] logger: don't close already logger if already closed + +This prevents close(-1) from showing up in strace +--- + src/libply/ply-logger.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/libply/ply-logger.c b/src/libply/ply-logger.c +index 5ea0b5e..ec5b6e5 100644 +--- a/src/libply/ply-logger.c ++++ b/src/libply/ply-logger.c +@@ -357,6 +357,9 @@ ply_logger_close_file (ply_logger_t *logger) + { + assert (logger != NULL); + ++ if (logger->output_fd < 0) ++ return; ++ + close (logger->output_fd); + ply_logger_set_output_fd (logger, -1); + } +-- +1.8.1.4 + diff --git a/plymouth-exit-code.patch b/plymouth-exit-code.patch new file mode 100644 index 0000000..7980785 --- /dev/null +++ b/plymouth-exit-code.patch @@ -0,0 +1,22 @@ +From 95a4fd9cb721f3e8355a944db85462ef15603e1f Mon Sep 17 00:00:00 2001 +From: Frederic Crozat +Date: Mon, 10 Jun 2013 18:54:47 +0200 +Subject: [PATCH] systemd: make sure to ignore all exit codes in ExecStartPost + +--- + systemd-units/plymouth-start.service.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: plymouth-0.8.8_git201304161248/systemd-units/plymouth-start.service.in +=================================================================== +--- plymouth-0.8.8_git201304161248.orig/systemd-units/plymouth-start.service.in ++++ plymouth-0.8.8_git201304161248/systemd-units/plymouth-start.service.in +@@ -8,7 +8,7 @@ ConditionKernelCommandLine=!plymouth.ena + + [Service] + ExecStart=@PLYMOUTH_DAEMON_DIR@/plymouthd --mode=boot --pid-file=@plymouthruntimedir@/pid --attach-to-session +-ExecStartPost=-@UDEVADM@ settle --timeout=30 --exit-if-exists=/sys/class/drm/card0/dev ; @UDEVADM@ settle --timeout=30 --exit-if-exists=/sys/class/graphics/fb0/dev ; @PLYMOUTH_CLIENT_DIR@/plymouth show-splash ++ExecStartPost=-@UDEVADM@ settle --timeout=30 --exit-if-exists=/sys/class/drm/card0/dev ; -@UDEVADM@ settle --timeout=30 --exit-if-exists=/sys/class/graphics/fb0/dev ; -@PLYMOUTH_CLIENT_DIR@/plymouth show-splash + Type=forking + KillMode=none + SendSIGKILL=no diff --git a/plymouth-redirect-null.patch b/plymouth-redirect-null.patch new file mode 100644 index 0000000..3b63747 --- /dev/null +++ b/plymouth-redirect-null.patch @@ -0,0 +1,176 @@ +From 0d610f91e2bfc85f2e9a4c037adc91306e4faf62 Mon Sep 17 00:00:00 2001 +From: Frederic Crozat +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 + diff --git a/plymouth-terminal-session-close.patch b/plymouth-terminal-session-close.patch new file mode 100644 index 0000000..1c0a087 --- /dev/null +++ b/plymouth-terminal-session-close.patch @@ -0,0 +1,27 @@ +From 5ed074df62fe13acd491079c2156907ba9e5b3be Mon Sep 17 00:00:00 2001 +From: Frederic Crozat +Date: Mon, 10 Jun 2013 18:29:57 +0200 +Subject: [PATCH] terminal-session: don't close session fd if already closed + +Prevents close(-1) from showing up in strace +--- + src/libply/ply-terminal-session.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/libply/ply-terminal-session.c b/src/libply/ply-terminal-session.c +index e7377e9..0bdb985 100644 +--- a/src/libply/ply-terminal-session.c ++++ b/src/libply/ply-terminal-session.c +@@ -148,7 +148,8 @@ ply_terminal_session_free (ply_terminal_session_t *session) + + ply_free_string_array (session->argv); + +- close (session->pseudoterminal_master_fd); ++ if (session->pseudoterminal_master_fd >= 0) ++ close (session->pseudoterminal_master_fd); + free (session); + } + +-- +1.8.1.4 + diff --git a/plymouth.changes b/plymouth.changes index 63bab67..c8f1dcc 100644 --- a/plymouth.changes +++ b/plymouth.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Tue Jun 11 16:09:57 UTC 2013 - fcrozat@suse.com + +- 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. + ------------------------------------------------------------------- Sun May 12 21:56:30 UTC 2013 - crrodriguez@opensuse.org diff --git a/plymouth.spec b/plymouth.spec index e51de49..b7e4e74 100644 --- a/plymouth.spec +++ b/plymouth.spec @@ -43,6 +43,16 @@ Patch9: plymouth-dracut-path.patch Patch10: 0001-Some-greenish-openSUSE-colors.patch # PATCH-OPENSUSE -- plymouth-correct-runtime-dir.patch tittiatcoke@gmail.com -- make sure the runtime directory is /run and not /var/run Patch16: plymouth-correct-runtime-dir.patch +# PATCH-FIX-UPSTREAM plymouth-close.patch fcrozat@suse.com -- do not try to close negative fd +Patch17: plymouth-close.patch +# PATCH-FIX-UPSTREAM plymouth-close-deactivate.patch bnc#811185 fcrozat@suse.com -- close stdout/stderr on deactivate +Patch18: plymouth-close-unredirect.patch +# PATCH-FIX-UPSTREAM plymouth-redirect-null.patch bnc#811185 fcrozat@suse.com -- redirect standard io to /dev/null +Patch19: plymouth-redirect-null.patch +# PATCH-FIX-UPSTREAM plymouth-exit-code.patch fcrozat@suse.com -- ensure all exit code are ignored in ExecStartPost +Patch20: plymouth-exit-code.patch +# PATCH-FIX-UPSTREAM plymouth-terminal-session-close.patch fcrozat@suse.com -- do not close already closed terminal session fd +Patch21: plymouth-terminal-session-close.patch BuildRequires: automake BuildRequires: kernel-headers BuildRequires: libtool @@ -314,6 +324,11 @@ plugin. %patch9 -p0 %patch10 -p1 %patch16 -p1 +%patch17 -p1 +%patch18 -p1 +%patch19 -p1 +%patch20 -p1 +%patch21 -p1 # replace builddate with patch0date sed -i "s/__DATE__/\"$(stat -c %y %{_sourcedir}/%{name}.changes)\"/" src/main.c