mirror of
https://github.com/troglobit/finit.git
synced 2026-12-04 21:58:19 +00:00
getty: Disable VINTR + VEOF, re-enable before calling /bin/login
This patch makes the Finit built-in getty behave a bit more like other getty implementations. We now not only disable ISIG but also VEOF and VINTR when prearing the TTY for the getty (built-in or external). Like before, it is up to the getty process to leave the TTY in a usable state to /bin/login, so we also move the stty() call to just before calling /bin/login in getty.c Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
faf0c680b8
commit
d31575538c
2 files changed
+30
-7
No files matched your search
+22
-1
@@ -250,7 +250,9 @@ static void prepare_tty(char *tty, char *procname)
|
|||||||
*/
|
*/
|
||||||
tcdrain(STDIN_FILENO);
|
tcdrain(STDIN_FILENO);
|
||||||
if (!tcgetattr(STDIN_FILENO, &term)) {
|
if (!tcgetattr(STDIN_FILENO, &term)) {
|
||||||
term.c_lflag &= ~ISIG;
|
term.c_lflag &= ~ISIG;
|
||||||
|
term.c_cc[VEOF] = _POSIX_VDISABLE;
|
||||||
|
term.c_cc[VINTR] = _POSIX_VDISABLE;
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &term);
|
tcsetattr(STDIN_FILENO, TCSANOW, &term);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,6 +314,25 @@ static int activate_console(int noclear, int nowait)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Start a getty on @tty
|
||||||
|
*
|
||||||
|
* At the login: prompt, no signals are allowed, both Ctrl-C and Ctrl-D
|
||||||
|
* should be disabled. Ctrl-S and Ctrl-Q are optional, but most getty
|
||||||
|
* allow them.
|
||||||
|
*
|
||||||
|
* Prior to getty is called and login: is printed, Finit may display the
|
||||||
|
* "Please press Enter ..." if @nowait is unset. This mode must be RAW,
|
||||||
|
* only accepting <CR> and not echoing anything, this also means no
|
||||||
|
* signals are allowed. For ease of implementation Finit will call the
|
||||||
|
* stty() function to reset the TTY and then force RAW mode until a <CR>
|
||||||
|
* has been received. This is handled in the same fashion for both this
|
||||||
|
* function and run_getty2(), which is used for external getty.
|
||||||
|
*
|
||||||
|
* When handing over to /bin/login, Ctrl-C and Ctrl-D must be enabled
|
||||||
|
* since /bin/login usually only disables ECHO until a password line has
|
||||||
|
* been entered. Upon starting the user's $SHELL the ISIG flag is reset
|
||||||
|
*/
|
||||||
pid_t run_getty(char *tty, char *speed, char *term, int noclear, int nowait)
|
pid_t run_getty(char *tty, char *speed, char *term, int noclear, int nowait)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|||||||
+8
-6
@@ -300,18 +300,20 @@ int getty(char *tty, char *baud, char *term, char *user)
|
|||||||
sigaction(SIGINT, &sa, NULL);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
sigaction(SIGQUIT, &sa, NULL);
|
sigaction(SIGQUIT, &sa, NULL);
|
||||||
|
|
||||||
/* Set up TTY */
|
/* The getty process is responsible for the UTMP login record */
|
||||||
stty(fd, speed);
|
|
||||||
close(fd);
|
|
||||||
utmp_set_login(tty, NULL);
|
utmp_set_login(tty, NULL);
|
||||||
if (term)
|
|
||||||
setenv("TERM", term, 1);
|
|
||||||
|
|
||||||
if (!user)
|
if (!user)
|
||||||
do_getty(tty, name, sizeof(name));
|
do_getty(tty, name, sizeof(name));
|
||||||
else
|
else
|
||||||
strlcpy(name, user, sizeof(name));
|
strlcpy(name, user, sizeof(name));
|
||||||
|
|
||||||
|
/* Set up TTY, re-enabling ISIG et al. */
|
||||||
|
stty(fd, speed);
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
if (term)
|
||||||
|
setenv("TERM", term, 1);
|
||||||
|
|
||||||
return do_login(name);
|
return do_login(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user