fix exit status of terminated child processes in su with pam(#559098)

This commit is contained in:
Ondrej Vasik 2010-02-12 09:28:31 +00:00
parent 5e50360426
commit edc268cf05
2 changed files with 29 additions and 24 deletions

View File

@ -1,6 +1,6 @@
diff -urNp coreutils-8.1-orig/configure.ac coreutils-8.1/configure.ac
--- coreutils-8.1-orig/configure.ac 2009-11-14 15:01:44.000000000 +0100
+++ coreutils-8.1/configure.ac 2009-11-20 13:00:10.000000000 +0100
diff -urNp coreutils-8.4-orig/configure.ac coreutils-8.4/configure.ac
--- coreutils-8.4-orig/configure.ac 2010-01-11 18:20:42.000000000 +0100
+++ coreutils-8.4/configure.ac 2010-02-12 10:17:46.000000000 +0100
@@ -126,6 +126,13 @@ if test "$gl_gcc_warnings" = yes; then
AC_SUBST([GNULIB_WARN_CFLAGS])
fi
@ -15,10 +15,10 @@ diff -urNp coreutils-8.1-orig/configure.ac coreutils-8.1/configure.ac
AC_FUNC_FORK
optional_bin_progs=
diff -urNp coreutils-8.1-orig/doc/coreutils.texi coreutils-8.1/doc/coreutils.texi
--- coreutils-8.1-orig/doc/coreutils.texi 2009-11-10 13:57:56.000000000 +0100
+++ coreutils-8.1/doc/coreutils.texi 2009-11-20 13:00:10.000000000 +0100
@@ -15070,8 +15070,11 @@ to certain shells, etc.).
diff -urNp coreutils-8.4-orig/doc/coreutils.texi coreutils-8.4/doc/coreutils.texi
--- coreutils-8.4-orig/doc/coreutils.texi 2010-01-03 18:06:20.000000000 +0100
+++ coreutils-8.4/doc/coreutils.texi 2010-02-12 10:17:46.000000000 +0100
@@ -15081,8 +15081,11 @@ to certain shells, etc.).
@findex syslog
@command{su} can optionally be compiled to use @code{syslog} to report
failed, and optionally successful, @command{su} attempts. (If the system
@ -32,7 +32,7 @@ diff -urNp coreutils-8.1-orig/doc/coreutils.texi coreutils-8.1/doc/coreutils.tex
The program accepts the following options. Also see @ref{Common options}.
@@ -15113,6 +15116,8 @@ environment variables except @env{TERM},
@@ -15124,6 +15127,8 @@ environment variables except @env{TERM},
@env{PATH} to a compiled-in default value. Change to @var{user}'s home
directory. Prepend @samp{-} to the shell's name, intended to make it
read its login startup file(s).
@ -41,7 +41,7 @@ diff -urNp coreutils-8.1-orig/doc/coreutils.texi coreutils-8.1/doc/coreutils.tex
@item -m
@itemx -p
@@ -15152,33 +15157,6 @@ Exit status:
@@ -15163,33 +15168,6 @@ Exit status:
the exit status of the subshell otherwise
@end display
@ -75,10 +75,10 @@ diff -urNp coreutils-8.1-orig/doc/coreutils.texi coreutils-8.1/doc/coreutils.tex
@node timeout invocation
@section @command{timeout}: Run a command with a time limit
diff -urNp coreutils-8.1-orig/src/Makefile.am coreutils-8.1/src/Makefile.am
--- coreutils-8.1-orig/src/Makefile.am 2009-11-06 18:04:10.000000000 +0100
+++ coreutils-8.1/src/Makefile.am 2009-11-20 13:00:10.000000000 +0100
@@ -359,7 +359,7 @@ factor_LDADD += $(LIB_GMP)
diff -urNp coreutils-8.4-orig/src/Makefile.am coreutils-8.4/src/Makefile.am
--- coreutils-8.4-orig/src/Makefile.am 2010-01-03 18:06:20.000000000 +0100
+++ coreutils-8.4/src/Makefile.am 2010-02-12 10:17:46.000000000 +0100
@@ -361,7 +361,7 @@ factor_LDADD += $(LIB_GMP)
uptime_LDADD += $(GETLOADAVG_LIBS)
# for crypt
@ -87,9 +87,9 @@ diff -urNp coreutils-8.1-orig/src/Makefile.am coreutils-8.1/src/Makefile.am
# for various ACL functions
copy_LDADD += $(LIB_ACL)
diff -urNp coreutils-8.1-orig/src/su.c coreutils-8.1/src/su.c
--- coreutils-8.1-orig/src/su.c 2009-11-20 12:59:39.000000000 +0100
+++ coreutils-8.1/src/su.c 2009-11-20 13:00:10.000000000 +0100
diff -urNp coreutils-8.4-orig/src/su.c coreutils-8.4/src/su.c
--- coreutils-8.4-orig/src/su.c 2010-02-12 10:15:15.000000000 +0100
+++ coreutils-8.4/src/su.c 2010-02-12 10:24:29.000000000 +0100
@@ -37,6 +37,16 @@
restricts who can su to UID 0 accounts. RMS considers that to
be fascist.
@ -339,7 +339,7 @@ diff -urNp coreutils-8.1-orig/src/su.c coreutils-8.1/src/su.c
shell_basename = last_component (shell);
arg0 = xmalloc (strlen (shell_basename) + 2);
arg0[0] = '-';
@@ -344,6 +496,66 @@ run_shell (char const *shell, char const
@@ -344,6 +496,67 @@ run_shell (char const *shell, char const
error (0, errno, "%s", shell);
exit (exit_status);
}
@ -377,12 +377,12 @@ diff -urNp coreutils-8.1-orig/src/su.c coreutils-8.1/src/su.c
+
+ pid = waitpid(-1, &status, WUNTRACED);
+
+ if (WIFSTOPPED(status)) {
+ kill(getpid(), SIGSTOP);
+ if (((pid_t)-1 != pid) && (0 != WIFSTOPPED (status))) {
+ kill(getpid(), WSTOPSIG(status));
+ /* once we get here, we must have resumed */
+ kill(pid, SIGCONT);
+ }
+ } while (WIFSTOPPED(status));
+ } while (0 != WIFSTOPPED(status));
+ }
+
+ if (caught) {
@ -401,12 +401,13 @@ diff -urNp coreutils-8.1-orig/src/su.c coreutils-8.1/src/su.c
+ fprintf(stderr, " ...killed.\n");
+ exit(-1);
+ }
+ exit (WEXITSTATUS(status));
+ exit ((0 != WIFEXITED (status)) ? WEXITSTATUS (status)
+ : WTERMSIG (status) + 128);
+#endif /* USE_PAM */
}
/* Return true if SHELL is a restricted shell (one not returned by
@@ -511,9 +723,9 @@ main (int argc, char **argv)
@@ -511,9 +724,9 @@ main (int argc, char **argv)
shell = xstrdup (shell ? shell : pw->pw_shell);
modify_environment (pw, shell);
@ -418,7 +419,7 @@ diff -urNp coreutils-8.1-orig/src/su.c coreutils-8.1/src/su.c
/* error() flushes stderr, but does not check for write failure.
Normally, we would catch this via our atexit() hook of
@@ -523,5 +735,5 @@ main (int argc, char **argv)
@@ -523,5 +736,5 @@ main (int argc, char **argv)
if (ferror (stderr))
exit (EXIT_CANCELED);

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 8.4
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -337,6 +337,10 @@ fi
%{_libdir}/coreutils
%changelog
* Fri Feb 12 2010 Ondrej Vasik <ovasik@redhat.com> - 8.4-5
- fix exit status of terminated child processes in su with
pam(#559098)
* Fri Feb 05 2010 Ondrej Vasik <ovasik@redhat.com> - 8.4-4
- do not depend on selinux patch application in
_require_selinux tests(#556350)