[Pkg-sysvinit-devel] Bug#374543: sysvinit: ^C and ^Z don't work in emergency mode

Samuel Thibault samuel.thibault at ens-lyon.org
Thu Aug 3 21:10:22 UTC 2006


Samuel Thibault, le Wed 21 Jun 2006 01:52:03 +0200, a écrit :
> Sulogin needs patched too, here it is.

Here is a better patch: before starting a new session, it checks thanks
to tcgetsid() whether stdin is the controlling terminal.

Samuel
-------------- next part --------------
diff -ur sysvinit-2.86.ds1/src/sulogin.c sysvinit-2.86.ds1youpi/src/sulogin.c
--- sysvinit-2.86.ds1/src/sulogin.c	2004-07-30 13:40:28.000000000 +0200
+++ sysvinit-2.86.ds1youpi/src/sulogin.c	2006-06-21 01:49:54.000000000 +0200
@@ -23,6 +23,7 @@
 #include <pwd.h>
 #include <shadow.h>
 #include <termios.h>
+#include <errno.h>
 #include <sys/ioctl.h>
 #if defined(__GLIBC__)
 #  include <crypt.h>
@@ -410,7 +411,6 @@
 				if (pid != getsid(0)) {
 					if (pid == getpgid(0))
 						setpgid(0, getpgid(getppid()));
-					setsid();
 				}
 
 				signal(SIGHUP, SIG_IGN);
@@ -421,13 +421,17 @@
 				close(2);
 				close(fd);
 				fd = open(tty, O_RDWR);
-				ioctl(0, TIOCSCTTY, (char *)1);
 				dup(fd);
 				dup(fd);
 			} else
 				close(fd);
 		}
 	}
+	if (tcgetsid(0) == -1) {
+		setsid();
+		if (ioctl(0, TIOCSCTTY, (char *)1))
+			perror("ioctl(TIOCSCTTY)");
+	}
 
 	/*
 	 *	Get the root password.


More information about the Pkg-sysvinit-devel mailing list