[coreutils/f16] su: fix shell suspend in tcsh (#597928)

Kamil Dudka kdudka at fedoraproject.org
Mon Jan 30 12:03:58 UTC 2012


commit 686d7b36358a7a3cca1204a919d26c128ff784cb
Author: Ondřej Vašík <ovasik at redhat.com>
Date:   Tue Aug 23 14:54:04 2011 +0200

    su: fix shell suspend in tcsh (#597928)

 coreutils-8.5-pam.patch |   22 ++++++++++++++++------
 coreutils.spec          |    1 +
 2 files changed, 17 insertions(+), 6 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 7ad6d6a..91f0f5c 100644
--- a/coreutils.spec
+++ b/coreutils.spec
@@ -336,6 +336,7 @@ fi
 %changelog
 * Mon Jan 30 2012 Kamil Dudka <kdudka at redhat.com> - 8.12-6
 - do not use shebang in sourced colorls.csh
+- su: fix shell suspend in tcsh (#597928)
 
 * Sun Jan 29 2012 Kamil Dudka <kdudka at redhat.com> - 8.12-5
 - output the correct ownership in chown -v (upstream bug #10636)


More information about the scm-commits mailing list