]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
syslogd: Keep console and tty descriptors open
authorJake Freeland <jfree@FreeBSD.org>
Sun, 15 Oct 2023 20:34:06 +0000 (15:34 -0500)
committerMark Johnston <markj@FreeBSD.org>
Mon, 16 Oct 2023 13:11:58 +0000 (09:11 -0400)
commitd556719e15d643ba9619bbbeab550eed87614525
tree64eb2c4fb7a939c0dd995b55a36cbe1a0b8030b7
parent7ef6e99752db3c0fc7953a039050881c068b43fe
syslogd: Keep console and tty descriptors open

Console and tty descriptors are initially opened in parse_action() to
determine whether they are valid using isatty(). That descriptor is then
closed because it is never accessed by syslogd again; ttymsg() will reopen
the tty/console under a new descriptor when needed.

If the user attempts to log to a tty that is inactive outside of
syslogd, then syslogd must keep that descriptor open so the tty remains
accessible. For example, logging to `/dev/ttyvb` requires the initial
`/dev/ttyvb` descriptor to stay open so the user can view its buffer at
any time via CTRL+ALT+F12.

As a result, console and tty descriptors must remain open until a
potential configuration reload or a system shutdown. The given
descriptor will be closed in close_filed() in such circumstances.

PR: 274454
Fixes: c3175a6e1c5a ("syslogd: Do not open console descriptor")
Reported by: Trond Endrestøl <Trond.Endrestol@ximalas.info>
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D42215
usr.sbin/syslogd/syslogd.c