History log of /freebsd-9.3-release/usr.sbin/newsyslog/newsyslog.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 262076 17-Feb-2014 bdrewery

MFC r261401:

Fix newsyslog(8) to use the size of the file instead of the blocks it
takes on disk, as advertised in newsyslog.conf(5).

Approved by: bapt (mentor, implicit)


# 261821 13-Feb-2014 markj

MFC r257600:
Initialize the struct tm before handing it to strptime(3).


# 251532 08-Jun-2013 markj

MFC r235647 for newsyslog (by gleb):
Hide DIR definition by making it an opaque struct typedef.

Introduce dirfd() libc exported symbol replacing macro with same name,
preserve _dirfd() macro for internal use.

Replace dirp->dd_fd with dirfd() call. Avoid using dirfd as variable
name to prevent shadowing global symbol.

MFC r250545:
Some filesystems (NFS in particular) do not fill out the d_type field when
returning directory entries through readdir(3). In this case we need to
obtain the file type ourselves; otherwise newsyslog -t will not be able to
find archived log files and will fail to both delete old log files and to
do interval-based rotations properly.

MFC r251240:
We want to stat the archived log file rather than the logfile itself.


# 251113 29-May-2013 markj

Revert my previous merge. There's a variable name difference between head
and stable (dirfd vs. dir_fd) and I managed to get it wrong again when I
did the MFC, even after I tested.


# 251110 29-May-2013 markj

MFC r250545:
Some filesystems (NFS in particular) do not fill out the d_type field when
returning directory entries through readdir(3). In this case we need to
obtain the file type ourselves; otherwise newsyslog -t will not be able to
find archived log files and will fail to both delete old log files and to
do interval-based rotations properly.


# 250489 10-May-2013 markj

Fix the build: 'valid' is no longer used.


# 250478 10-May-2013 markj

MFC r248776:
Fix interval-based rotations when the -t flag is used. In this case, find
the most-recently archived logfile and use its mtime to determine whether
or not to rotate, as in the non-timestamped case.

Previously we would just try to use the mtime of <logfile>.0, which always
results in a rotation since it generally doesn't exist in the -t case.

Approved by: emaste


# 246918 17-Feb-2013 markj

MFC r245961 r245962 r245963.

MFC r245961:
When the 'R' flag is used with a newsyslog.conf entry, some fields of
the corresponding struct sigwork_entry were left uninitialized,
potentially causing an early return from do_sigwork(). Ensure that these
fields are initialized, and handle the 'R' flag properly in
do_sigwork().

MFC r245962:
Ensure that newsyslog -n prints the correct message for a rotation rule
that uses the 'R' flag.

MFC r245963:
Rename the run_cmd field to sw_runcmd to make it consistent with the
other fields in struct sigwork_entry.

Approved by: emaste (co-mentor)


# 245360 13-Jan-2013 markj

MFC r244995 r244996 r244997.

MFC r244995:
Fix a typo in an error message.

MFC r244996:
Have -n imply -r, since dry-run mode obviously doesn't require root
privileges.

MFC r244997:
Make sure to update the mtime of a logfile after archiving it. This
ensures that the next rotation happens at the correct time when using
interval-based rotations.

Approved by: rstone (co-mentor)


# 238520 16-Jul-2012 ae

MFC r238281:
We don't need to check the result of sending signal when R flag is
specified.

Submitted by: Ilya A. Arkhipov

Approved by: re (kib)


# 234674 25-Apr-2012 glebius

Merge r233257, r233258 from head:
Don't run through time checks when entry is definitely oversized. This
leads to newsyslog rotating on (size OR time) if both are specified.

Fix a sentence in a paragraph that describes time and interval based
trimming. This sentence vaguely can be interpreted as if it was speaking
about time and size interaction, while it wasn't about it.

PR: 100018, 160432


# 229899 09-Jan-2012 eadler

- Remove extraneous null ptr deref checks
- Fix memory leak

Approved by: jhb


# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 221873 14-May-2011 sobomax

Add new modifier - "R", when it is specified the path to pid file
will be considered as a path to a binary or a shell script to be executed
after rotation has been completed instead of sending signal to the process
id in that file.

Sponsored by: Sippy Software, Inc.
From the: FreeBSD hacking lounge at BSDCan


# 220926 21-Apr-2011 simon

Fix an old bug in newsyslog where we kept one log file more than was
requested in newsyslog.conf. This was only the case using the non-time
based filenames (.0, .1, .2 etc.).

The change also makes newsyslog clean clean up the old extra logfile so
users don't end up with a single stale logfile which won't be rotated
out.

This change also cleans up some code a bit to avoid more copy / paste
code and removes some old copy / paste code in the process.

PR: bin/76697
MFC after: 2 weeks


# 219434 09-Mar-2011 ru

Sync manpage's SYNOPSIS with program's usage.


# 218944 22-Feb-2011 sobomax

Make code more friendly to the non-C99 compilers - don't allocate
local variables in the `for' loop declaration. This allows trunk
newsyslog.c to be compiled on 7.x. This change should be no-op from
the functional POV.


# 218127 31-Jan-2011 mm

Add xz(1) support to newsyslog.
Rewrite and simplify logfile compression code.

Approved by: gad
MFC after: 3 weeks


# 216832 30-Dec-2010 brian

Make -S functional.

MFC after: 1 week


# 215625 21-Nov-2010 simon

Fix a typo in a comment.

MFC after: 3 days


# 210407 23-Jul-2010 brian

Add a -S switch to override the default syslog pid file. This can be useful
if syslogd's -P switch or a syslogd alternative is being used.

MFC after: 3 weeks


# 210372 22-Jul-2010 simon

Add support for creating the archived log filenames using a time-stamp
instead of the traditional simple counter.

Using the time-stamp based file-names, once a log file is archived, it
will not change name until it is deleted. This means that many backup
systems will only perform one backup of the archived log file, instead
for performing a new backup of the logfile upon each logfile rotation.

This implementation is separate from the patches in the mentioned PR,
as I wasn't aware of the existence of the PR until after I had
implemented the same functionality as the patches in the PR provide.
Unlike the PR, this new code does honor the 'log count' in
newsyslog.conf so old logfiles are deleted. This new code does not
currently support never deleting the archived logfiles.

PR: bin/29363
MFC after: 3 weeks


# 208649 29-May-2010 gordon

Add file include processing for newsyslog.

Format for the include line in /etc/newsyslog.conf is:
<include> /etc/defaults/newsyslog.conf

Other notes of interest:
Globbing is supported in <include> statements.
Properly detect circular include loop dependencies.

Reviewed by: gad@
Approved by: wes@ (mentor)
MFC after: 2 months


# 208648 29-May-2010 gordon

Convert newsyslog to using queue(3) macros instead of a home rolled version.

Reviewed by: gad@
Approved by: wes@ (mentor)
MFC after: 2 months


# 202668 19-Jan-2010 delphij

Add a new option, -P, which reverts newsyslog(8) to the old behavior,
which stops to proceed further, as it is possible that processes which
fails to create PID file get screwed by rotation.

Requested by: stas
MFC after: 2 weeks
X-MFC with: r200806


# 200806 21-Dec-2009 delphij

Don't consider non-existence of a PID file an error, we should be able
to proceed anyway as this most likely mean that the process has been
terminated.

PR: bin/140397
Submitted by: Dan Lukes <dan obluda cz>
MFC after: 1 month


# 175837 30-Jan-2008 delphij

Fix two typos.


# 161412 17-Aug-2006 delphij

Use same signedness for i and matched_c. This should make
newsyslog(8) WARNS=6 clean.


# 160560 21-Jul-2006 sobomax

Remove mention of the `W' flag, which has been turned to no-op by the
neworder change. Keep the option in a config file parser, to not
violate POLA.

MFC after: 2 weeks


# 159998 27-Jun-2006 gad

Remove the last three calls to strncpy(), two of which would have
been bugs if the source had ever been too big for the destination.

MFC after: 3 weeks


# 159968 26-Jun-2006 gad

Remove the "oldorder" processing. The "neworder" processing has
been the default for two years now, without any problems reported.

MFC after: 3 weeks


# 154566 20-Jan-2006 gad

Improve error-handling related to the fork() done to compress files after
they have been rotated. Among other things, use warnx() instead of warn()
for some messages where the value if errno is irrelevant to the problem
being reported.

MFC after: 5 days


# 152980 01-Dec-2005 sobomax

Fix logic error which causes <null> to be printed instead of the
actual file name in error message.

MFC After: 2 weeks


# 143106 03-Mar-2005 brooks

Add the -N option to not rotate any files. This is to be used in
cojunction with -C and is used by /etc/rc.d/newsyslog.

I forgot that this was in my perforce tree and not my running system and
thus committed a non-working newsyslog script.

Reported by: des
Pointy hat: brooks


# 139655 04-Jan-2005 delphij

Because the `permission' field in conf_entry is intended to be used as
parameter 2 in chmod(2), which is a mode_t (and in turn a __uint_16_t),
it's more likely that it should be defined as an unsigned variable.

This commit should make newsyslog WARNS=6 clean, but don't bump the knob
until I have a universe build.

MFC After: 1 month


# 136186 06-Oct-2004 brooks

Mention "-d directory" in usage().

Pointy hat to: brooks


# 136174 05-Oct-2004 brooks

Don't prepend the directory specified by -d when the file is a relative
path. Doing so makes no sense. I'm not sure allowing relative paths
makes sense either, but I'm not going to break that now.


# 136127 04-Oct-2004 brooks

Add a new -d argument which is used to specify an alternate root for log
files similar to DESTDIR in the BSD make process. This only affects log
file paths not config file (-f) or archive directory (-a) paths.


# 131581 04-Jul-2004 sobomax

Nothing says that /var/log can't be not a directory but a symbolic link
to a directory. Therefore, use stat(2) instead of lstat(2) to check if
/var/log exists.

MFC after: 7 days


# 130794 20-Jun-2004 gad

Fix the format-string in a call to err(). It was causing a warning if
compiled on 4.x-stable.


# 130707 19-Jun-2004 gad

Fix the check for a "duplicate filename to compress", so that we're checking
the *filename* and not the pid_file(!). Stupid brain-fault on my part.
This could cause a segfault under -neworder if newsyslog had to rotate
multiple files, and later ones had specifed the 'N' flag.

Bug first reported by: le
MFC after: 3 days


# 130385 12-Jun-2004 gad

Switch to using the "neworder" for rotating log files, by default. The
main advantage of this is that daemon's are only signalled once per run,
instead of once for each file that is rotated.

MFC after: 2 weeks


# 130205 07-Jun-2004 gad

Add an "oldorder" option, so that when the default changes to "neworder",
people have a way to drop back to the previous logic.

MFC after: 13 days


# 130204 07-Jun-2004 gad

In "neworder" processing, reduce the delay between signals to separate
processes, and balance that by adding a 10-second delay after all the
processes have been signaled. Also improvement a few messages printed
with `-n' or `-v' processing (mostly signal-related messages).

MFC after: 13 days


# 130167 07-Jun-2004 gad

Major re-ordering of the steps that newsyslog will use when processing
files to rotate. The new order will first rotate all files that need
to be rotated, and then send a single signal to each process which
needs to be signaled, and finally it will compress all the files which
were rotated.

This means daemons will be signaled once per run of newsyslog, instead
of once per file rotated. Also, files will be compressed in order of
file-size (smallest to largest). Also, it waits for each file to be
completely compressed before starting the next one (effectively as if
the 'w' flag is specified for all entries in newsyslog.conf). This
avoids the situation of having 10 gzip's going at the same time (each
with a log.0 and a log.0.gz file active), and it also means that file
attributes can be reliably set on files after they are compressed.

NOTE: This commit does define NEWORDER (which you could get rid of if
you really don't trust this), but it does not flip the "-D neworder"
switch. So, at the moment none of these changes happen unless you
request them (perhaps by adding '<debug> neworder' in newsyslog.conf).

PR: bin/25070 inspired some parts of this
Submitted by: parts from bin/25070 done by Helge Oldach
MFC after: 14 days


# 130165 06-Jun-2004 gad

A variety of minor changes. Allow users to set a debugging option via
the newsyslog.conf file. Rename one size-related variable, and move
another one from the stack into conf_entry. Add a routine to change
file-attributes (chown, chmod, chflags), instead of having several
places doing the same sequence of system-calls. A few cosmetic/style
changes.

These should not effect any users. Most of these probably look
pointless, but they are the "insignificant parts" of a much larger
update that I'll be committing soon. Doing these as a separate update
should make that update easier to read.

MFC after: 14 days


# 130045 03-Jun-2004 gad

Style-istic fix to a number of #define's that were not followed by a tab...

MFC after: 16 days


# 130043 03-Jun-2004 gad

Add a 'D' flag that can be specified on entries in newsyslog.conf.
If specified, the matching log files will have the NODUMP flag set
on them after they are created.

Submitted by: Sean Eric Fagan
MFC after: 16 days


# 130038 03-Jun-2004 gad

Change standard processing to use the newer createlog() routine
that had been written some months ago for other processing. This
should get rid of a few subtle situations where an existing log
file would not exist (for a short time) while it is being rotated.

MFC after: 16 days


# 129975 01-Jun-2004 gad

Improved versions of the is*ch() and tolowerch() macros that I like to use.


# 129974 01-Jun-2004 gad

When rotating some "blah.log" file, make sure that a chmod and
(if requested) a chown is done on the "blah.log.0" file.

PR: bin/67137
Submitted by: jeh
MFC after: 10 days


# 127858 04-Apr-2004 charnier

Do not :-terminate err(3) string, one will be added anyway.


# 120361 22-Sep-2003 gad

Restructure the time processing routines, mainly to fix up the
"will trim at" message printed when the user requests '-v'. The
previous code would often print the wrong time, such as:
On Sept 22, run: newsyslog -nv /var/log/wtmp
And see: will trim at Mon Sep 1 05:00:00 2003
correct msg: will trim at Wed Oct 1 05:00:00 2003

MFC after: 20 days


# 119998 11-Sep-2003 gad

Move the parse8601 and parseDWM routines into a new ptime.c file. The
only code-change is to add a "next_time" parameter to both routines (and
that is not used yet). A later update will make "next_time" more useful.

MFC after: 20 days


# 119927 09-Sep-2003 gad

Switch dotrim() to take advantage of the 'struct conf_entry' that
is already passed in, instead of having the caller copy values from
that struct into additional parameters.

MFC after: 22 days


# 119926 09-Sep-2003 gad

Reduce the annoying compiler warnings that pop up when compiling with
gcc 3.3.x and -Wshadow. Just renames 'log' variables to be 'logname'.

MFC after: 22 days


# 119905 09-Sep-2003 gad

Correct the comment about which timezone-change loses an hour...

MFC after: 23 days


# 119904 09-Sep-2003 gad

Add a '-D <something>' command line arg, which can be used to set
debugging options. Initial option is '-D TN=<time>', which can be
used to see how newsyslog would work if run at the specified time.
(time format is ISO 8601, since that is already supported).

MFC after: 23 days


# 119902 09-Sep-2003 gad

Use strtol() instead of strtoul() in parse8601, so we can detect
negative values. Mainly done to sync this routine with OpenBSD.

Obtained from: OpenBSD
MFC after: 23 days


# 119901 09-Sep-2003 gad

Fix typo in the previous commit. Was checking wrong variable...

MFC after: 23 days


# 119899 09-Sep-2003 gad

Change parse8601 and parseDWM so they return an alternate error value
for invalid times, and have the caller print the error message.

MFC after: 23 days


# 119897 09-Sep-2003 gad

Cosmetic change to move parse8601 right next to parseDWM. No code
is changed. (that will come in later updates).

MFC after: 23 days


# 119102 19-Aug-2003 gad

When checking the 'user:group' field in newsyslog.conf, freebsd's source
was mistakenly calling the standard isnumber() function to find out if
the given 'user' or 'group' were all numeric. This meant that only the
first character of the fields were actually checked, so a username of
(say) '3com' would look like a number, and thus get mapped to uid=3 (bin)
instead of username=3com.

This bug was introduced back in freebsd's v1.1. That initial import
almost matches netbsd's v1.9, except that an internal isnumber()
routine was removed in favor of the standard library version. The thing
is, that internal routine was checking the entire string, and not just
the first digit. In OpenBSD, isnumber() was eventually renamed to
isnumberstr() to make the distinction more obvious, and I'm going to
follow that lead.

I believe this also happens to remove the last references to isnumber()
in the entire freebsd base system.

Obtained from: OpenBSD, by a long circuitous route
MFC after: 5 days


# 118370 02-Aug-2003 gad

Fix an 'bad file descriptor' error which would come up when using
the 'C' flag on an entry that also specifies 'user:group' info.

Submitted by: Riccardo Torrini <riccardo@torrini.org> in -current
MFC after: 4 days


# 114764 05-May-2003 gad

Fix age_old_log checking so that it will notice log files which were
rotated and then compressed with bzip2 instead of gzip. Otherwise,
any file which had a time-interval specified for 'when' and also
specified the 'J' flag would be rotated every time newsyslog was run.
(this is a quick-fix, trying to beat the code-freeze for 5.1-release)

PR: bin/51519
MFC after: 1 week


# 114762 05-May-2003 gad

Slightly improve the checking of the 'size' field, so people will get
a warning message if they switch the values for 'size' and 'when'.

MFC after: 1 week


# 114601 03-May-2003 obrien

Use __FBSDID over rcsid[]. Protect copyright[] where needed.


# 114137 27-Apr-2003 gad

Add a -C (create) option for newsyslog, and a 'C' flag for entries in the
config file. If the -C option is specified once, then newsyslog will create
any entries which specify the 'C' option. If -C is given twice, then
newsyslog will create all missing log files. Some of this code comes
from NetBSD, although this implementation does not exactly match theirs.

Reviewed by: freebsd-arch
MFC after: 10 days


# 112020 09-Mar-2003 gad

Fix interactions between entries for a specific file vs entries for
a filename pattern, and also wrt filenames given on the command line.
Now if a file is listed as a specific entry, it will not *also* be
processed by an entry specifying a pattern. And filename-patterns
will now only match existing files (ignoring directories, etc).

MFC after: 3 weeks


# 112013 08-Mar-2003 gad

The processing of files given on the command-line will work a little better
if we return the entire worklist, instead of just the last entry. A minor
fix to revision 1.57.

MFC after: 15 days


# 112003 08-Mar-2003 gad

Add a config-file flag of 'U' or 'u' to indicate that the pid-file
will contain the pid for a process group. This means the file must
contain a negative value (as would be needed in the 'kill' commmand).
I still need to write man-page update before MFC-ing.

This started by rewriting the get_pid() routine. Later I looked at
what OpenBSD has, and included a few ideas from their send_signal()
routine. So, parts of this change are from OpenBSD, even though
OpenBSD does not actually have a 'U' flag.

PR: bin/28435
Reviewed by: no objections on freebsd-arch
MFC after: 3 weeks


# 111967 07-Mar-2003 gad

Prefix all -n (noaction) "unix cmds" with tab, thus making it much easier
to sort out noaction messages from -v (verbose) messages. This also
improves a few noaction messages.

Obtained from: OpenBSD
MFC after: 3 weeks


# 111966 07-Mar-2003 gad

Move the -s (nosignal) processing, as newsyslog needs to print out a
warning message if -s is specified and it rotates a file that expects
to be compressed. This warning message is not printed if -R is also
specified, because we assume a -sR request is coming from the process
which would have been signaled, and that it has already released the
logfile.

Indirectly noticed by: sheldonh


# 111820 03-Mar-2003 gad

Add missing 'static' on two routines, so they match their declarations.

PR: 29363 (a small part of)
Submitted by: dinoex
MFC after: 3 weeks


# 111781 03-Mar-2003 gad

A variety of cosmetic changes, mostly to (slightly) reduce diffs with
OpenBSD. Except for one added '\n', the object code is not changed.

MFC after: 3 weeks


# 111780 02-Mar-2003 gad

Collapse two more parameters to dotrim() into the 'ent' parameter that is
already there. This should not effect anything.

MFC after: 3 weeks


# 111779 02-Mar-2003 gad

Change to using uid_t and gid_t instead of int. Also change this won't
bother doing a chmod() if neither of these two fields are set.

Obtained from: OpenBSD
MFC after: 3 weeks


# 111773 02-Mar-2003 gad

Fix the interactions between specific log files given on the command line,
and config-file entries which specify a filename-pattern (glob). It is
still not perfectly-right, but at least it isn't completely-wrong.

Reviewed by: no objections on freebsd-arch
MFC after: 3 weeks
MFC addendum: (or after the code-freeze of 4.x is lifted)


# 111772 02-Mar-2003 gad

Add a command-line option of '-R somename', which indicates that newsyslog
should rotate all files given on the command, even if they don't seem to
need to be rotated. This would be used by some other command that decides
the given log file(s) should be rotated, but wants the "how" of that rotation
to be determined by entries to newsyslog. Wes expects to change syslogd to
take advantage of this. Man page will be updated after we're sure this is
all working the way we want it to.

Reviewed by: no objections on freebsd-arch
MFC after: 3 weeks
MFC addendum: (or after the code-freeze of 4.x is lifted)


# 111768 02-Mar-2003 gad

Add a command-line option of '-s', which indicates that newsyslog should
not send a signal to any processes. Also add a config-file flag of 'N' or
'n', which indicates that the given logfile has no process which needs a
signal when it is rotated. Both of these are based on changes NetBSD
has made, although the implementation is somewhat different.

PR: bin/36553 (2nd half)
Reviewed by: no objections on freebsd-arch
Obtained from: NetBSD (in spirit, at least)
MFC after: 3 weeks


# 111529 26-Feb-2003 gad

Fix an error which caused 'free(): error: chunk is already free'
if an entry in the config file included flag 'G'.

MFC after: 3 weeks


# 111400 24-Feb-2003 gad

Check the value given for number-of-logs to keep in config-file entries,
and error-out if the value is negative (avoiding an infinite loop).

PR: bin/30654 (part of it)
MFC after: 3 weeks


# 111398 24-Feb-2003 gad

1) Fix so -a honors the -n ("do nothing") option. Before, if the directory
given for -a did not exist, then newsyslog would always try to create
it, even if -n was specified.
2) When -a processing *does* create the directory, have it check the result
from mkdir(), and immediately error-out if that failed.

PR: bin/46974
MFC after: 3 weeks


# 111392 23-Feb-2003 gad

Minor style fix. Add parenthesis around 'return' values.

Reviewed by: md5
MFC after: 3 weeks


# 111388 23-Feb-2003 gad

Add the idea of a "default rotate action", which will be used if a file is
specified at runtime, but that filename is not listed in the newsyslog.conf
file. This default-action can be changed by having a line in newsyslog.conf
with the filename of "<default>". Before this change, the program would
quietly ignore the given file. An update to the man page will be written
after I finish some other updates to newsyslog.c.

Reviewed by: no objections from freebsd-arch
MFC after: 3 weeks


# 108164 21-Dec-2002 trhodes

Make newsyslog(8) print the correct date when the logs are turned over.

PR: 46395
Submitted by: maxim
MFC: eventually


# 107916 15-Dec-2002 sobomax

Add a new `W' flag, that when used in conjunction with the `Z' flag or the
`J' flag means that newsyslog should wait for previously started compression
jobs to complete before starting a new one for this entry. When it is used
along with the `G' flag, in the case when several logfiles match the pattern
and should be compressed, the newsyslog will compress logs one by one,
ensuring that only one compression job is running at a time.

This prevents newsyslog(8) from overloading system by starting several
compression jobs on big files simultaneously.

Sponsored by: Porta Software Ltd
MFC after: 2 weeks


# 107737 10-Dec-2002 sobomax

- Allow comments to be placed at the end of configuration line.

Sponsored by: Porta Software Ltd
Approved by: re
MFC after: 2 weeks


# 106905 14-Nov-2002 sobomax

Add a new newsyslog.conf flag - 'G', which if set tells newsyslog(8) that
the specified filename of the log to be rotated is in fact shell glob
pattern. In this case, all files matching this pattern will be rotated
using the same options. Useful in the case when there is no pre-defined
name for the logfiles (e.g. xtradius, samba etc).

Sponsored by: PortaOne Software Ltd
MFC after: 2 weeks


# 105248 16-Oct-2002 maxim

Fix getopt(3) optstring: remove a flag we does not handle.

PR: bin/44066
Submitted by: Stefan Farfeleder <e0026813@stud3.tuwien.ac.at>
MFC after: 1 week


# 99209 01-Jul-2002 maxim

Remove the last EOF spaces I missed in rev. 1.43.

MFC after: 1 week


# 96001 03-May-2002 maxim

style(9): sort includes, remove EOL spaces.

MFC after: 1 week


# 95999 03-May-2002 maxim

wait(2) for compress_log() processes to complete before exit.

Spotted by: Grigoriy Strokin <grg@isabase.philol.msu.ru>
Reviewed by: -current
MFC after: 1 month


# 94352 10-Apr-2002 sheldonh

Close a very small window during which new (empty) instances of rotated log
files are owned by the caller of newsyslog (usually root:wheel) even if
alternative ownerships were specified in newsyslog.conf.

Note that this is part of a wider problem which is fully addressed in
OpenBSD. Anyone with the time and inclination to incorporate the full
fix for the wider problem will receive no complaints from me and should
feel free to walk all over this delta.

PR: bin/36738
MFC after: 1 week


# 93659 02-Apr-2002 cjc

Produce a different error message for mktime(3) failure than for bad
newsyslog.conf syntax.

PR: bin/36641


# 90240 05-Feb-2002 roam

Fix -F with logfiles rotated on time only.

Approved by: silence on -audit
MFC after: 1 month


# 86360 14-Nov-2001 obrien

Fix the type of the NULL arg to execl().


# 80742 31-Jul-2001 obrien

jhb says a 10 line change containing casts is more invasive than a 28 line
change.


# 80684 30-Jul-2001 obrien

Use the POSIX syntax for chown.

Submmited by: garrett


# 80666 30-Jul-2001 wollman

Simplify (and hopefully clarify) some date-parsing arithmetic.


# 80646 30-Jul-2001 obrien

style(9)


# 80640 30-Jul-2001 obrien

WARNS-2'ify.
(this included removing the funny "if (unsigned_var < 0)" test)


# 80638 30-Jul-2001 obrien

Add the ability to Bzip2 your logs.

PR: 27901
Submitted by: Anders Nordby <anders@fix.no> (stylistic changes by me)


# 79452 09-Jul-2001 brian

Fix the type of the NULL arg to execl()

Idea from: Theo de Raadt <deraadt@openbsd.org>


# 71299 20-Jan-2001 jedgar

- Correct MAXPATHLEN/MAXHOSTNAMELEN usage
- Check return values of malloc() and strdup()
- Replace strcpy()/strcat()/sprintf() usage with strlcpy()/snprintf

Reviewed by: -audit


# 64663 15-Aug-2000 joe

When warning that a log file can't be compressed, tell the reader which
log file it was.


# 60373 11-May-2000 des

Allow user to specify which logs to rotate


# 59004 04-Apr-2000 hm

- implement logfile archivation to a separate, user
configurable directory
- implement alternate and more flexible way to specify
logfile rotation time in addition to the ISO 8601
restricted format
- cleanup the source which was a mix of several styles
of persons who maintained it so far, ran through
knfom script got from bde.

Reviewed by: (in part) sheldonh and garyj


# 59003 04-Apr-2000 hm

Run newsyslog source through knfom script obtained from Bruce Evans.
Joerg Wunsch suggested to do this to make the functional changes in
the next commit to newsyslog (which were run through the same script)
better visible.


# 50479 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 49145 28-Jul-1999 obrien

Go back to allowing ``.'' as a username.group separator for backward
compatibility. : is still the documented non-ambiguous approach. The
algorithm used will correctly parse david.obrien.staff as strrchar() is
used, and in my mind more people would use a ``.'' in the username than
the group name.

Convinced by argument and patch by: sheldonh (with slight changes by me)


# 48295 28-Jun-1999 obrien

Syntax for user/group is changed from "user.group" to "user:group" to be
consistant with chown(8).


# 43071 22-Jan-1999 wollman

A slight bit of code and doco cleanup, but mostly:

Add the much-needed and long-desired ability to force the log rotation
to take place on a specific day or time, and document same. This works
by extending the syntax of the `when' field to allow a restricted
ISO 8601 time specification, and performing the log rotation if newsyslog
is run during the same hour as is specified.


# 42031 23-Dec-1998 peter

The largest PID is now 99999
Reported by: Ben Stuyts <ben@stuyts.nl>


# 36817 09-Jun-1998 ache

Add optional config file field: signal number to send (defaulted to HUP)
F.e. apache restarts less agressively on USR1 then on HUP


# 35920 10-May-1998 hoek

1) kill -HUP syslog, even if compressing supposedly "binary" files
PR: docs/6385

2) -n (noaction) does not imply -r (run as non-root), since as of
Rev. 1.12 (ache), -r changes actual behaviour.

3) missing \n from if(noaction) messages.


# 35917 10-May-1998 hoek

Arg! Someone fixed the synopsis in -stable's newsyslog.8, but not
in -current. However, they fixed both the ordering and the missing -F
flag. Merge from 22 and fix ordering here, too.


# 35915 10-May-1998 hoek

Fix the usage here, too (-F option).

Typo fix in comment ("Force the tim now matter what" s/tim/trim/)


# 34584 14-Mar-1998 pst

Add "-F" (force) flag to newsyslog.
Submitted by: Terry Lambert <terry@freebsd.org>


# 31460 30-Nov-1997 ache

Sleep 10secs after kill -HUP instead of 3secs, some daemons like Apache
may have log time to re-configure


# 30160 06-Oct-1997 charnier

Cosmetic in err() strings.


# 25518 06-May-1997 brian

Allow a '-' flag as a placeholder so that path_to_pid_file
can be specified without the flags field.
Fix bogus "trail" left in parse routine where the code jumps
past the end of the line and wanders into oblivion.


# 25496 05-May-1997 ache

Do not kill -HUP syslog if running in user mode (-r), it allows
private user logs rotation without error diagnostics


# 25443 03-May-1997 ache

1) Add yet one optional field: pid file to send SIGHUP to if log rotated
(good thing for apache f.e.) This change is backward compatible with old
newsyslog.conf files.

2) Do not compress log if SIGHUP sending failed for some reason
(f.e. pid file deleted). Newcoming messages will be lost
otherwise.

3) Misc cleanup while I am here.


# 24428 31-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 22997 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 18188 09-Sep-1996 jkh

Doh! Actually read the patch I applied and see what it was *trying* to do,
then make it do that.
Error-of-my-ways-pointed-out-by: Bob Willcox <bob@luke.pmr.com>


# 18075 06-Sep-1996 jkh

PR#2724 in NetBSD notes that newsyslog save log files even if the number
of copies to save is zero. Incorporate suggested fix with some stylistic
cleanup to make the resulting code more readable.
Submitted-By: Kenneth Stailey <kstailey@dol-esa.gov>


# 16240 08-Jun-1996 alex

Added function prototypes and removed in-line prototypes of standard
functions such as malloc and time.


# 16174 07-Jun-1996 alex

Fix uninitialized variable that caused a core dump if /etc/newsyslog.conf
was empty. Closes PR bin/1300.

Found by: Brian Tao <taob@io.org>


# 13460 16-Jan-1996 graichen

Submitted by: charnier@lirmm.fr (Philippe Charnier)
1) correct MAX_PID according to system definition.
2) replace fprintf(stderr,...)/perror/exit by 4.4 equivalence.
3) make strings enough larger so they can't overflow: MAXHOSTNAMELEN for
host and MAXPATHLEN for filenames.
4) call execl with correct parameters (compress -> gzip).


# 13358 09-Jan-1996 graichen

Obtained from: NetBSD (PR#1906)
removed date formatting glitch in newsyslog


# 13245 05-Jan-1996 graichen

This commit was generated by cvs2svn to compensate for changes in r13244,
which included commits to RCS files with non-trunk default branches.


# 13244 05-Jan-1996 graichen

Obtained from: NetBSD
imported the newsyslog command from NetBSD - it make the "rotation" of
the logfiles much simpler (it is currently done by "hand" in the
/etc/[daily,weekly,monthly] scripts) - now it will be done by invoking
newsyslog every hour which is very customizable via a
/etc/newsyslog.conf file