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)