Hi, syslogd has special code for reporting errors before it has been initialized. Then it tries to log to console. For every message it reopens the console with file descriptor passing from the privsep parent. Of course that does not work when we have reached our file descriptor limit. I think is is better to have the console preopend, so we can always get a message out.
ok? bluhm Index: usr.sbin/syslogd/syslogd.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v retrieving revision 1.246 diff -u -p -r1.246 syslogd.c --- usr.sbin/syslogd/syslogd.c 12 Sep 2017 15:17:20 -0000 1.246 +++ usr.sbin/syslogd/syslogd.c 13 Sep 2017 14:59:20 -0000 @@ -483,6 +483,10 @@ main(int argc, char *argv[]) consfile.f_type = F_CONSOLE; (void)strlcpy(consfile.f_un.f_fname, ctty, sizeof(consfile.f_un.f_fname)); + consfile.f_file = open(consfile.f_un.f_fname, O_WRONLY|O_NONBLOCK, 0); + if (consfile.f_file == -1) + log_warn("open %s", consfile.f_un.f_fname); + (void)gethostname(LocalHostName, sizeof(LocalHostName)); if ((p = strchr(LocalHostName, '.')) != NULL) { *p++ = '\0'; @@ -1780,16 +1784,14 @@ logline(int pri, int flags, char *from, /* log the message to the particular outputs */ if (!Initialized) { f = &consfile; - f->f_file = priv_open_tty(ctty); - - if (f->f_file >= 0) { + if (f->f_type == F_CONSOLE) { strlcpy(f->f_lasttime, timestamp, sizeof(f->f_lasttime)); strlcpy(f->f_prevhost, from, sizeof(f->f_prevhost)); fprintlog(f, flags, msg); - (void)close(f->f_file); - f->f_file = -1; + /* May be set to F_UNUSED, try again next time. */ + f->f_type = F_CONSOLE; } return; }