misc: syslog: Use CLOC_EXEC with _PATH_CONSOLE (BZ #17145)

The syslog open the '/dev/console' for LOG_CONS without O_CLOEXEC,
which might leak in multithread programs that call fork.

Checked on x86_64-linux-gnu.
This commit is contained in:
Adhemerval Zanella 2021-04-10 23:29:40 -03:00
parent ded3cef361
commit 7f3ab33f20

View File

@ -284,7 +284,8 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap,
* syslogd failure.
*/
if (LogStat & LOG_CONS &&
(fd = __open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY, 0)) >= 0)
(fd = __open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY|O_CLOEXEC,
0)) >= 0)
{
__dprintf (fd, "%s\r\n", buf + msgoff);
(void)__close(fd);