aboutsummaryrefslogtreecommitdiff
path: root/src/rc.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-05-03 13:46:38 +0000
committerRoy Marples <roy@marples.name>2007-05-03 13:46:38 +0000
commit2fd8225c6ae47e13956deb7b0aa8c838be243a86 (patch)
tree95d855dada8f65ef877308428728b9066304815a /src/rc.c
parent33832218347d4ad533fdd599499560b6cdd70131 (diff)
Always pass ttyname to sulogin
Diffstat (limited to 'src/rc.c')
-rw-r--r--src/rc.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/rc.c b/src/rc.c
index 0ecbb020..946a7a94 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -36,6 +36,7 @@
#define INITSH RC_LIBDIR "sh/init.sh"
#define INITEARLYSH RC_LIBDIR "sh/init-early.sh"
#define HALTSH RC_INITDIR "halt.sh"
+#define SULOGIN "/sbin/sulogin"
#define RC_SVCDIR_STARTING RC_SVCDIR "starting/"
#define RC_SVCDIR_INACTIVE RC_SVCDIR "inactive/"
@@ -393,14 +394,22 @@ static void sulogin (bool cont)
if (cont) {
int status = 0;
+#ifdef __linux__
+ char *tty = ttyname (fileno (stdout));
+#endif
+
pid_t pid = vfork ();
if (pid == -1)
eerrorx ("%s: vfork: %s", applet, strerror (errno));
if (pid == 0) {
#ifdef __linux__
- execle ("/sbin/sulogin", "/sbin/sulogin", (char *) NULL, newenv);
- eerror ("%s: unable to exec `/sbin/sulogin': %s", applet,
+ if (tty)
+ execle (SULOGIN, SULOGIN, tty, (char *) NULL, newenv);
+ else
+ execle (SULOGIN, SULOGIN, (char *) NULL, newenv);
+
+ eerror ("%s: unable to exec `%s': %s", applet, SULOGIN,
strerror (errno));
#else
execle ("/bin/sh", "/bin/sh", (char *) NULL, newenv);