Always reset ownership and permissions on TTY device nodes

During /bin/login phase the TTY device node is chowned and chmodded to
the authenticated user.  It will remain in this state until the next
call to getty.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-12-27 12:12:18 +01:00
parent 7c8ab7915f
commit 53c5d0e55a
+6
View File
@@ -286,6 +286,12 @@ static void prepare_tty(char *tty, speed_t speed, const char *procname, struct r
char name[80];
int fd, dummy;
/* Set proper protections and ownership */
if (chown(tty, 0, 0))
logit(LOG_ERR, "failed chowning 0:0 %s: %s", tty, strerror(errno));
if (chmod(tty, 0620))
logit(LOG_ERR, "failed chmoding 620 %s: %s", tty, strerror(errno));
fd = open(tty, O_RDWR);
if (fd < 0) {
logit(LOG_ERR, "Failed opening %s: %s", tty, strerror(errno));