]> Pileus Git - mkinit/commitdiff
Update gettyd
authorAndy Spencer <andy753421@gmail.com>
Sat, 7 Nov 2020 10:24:45 +0000 (10:24 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 7 Nov 2020 10:24:45 +0000 (10:24 +0000)
src/gettyd.c

index d87df727e60926f2e0512993e195a8e111e674d8..b9acb05e9c7c0f96e73472f3dffda412eaf255f2 100644 (file)
@@ -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)