From 649d174c683416c1579e7324614c266d3853a20f Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sat, 7 Nov 2020 10:24:45 +0000 Subject: [PATCH] Update gettyd --- src/gettyd.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gettyd.c b/src/gettyd.c index d87df72..b9acb05 100644 --- a/src/gettyd.c +++ b/src/gettyd.c @@ -62,16 +62,24 @@ static int start_tty(tty_t *tty) const char *prompt = "[Press enter to login]"; struct termios attr; - tty->fd = open(tty->path, O_RDWR|O_NOCTTY|O_NONBLOCK|O_CLOEXEC, 0); - if (tty->fd < 0) - return tty->fd; + if (chown(tty->path, 0, 0) < 0) + return -1; + if (chmod(tty->path, 0600) < 0) + return -1; + if ((tty->fd = open(tty->path, O_RDWR|O_NOCTTY|O_NONBLOCK|O_CLOEXEC, 0)) < 0) + return -1; + if (add_poll(tty->fd, tty) < 0) + return -1; + tcgetattr(tty->fd, &attr); attr.c_lflag &= ~ECHO; tcsetattr(tty->fd, TCSANOW, &attr); + write(tty->fd, "\033c", 2); write(tty->fd, "\033[?1c", 5); write(tty->fd, prompt, strlen(prompt)); - return add_poll(tty->fd, tty); + + return 0; } static void read_tty(tty_t *tty) -- 2.43.2