History log of /openbsd-current/lib/libc/gen/syslog_r.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.20 03-Apr-2024 deraadt

Reading https://github.com/Geal/rust-syslog/issues/79, I came to a
related conclusion that our syslog_r should not stomp on errno.
The errno being returned from sendsyslog() isn't exactly compatible
with the what a legacy syslog_r() would do here anyways, and it is
better to just be void and non-stomping;
ok millert bluhm


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.19 08-Aug-2017 bluhm

Kernel sendsyslog(2), libc syslog(3), and syslogd(8) restrict and
truncate the length of a syslog message to 8192 bytes. Use one
global define LOG_MAXLINE for all of them.
OK deraadt@ millert@


# 1.18 07-Aug-2017 bluhm

Since sendsyslog(2) handles the LOG_CONS parameter, the variable
conp in syslog(3) is unused. Remove dead code.
OK jca@ deraadt@


# 1.17 20-Jul-2017 bluhm

Rename TBUF_LEN and FMT_LEN to _SIZE as they contain a NUL byte.
Change FMT_SIZE to 1024+1 for consistency. Do not loop over the
format string if there is no output space left.
OK deraadt@ millert@


Revision tags: OPENBSD_6_1_BASE
# 1.16 19-Oct-2016 millert

Use the reentrant strerror_r() instead of strerror() to expand %m.
Previously, syslog_r() would avoid calling strerror() since the latter
is not reentrant. OK bluhm@


Revision tags: OPENBSD_6_0_BASE
# 1.15 27-Mar-2016 chl

remove unused variable

ok millert@


# 1.14 21-Mar-2016 bluhm

Rename the system call sendsyslog2 to sendsyslog. Keep the old one
as osendsyslog for a while. The three argument variant is the only
one that will stay.
input kettenis@; OK deraadt@


# 1.13 13-Mar-2016 guenther

environ and __progname are not declared in a public header; declare them
in libc's hidden/stdlib.h instead of in each .c file that needs one

ok deraadt@ gsoares@ mpi@


Revision tags: OPENBSD_5_9_BASE
# 1.12 19-Feb-2016 millert

Remove the "error" variable; we no longer fall back to writing to
/dev/console so the value of "error" is never read. Also mention
that sendsyslog2 can fail due to ENOBUFS in the comment. OK deraadt@


# 1.11 25-Nov-2015 deraadt

Add a syscall stub for sendsyslog2(2), and use it in syslog_r(3), passing
LOG_CONS to the kernel. As a result, the /dev/console opening code can
be removed.
ok kettenis millert beck


# 1.10 31-Oct-2015 deraadt

Do not include a timestamp in the syslog message. There is no need --
syslogd will fill it in immediately upon reception on the other side of
sendsyslog(2). Our libc only talks to our syslogd, which will fix the
timestamp before forwarding. syslog_r has done this for a long time
already.
ok tedu bluhm


# 1.9 12-Sep-2015 guenther

Wrap <syslog.h> so that internal calls go direct and they're all weak symbols
Delete code that's a no-op now that we don't use sockets
Eliminate unnecessary #includes


# 1.8 09-Sep-2015 bluhm

Syslogd can handle 8192 bytes per message now. Increase the libc
syslog(3) limit to the same size. The buffer needs one byte more
as it conains a NUL that sendsyslog(2) does not process.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.7 21-Jan-2015 deraadt

Truncate progname to NAME_MAX in the syslog message, to ensure other
information also makes it through. This is a compromise to cope with
the absolutely ridiculous setprogname() API.
ok various discussions


# 1.6 03-Oct-2014 bluhm

Strip trailing new-lines from syslog messages. This avoids empty
lines when printing to console or stderr.
OK deraadt@


Revision tags: OPENBSD_5_6_BASE
# 1.5 14-Jul-2014 deraadt

Convert syslog_r(3) to using sendsyslog(2). This ensures that syslog_r(3)
can be used anywhere (signal handler, stack protector fault handler) as
long as the format string does not contain floating point.
ok tedu miod beck


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.4 29-Apr-2013 okan

use FD_CLOEXEC instead of 1; from David Hill

ok otto


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.3 30-May-2011 martynas

Make printf-like and scanf-like functions marked as such in llib-lc.ln
and llib-lwrap.ln databases; so that the lint features doing format
strings checks are enabled by default.

Looks good to millert@.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.2 21-Nov-2009 chl

remove unused variable

ok guenther@


# 1.1 18-Nov-2009 guenther

More shrinkage, a bit for ramdisks but mostly for static binaries:
- wrap with #ifndef NO_LOG_BAD_DNS_RESPONSES libc code that uses
p_class() and p_type() for diagnostics, then add that define to
libstub to avoid pulling in res_debug_syms.o
- split rcmd() and ruserok() into separate files, as nothing uses both
- split readdir_r() to its own file
- split syslog_r() from syslog(), as the latter needs localtime(); many
binaries no longer need to pull in all the time code after this; switch
from usleep() to nanosleep() while we're at it

(The profit of analysis of -Wl,-M,--cref output)

Chops 888kB from /bin and /sbin on i386

ok deraadt@, miod@


Revision tags: OPENBSD_6_2_BASE
# 1.19 08-Aug-2017 bluhm

Kernel sendsyslog(2), libc syslog(3), and syslogd(8) restrict and
truncate the length of a syslog message to 8192 bytes. Use one
global define LOG_MAXLINE for all of them.
OK deraadt@ millert@


# 1.18 07-Aug-2017 bluhm

Since sendsyslog(2) handles the LOG_CONS parameter, the variable
conp in syslog(3) is unused. Remove dead code.
OK jca@ deraadt@


# 1.17 20-Jul-2017 bluhm

Rename TBUF_LEN and FMT_LEN to _SIZE as they contain a NUL byte.
Change FMT_SIZE to 1024+1 for consistency. Do not loop over the
format string if there is no output space left.
OK deraadt@ millert@


Revision tags: OPENBSD_6_1_BASE
# 1.16 19-Oct-2016 millert

Use the reentrant strerror_r() instead of strerror() to expand %m.
Previously, syslog_r() would avoid calling strerror() since the latter
is not reentrant. OK bluhm@


Revision tags: OPENBSD_6_0_BASE
# 1.15 27-Mar-2016 chl

remove unused variable

ok millert@


# 1.14 21-Mar-2016 bluhm

Rename the system call sendsyslog2 to sendsyslog. Keep the old one
as osendsyslog for a while. The three argument variant is the only
one that will stay.
input kettenis@; OK deraadt@


# 1.13 13-Mar-2016 guenther

environ and __progname are not declared in a public header; declare them
in libc's hidden/stdlib.h instead of in each .c file that needs one

ok deraadt@ gsoares@ mpi@


Revision tags: OPENBSD_5_9_BASE
# 1.12 19-Feb-2016 millert

Remove the "error" variable; we no longer fall back to writing to
/dev/console so the value of "error" is never read. Also mention
that sendsyslog2 can fail due to ENOBUFS in the comment. OK deraadt@


# 1.11 25-Nov-2015 deraadt

Add a syscall stub for sendsyslog2(2), and use it in syslog_r(3), passing
LOG_CONS to the kernel. As a result, the /dev/console opening code can
be removed.
ok kettenis millert beck


# 1.10 31-Oct-2015 deraadt

Do not include a timestamp in the syslog message. There is no need --
syslogd will fill it in immediately upon reception on the other side of
sendsyslog(2). Our libc only talks to our syslogd, which will fix the
timestamp before forwarding. syslog_r has done this for a long time
already.
ok tedu bluhm


# 1.9 12-Sep-2015 guenther

Wrap <syslog.h> so that internal calls go direct and they're all weak symbols
Delete code that's a no-op now that we don't use sockets
Eliminate unnecessary #includes


# 1.8 09-Sep-2015 bluhm

Syslogd can handle 8192 bytes per message now. Increase the libc
syslog(3) limit to the same size. The buffer needs one byte more
as it conains a NUL that sendsyslog(2) does not process.
OK deraadt@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.7 21-Jan-2015 deraadt

Truncate progname to NAME_MAX in the syslog message, to ensure other
information also makes it through. This is a compromise to cope with
the absolutely ridiculous setprogname() API.
ok various discussions


# 1.6 03-Oct-2014 bluhm

Strip trailing new-lines from syslog messages. This avoids empty
lines when printing to console or stderr.
OK deraadt@


Revision tags: OPENBSD_5_6_BASE
# 1.5 14-Jul-2014 deraadt

Convert syslog_r(3) to using sendsyslog(2). This ensures that syslog_r(3)
can be used anywhere (signal handler, stack protector fault handler) as
long as the format string does not contain floating point.
ok tedu miod beck


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.4 29-Apr-2013 okan

use FD_CLOEXEC instead of 1; from David Hill

ok otto


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.3 30-May-2011 martynas

Make printf-like and scanf-like functions marked as such in llib-lc.ln
and llib-lwrap.ln databases; so that the lint features doing format
strings checks are enabled by default.

Looks good to millert@.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.2 21-Nov-2009 chl

remove unused variable

ok guenther@


# 1.1 18-Nov-2009 guenther

More shrinkage, a bit for ramdisks but mostly for static binaries:
- wrap with #ifndef NO_LOG_BAD_DNS_RESPONSES libc code that uses
p_class() and p_type() for diagnostics, then add that define to
libstub to avoid pulling in res_debug_syms.o
- split rcmd() and ruserok() into separate files, as nothing uses both
- split readdir_r() to its own file
- split syslog_r() from syslog(), as the latter needs localtime(); many
binaries no longer need to pull in all the time code after this; switch
from usleep() to nanosleep() while we're at it

(The profit of analysis of -Wl,-M,--cref output)

Chops 888kB from /bin and /sbin on i386

ok deraadt@, miod@