[Pkg-shadow-commits] r276 - trunk/debian/patches
Alexander Gattin
pkg-shadow-devel@lists.alioth.debian.org
Mon, 20 Jun 2005 08:30:38 +0000
Author: xrgtn-guest
Date: 2005-06-20 08:30:38 +0000 (Mon, 20 Jun 2005)
New Revision: 276
Added:
trunk/debian/patches/356_su-stop_cont-proxy
Modified:
trunk/debian/patches/series
Log:
added "stop/cont proxy" patch for bug #314727
Added: trunk/debian/patches/356_su-stop_cont-proxy
===================================================================
--- trunk/debian/patches/356_su-stop_cont-proxy 2005-06-20 00:16:30 UTC (rev 275)
+++ trunk/debian/patches/356_su-stop_cont-proxy 2005-06-20 08:30:38 UTC (rev 276)
@@ -0,0 +1,61 @@
+Goal: When su process sits between parent and child shells, it should
+ pass STOPs from child to parent and CONTs from parent to child.
+
+Status wrt upstream: Will possibly be accepted upstream, in 4.0.11.
+
+Notes: SIGCHLD is handled implicitly by waitpid() when WUNTRACED flag is
+ specified.
+
+ SIGCONT just resumes execution of "su" right after the point where
+ it was stopped -- i.e. starting from the next command after
+ kill(SIGSTOP), which has been processed synchronously.
+
+ Thus there's no need to set signal handlers for either SIGCHLD or
+ SIGCONT, and code is much cleaner with this.
+
+ Because waitpid() is now placed inside a loop, here are some comments
+ about when the loop is broken:
+ 1. (wpid != pid && errno != EINTR) -- waitpid(pid, ...) error like
+ wrong pid, options, but excluding interrupted by signal case
+ 2. WIFEXITED
+ 3. WIFSIGNALED
+ 4. WCOREDUMP
+ This _differs_ with Tomasz's in EINTR handling -- Tomasz's su will
+ _exit_ on EINTR. This code won't. I suspect that it's not possible
+ to be inerrupted _that way_ with e.g. SIGCHLD, but who knows...
+
+ Closes: 314727
+ (suspend command from su shell fails to return to parent shell)
+
+Index: shadow-4.0.3/src/su.c
+===================================================================
+--- shadow-4.0.3.orig/src/su.c 2005-06-20 11:15:03.000000000 +0300
++++ shadow-4.0.3/src/su.c 2005-06-20 11:35:27.000000000 +0300
+@@ -737,7 +737,7 @@
+ around to close sessions */
+ if (getdef_bool("CLOSE_SESSIONS")) {
+ pid_t pid;
+- int status;
++ int status, wpid;
+
+ signal(SIGINT, SIG_IGN);
+ pid = fork();
+@@ -754,7 +754,17 @@
+ signal(SIGINT, SIG_DFL);
+ break;
+ default: /* parent */
+- waitpid(pid, &status, 0);
++ do {
++ errno = 0;
++ wpid = waitpid(pid, &status, WUNTRACED);
++ if (wpid == pid && WIFSTOPPED(status)) {
++ /* stop when child stops */
++ raise(SIGSTOP);
++ /* wake child when resumed */
++ kill(pid, SIGCONT);
++ }
++ } while (wpid == pid && WIFSTOPPED(status)
++ || wpid != pid && errno == EINTR);
+ /* now we are done using PAM */
+ pam_setcred(pamh, PAM_DELETE_CRED);
+ ret = pam_close_session(pamh, 0);
Modified: trunk/debian/patches/series
===================================================================
--- trunk/debian/patches/series 2005-06-20 00:16:30 UTC (rev 275)
+++ trunk/debian/patches/series 2005-06-20 08:30:38 UTC (rev 276)
@@ -120,3 +120,4 @@
421_login.1_pishing
422_getdate.c_generated_file
010_more-i18ned-messages
+356_su-stop_cont-proxy