Comment 1 for bug 980835

Revision history for this message
Adam Conrad (adconrad) wrote :

This is actually the code responsible:

@@ -686,12 +770,16 @@ static void open_tty(char *tty, struct termios *tp, struct options *op)
                log_err("%s: tcgetattr: %m", tty);

        /*
- * Linux login(1) will change tty permissions. Use root owner and group
- * with permission -rw------- for the period between getty and login.
+ * Detect if this is a virtual console or serial/modem line.
+ * In case of a virtual console the ioctl TIOCMGET fails and
+ * the error number will be set to EINVAL.
         */
- ignore_result(chown(tty, 0, 0));
- ignore_result(chmod(tty, 0600));
- errno = 0;
+ if (ioctl(STDIN_FILENO, TIOCMGET, &serial) < 0 && (errno = EINVAL)) {
+ op->flags |= F_VCONSOLE;
+ if (!op->term)
+ op->term = DEFAULT_VCTERM;
+ } else if (!op->term)
+ op->term = DEFAULT_STERM;

        setenv("TERM", op->term, 1);
 }