Index | Thread | Search

From:
"Theo de Raadt" <deraadt@openbsd.org>
Subject:
Re: getty: check login_tty() failure
To:
Ted Bullock <tbullock@comlore.com>
Cc:
tech@openbsd.org
Date:
Sun, 11 Oct 2026 12:05:05 -0600

Download raw body.

Thread
You have not explained how you got here.

Your diff just duplicates a syslog+exit from lower down.  It will still
do the same thing.

I think what you are trying to do, which you don't explain, is probably
wrong, and swapping one message for another message does nothing.

> I was reworking my X login environment and ran into a problem where
> getty repeatedly reported:
> 
>     /dev/console: Inappropriate ioctl for device
> 
> Tracing it showed that opening /dev/console succeeded, but login_tty()
> failed at TIOCSCTTY with EPERM. Getty ignores that return value and goes
> on to call tcgetattr() on its inherited stdin, producing the misleading
> ENOTTY error.
> 
> This checks the return from login_tty() and exits. It does not address
> the underlying console/session conflict but that is probably just
> something I broke that exposed this defect.
> 
> Ted
> 
> --- libexec/getty/main.c
> +++ libexec/getty/main.c
> @@ -247,7 +247,10 @@
>  				repcnt++;
>  				sleep(60);
>  			}
> -			login_tty(i);
> +			if (login_tty(i) == -1) {
> +				syslog(LOG_ERR, "%s: login_tty: %m", ttyn);
> +				exit(1);
> +			}
>  		}
>  	}
>  
>