[Pkg-shadow-devel] Bug#317747: su -m / suspend / fg broken with zsh

dean gaudet dean gaudet <dean@arctic.org>, 317747@bugs.debian.org
Mon Jul 11 10:32:17 UTC 2005


ok this is gross... but this seems to fix the problems.  at first i tried 
just adding the setpgrp... but with that the su'd zsh doesn't ever seem to 
wake up.

so i threw in the TIOCSPGRP calls to pass the tty pgrp to the su'd zsh... 
and that fixes it.

it looks like bash calls TIOCSPGRP directly to set the tty pgrp when it is 
continued... whereas zsh calls TIOCGPGRP to check it and then goes back to 
sleep because it doesn't own the tty.

ugh.  this is a gross...  i'm leaning towards blaming zsh for the tty pgrp 
problems, but blaming su for the lack of setpgrp -- su really needs to 
protect itself from being put to sleep by its child accidentally.

-dean

--- shadow-4.0.3/src/su.c	2005-07-11 03:23:29.000000000 -0700
+++ shadow-4.0.3.dg1/src/su.c	2005-07-11 03:21:08.000000000 -0700
@@ -70,6 +70,7 @@
 #include <getopt.h>
 #include "pwauth.h"
 #include "getdef.h"
+#include <sys/ioctl.h>
 
 /*
  * Assorted #defines to control su's behavior
@@ -751,14 +752,19 @@
 			exit(1);
 		case 0: /* child */
 			signal(SIGINT, SIG_DFL);
+			if (setpgrp()) {
+				exit(1);
+			}
 			break;
 		default: /* parent */
+			ioctl(0, TIOCSPGRP, &pid);
 			do {
 				errno = 0;
 				wpid = waitpid(pid, &status, WUNTRACED);
 				if (wpid == pid && WIFSTOPPED(status)) {
 					/* stop when child stops */
 					raise(SIGSTOP);
+					ioctl(0, TIOCSPGRP, &pid);
 					/* wake child when resumed */
 					kill(pid, SIGCONT);
 				}





More information about the Pkg-shadow-devel mailing list