mirror of
https://github.com/troglobit/finit.git
synced 2026-11-19 19:40:50 +00:00
getty: attempt to steal ctty if don't already have it
This fixes the following classic problem
login: root
-sh: can't access tty; job control turned off
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
093fa0107a
commit
dc36b313ff
1 file changed
+8
@@ -198,6 +198,7 @@ static int getty(char *tty, speed_t speed, char *term, char *user)
|
|||||||
{
|
{
|
||||||
const char cln[] = "\r\e[2K\n";
|
const char cln[] = "\r\e[2K\n";
|
||||||
char name[33]; /* useradd(1) limit at 32 chars */
|
char name[33]; /* useradd(1) limit at 32 chars */
|
||||||
|
pid_t sid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clean up tty name.
|
* Clean up tty name.
|
||||||
@@ -219,6 +220,13 @@ restart:
|
|||||||
} else
|
} else
|
||||||
strlcpy(name, user, sizeof(name));
|
strlcpy(name, user, sizeof(name));
|
||||||
|
|
||||||
|
/* check current session associated with our tty */
|
||||||
|
sid = tcgetsid(0);
|
||||||
|
if (sid < 0 || getpid() != sid) {
|
||||||
|
if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) == -1)
|
||||||
|
err(1, "failed stealing controlling TTY");
|
||||||
|
}
|
||||||
|
|
||||||
if (term && term[0])
|
if (term && term[0])
|
||||||
setenv("TERM", term, 1);
|
setenv("TERM", term, 1);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user