From 6ff9fce16118cf865f362b9ab7a327edd04ef1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= Date: Tue, 23 Aug 2011 14:54:04 +0200 Subject: [PATCH] su: fix shell suspend in tcsh (#597928) --- coreutils-8.5-pam.patch | 22 ++++++++++++++++------ coreutils.spec | 5 ++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/coreutils-8.5-pam.patch b/coreutils-8.5-pam.patch index 71b85e7..8a924b2 100644 --- a/coreutils-8.5-pam.patch +++ b/coreutils-8.5-pam.patch @@ -106,7 +106,7 @@ index f8f5b61..811aad7 100644 static struct option const longopts[] = { {"command", required_argument, NULL, 'c'}, -@@ -200,7 +224,164 @@ log_su (struct passwd const *pw, bool successful) +@@ -200,7 +224,174 @@ log_su (struct passwd const *pw, bool successful) } #endif @@ -168,7 +168,7 @@ index f8f5b61..811aad7 100644 +create_watching_parent (void) +{ + pid_t child; -+ sigset_t ourset; ++ sigset_t ourset, blockset; + int status = 0; + + retval = pam_open_session (pamh, 0); @@ -230,7 +230,17 @@ index f8f5b61..811aad7 100644 + + if (pid != (pid_t)-1 && WIFSTOPPED (status)) + { ++ /* tcsh sends SIGTSTP to the process group, and so is already pending */ + kill (getpid (), SIGSTOP); ++ if (WSTOPSIG(status) != SIGSTOP) { ++ sigemptyset(&blockset); ++ if (sigaddset(&blockset, WSTOPSIG(status)) || ++ sigprocmask(SIG_UNBLOCK, &blockset, &ourset) || ++ sigprocmask(SIG_SETMASK, &ourset, NULL)) ++ { ++ error (0, errno, _("cannot set signal handler")); ++ } ++ } + /* once we get here, we must have resumed */ + kill (pid, SIGCONT); + } @@ -271,7 +281,7 @@ index f8f5b61..811aad7 100644 Return true if the user gives the correct password for entry PW, false if not. Return true without asking for a password if run by UID 0 or if PW has an empty password. */ -@@ -208,10 +389,52 @@ log_su (struct passwd const *pw, bool successful) +@@ -208,10 +399,52 @@ log_su (struct passwd const *pw, bool successful) static bool correct_password (const struct passwd *pw) { @@ -325,7 +335,7 @@ index f8f5b61..811aad7 100644 endspent (); if (sp) -@@ -232,6 +455,7 @@ correct_password (const struct passwd *pw) +@@ -232,6 +465,7 @@ correct_password (const struct passwd *pw) encrypted = crypt (unencrypted, correct); memset (unencrypted, 0, strlen (unencrypted)); return STREQ (encrypted, correct); @@ -333,7 +343,7 @@ index f8f5b61..811aad7 100644 } /* Update `environ' for the new shell based on PW, with SHELL being -@@ -274,19 +498,41 @@ modify_environment (const struct passwd *pw, const char *shell) +@@ -274,19 +508,41 @@ modify_environment (const struct passwd *pw, const char *shell) } } } @@ -377,7 +387,7 @@ index f8f5b61..811aad7 100644 if (setgid (pw->pw_gid)) error (EXIT_CANCELED, errno, _("cannot set group id")); if (setuid (pw->pw_uid)) -@@ -500,9 +746,21 @@ main (int argc, char **argv) +@@ -500,9 +756,21 @@ main (int argc, char **argv) shell = NULL; } shell = xstrdup (shell ? shell : pw->pw_shell); diff --git a/coreutils.spec b/coreutils.spec index 6ae3334..3d5c6a1 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 8.12 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv3+ Group: System Environment/Base Url: http://www.gnu.org/software/coreutils/ @@ -335,6 +335,9 @@ fi %{_libdir}/coreutils %changelog +* Tue Aug 23 2011 Ondrej Vasik - 8.12-6 +- su: fix shell suspend in tcsh (#597928) + * Thu Aug 18 2011 Ondrej Vasik - 8.12-5 - variable "u" should be static in uname processor type patch