Before this patch, signals in newsyslog.conf must be configured using the number (e.g. 30 for SIGUSR1). This patch add the possibility to write the signal name (e.g. SIGUSR1) and adapt the man page accordingly.
Details
- Reviewers
bapt - Group Reviewers
manpages - Commits
- rS290225: MFC: 289879
rS289879: newsyslog.conf: allow to configure the signal using the signal name.
none
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
No Lint Coverage - Unit
No Test Coverage - Build Status
Buildable 875 Build 875: arc lint + arc unit
Event Timeline
signame_to_signum taken from kill(1), manpage changes based on OpenBSD's newsyslog.conf.
head/usr.sbin/newsyslog/newsyslog.c | ||
---|---|---|
1360 | I think the whole logic of validating signal should reuse something like https://svnweb.freebsd.org/base/head/usr.bin/timeout/timeout.c?view=markup&pathrev=278810#l103 |
head/usr.sbin/newsyslog/newsyslog.c | ||
---|---|---|
1360 | Sure, let me patch/test and update the diff :) |
Here is a sample test session using the -v (verbose) and -n (don't trim but print actions) options.
At first, we have a simple test config using a signal number (and also an executable path to test compatibility) and see the result with /usr/sbin/newsyslog (testing on 10.2-RELEASE-p5). Then we include a rotation using the signal name and run the patched newsyslog command. As a result it seems to interpret correctly both the signum and shellcmd lines (as the non-patched version does), while successfully parsing and executing the signame line.
[alex@smaug.kaworu.ch /tmp/newsyslog] % cat test.conf # logfilename [owner:group] mode count size when flags [/pid_file] [sig_num] /tmp/newsyslog/signum-test.log 644 1 1 * J /var/run/rspamd/rspamd.pid 30 /tmp/newsyslog/cmd-test.log 644 1 1 * JR /bin/ls [alex@smaug.kaworu.ch /tmp/newsyslog] % /usr/sbin/newsyslog -vn -f ./test.conf Processing ./test.conf /tmp/newsyslog/signum-test.log <1J>: size (Kb): 1 [1] --> trimming log.... rm -f /tmp/newsyslog/signum-test.log.1 rm -f /tmp/newsyslog/signum-test.log.1.gz rm -f /tmp/newsyslog/signum-test.log.1.bz2 rm -f /tmp/newsyslog/signum-test.log.1.xz rm -f /tmp/newsyslog/signum-test.log.0 rm -f /tmp/newsyslog/signum-test.log.0.gz rm -f /tmp/newsyslog/signum-test.log.0.bz2 rm -f /tmp/newsyslog/signum-test.log.0.xz ln /tmp/newsyslog/signum-test.log /tmp/newsyslog/signum-test.log.0 touch /tmp/newsyslog/signum-test.log.0 # Update mtime for 'when'-interval processing chmod 644 /tmp/newsyslog/signum-test.log.0 Start new log... mktemp /tmp/newsyslog/signum-test.log.zXXXXXX chmod 644 /tmp/newsyslog/signum-test.log.zXXXXXX mv /tmp/newsyslog/signum-test.log.zXXXXXX /tmp/newsyslog/signum-test.log /tmp/newsyslog/cmd-test.log <1J>: size (Kb): 1 [1] --> trimming log.... rm -f /tmp/newsyslog/cmd-test.log.1 rm -f /tmp/newsyslog/cmd-test.log.1.gz rm -f /tmp/newsyslog/cmd-test.log.1.bz2 rm -f /tmp/newsyslog/cmd-test.log.1.xz rm -f /tmp/newsyslog/cmd-test.log.0 rm -f /tmp/newsyslog/cmd-test.log.0.gz rm -f /tmp/newsyslog/cmd-test.log.0.bz2 rm -f /tmp/newsyslog/cmd-test.log.0.xz ln /tmp/newsyslog/cmd-test.log /tmp/newsyslog/cmd-test.log.0 touch /tmp/newsyslog/cmd-test.log.0 # Update mtime for 'when'-interval processing chmod 644 /tmp/newsyslog/cmd-test.log.0 Start new log... mktemp /tmp/newsyslog/cmd-test.log.zXXXXXX chmod 644 /tmp/newsyslog/cmd-test.log.zXXXXXX mv /tmp/newsyslog/cmd-test.log.zXXXXXX /tmp/newsyslog/cmd-test.log Signal all daemon process(es)... kill -30 20617 # /var/run/rspamd/rspamd.pid sleep 1 sh -c '/bin/ls 1' sleep 10 Compress all rotated log file(s)... bzip2 /tmp/newsyslog/cmd-test.log.0 chmod 644 /tmp/newsyslog/cmd-test.log.0.bz2 bzip2 /tmp/newsyslog/signum-test.log.0 chmod 644 /tmp/newsyslog/signum-test.log.0.bz2 [alex@smaug.kaworu.ch /tmp/newsyslog] % echo "/tmp/newsyslog/signame-test.log 644 1 1 * J /var/run/nginx.pid SIGUSR1" >> test.conf [alex@smaug.kaworu.ch /tmp/newsyslog] % cat test.conf # logfilename [owner:group] mode count size when flags [/pid_file] [sig_num] /tmp/newsyslog/signum-test.log 644 1 1 * J /var/run/rspamd/rspamd.pid 30 /tmp/newsyslog/cmd-test.log 644 1 1 * JR /bin/ls /tmp/newsyslog/signame-test.log 644 1 1 * J /var/run/nginx.pid SIGUSR1 [alex@smaug.kaworu.ch /tmp/newsyslog] % ./newsyslog.patched -vn -f ./test.conf Processing ./test.conf /tmp/newsyslog/signum-test.log <1J>: size (Kb): 1 [1] --> trimming log.... rm -f /tmp/newsyslog/signum-test.log.1 rm -f /tmp/newsyslog/signum-test.log.1.gz rm -f /tmp/newsyslog/signum-test.log.1.bz2 rm -f /tmp/newsyslog/signum-test.log.1.xz rm -f /tmp/newsyslog/signum-test.log.0 rm -f /tmp/newsyslog/signum-test.log.0.gz rm -f /tmp/newsyslog/signum-test.log.0.bz2 rm -f /tmp/newsyslog/signum-test.log.0.xz ln /tmp/newsyslog/signum-test.log /tmp/newsyslog/signum-test.log.0 touch /tmp/newsyslog/signum-test.log.0 # Update mtime for 'when'-interval processing chmod 644 /tmp/newsyslog/signum-test.log.0 Start new log... mktemp /tmp/newsyslog/signum-test.log.zXXXXXX chmod 644 /tmp/newsyslog/signum-test.log.zXXXXXX mv /tmp/newsyslog/signum-test.log.zXXXXXX /tmp/newsyslog/signum-test.log /tmp/newsyslog/cmd-test.log <1J>: size (Kb): 1 [1] --> trimming log.... rm -f /tmp/newsyslog/cmd-test.log.1 rm -f /tmp/newsyslog/cmd-test.log.1.gz rm -f /tmp/newsyslog/cmd-test.log.1.bz2 rm -f /tmp/newsyslog/cmd-test.log.1.xz rm -f /tmp/newsyslog/cmd-test.log.0 rm -f /tmp/newsyslog/cmd-test.log.0.gz rm -f /tmp/newsyslog/cmd-test.log.0.bz2 rm -f /tmp/newsyslog/cmd-test.log.0.xz ln /tmp/newsyslog/cmd-test.log /tmp/newsyslog/cmd-test.log.0 touch /tmp/newsyslog/cmd-test.log.0 # Update mtime for 'when'-interval processing chmod 644 /tmp/newsyslog/cmd-test.log.0 Start new log... mktemp /tmp/newsyslog/cmd-test.log.zXXXXXX chmod 644 /tmp/newsyslog/cmd-test.log.zXXXXXX mv /tmp/newsyslog/cmd-test.log.zXXXXXX /tmp/newsyslog/cmd-test.log /tmp/newsyslog/signame-test.log <1J>: size (Kb): 1 [1] --> trimming log.... rm -f /tmp/newsyslog/signame-test.log.1 rm -f /tmp/newsyslog/signame-test.log.1.gz rm -f /tmp/newsyslog/signame-test.log.1.bz2 rm -f /tmp/newsyslog/signame-test.log.1.xz rm -f /tmp/newsyslog/signame-test.log.0 rm -f /tmp/newsyslog/signame-test.log.0.gz rm -f /tmp/newsyslog/signame-test.log.0.bz2 rm -f /tmp/newsyslog/signame-test.log.0.xz ln /tmp/newsyslog/signame-test.log /tmp/newsyslog/signame-test.log.0 touch /tmp/newsyslog/signame-test.log.0 # Update mtime for 'when'-interval processing chmod 644 /tmp/newsyslog/signame-test.log.0 Start new log... mktemp /tmp/newsyslog/signame-test.log.zXXXXXX chmod 644 /tmp/newsyslog/signame-test.log.zXXXXXX mv /tmp/newsyslog/signame-test.log.zXXXXXX /tmp/newsyslog/signame-test.log Signal all daemon process(es)... kill -30 20617 # /var/run/rspamd/rspamd.pid sleep 1 kill -30 30969 # /var/run/nginx.pid sleep 1 sh -c '/bin/ls 1' sleep 10 Compress all rotated log file(s)... bzip2 /tmp/newsyslog/signame-test.log.0 chmod 644 /tmp/newsyslog/signame-test.log.0.bz2 bzip2 /tmp/newsyslog/cmd-test.log.0 chmod 644 /tmp/newsyslog/cmd-test.log.0.bz2 bzip2 /tmp/newsyslog/signum-test.log.0 chmod 644 /tmp/newsyslog/signum-test.log.0.bz2 [alex@smaug.kaworu.ch /tmp/newsyslog] %