Commit Graph

160 Commits

Author SHA1 Message Date
Brian Somers
318a43da85 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
2010-07-23 09:11:47 +00:00
Simon L. B. Nielsen
872e964d07 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
2010-07-22 11:23:18 +00:00
Gordon Tetlow
82c00be8ee 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
2010-05-29 22:55:59 +00:00
Gordon Tetlow
a40596d77a Convert newsyslog to using queue(3) macros instead of a home rolled version.
Reviewed by:	gad@
Approved by:	wes@ (mentor)
MFC after:	2 months
2010-05-29 22:52:17 +00:00
Ulrich Spörlein
0b31f1f731 mdoc: move remaining sections into consistent order
This pertains mostly to FILES, HISTORY, EXIT STATUS and AUTHORS sections.

Found by:	mdocml lint run
Reviewed by:	ru
2010-05-13 12:08:11 +00:00
Xin LI
ccc28f774a 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
2010-01-20 01:07:38 +00:00
Ed Schouten
71ccf09269 The last big commit: let usr.sbin/ use WARNS=6 by default. 2010-01-02 11:07:44 +00:00
Xin LI
f65917cdc3 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
2009-12-21 20:12:01 +00:00
Maxim Sobolev
cb45b78eae Fix 6-year old cut&paste error. The # could be escaped with '\', not
with '\\'.

MFC after:	2 weeks
2008-06-26 07:02:47 +00:00
Xin LI
874f1f4efe Fix two typos. 2008-01-30 22:11:59 +00:00
Remko Lodder
67f3da0107 s/effect/affect/
PR:		docs/118266
Submitted by:	"Kim Scarborough" <sluggo at unknown dot nu>
MFC After:	3 days
2007-11-27 06:50:21 +00:00
Ruslan Ermilov
bc84aa4ba3 Markup fixes. 2006-09-29 17:57:04 +00:00
Xin LI
ccb43d66aa Use same signedness for i and matched_c. This should make
newsyslog(8) WARNS=6 clean.
2006-08-17 18:15:43 +00:00
Maxim Sobolev
7697c5e483 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
2006-07-21 22:13:06 +00:00
Garance A Drosehn
656f773000 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
2006-06-27 22:14:09 +00:00
Garance A Drosehn
a04de8fa95 Remove the "oldorder" processing. The "neworder" processing has
been the default for two years now, without any problems reported.

MFC after:	3 weeks
2006-06-27 00:18:15 +00:00
Garance A Drosehn
616270cb21 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
2006-01-20 05:18:01 +00:00
Maxim Sobolev
4fd87db95a Fix logic error which causes <null> to be printed instead of the
actual file name in error message.

MFC After:	2 weeks
2005-12-01 03:47:01 +00:00
Ruslan Ermilov
9d73fabda7 Markup fixes.
Approved by:	re (blanket)
2005-06-14 12:26:36 +00:00
Brooks Davis
deea909a70 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
2005-03-03 15:47:32 +00:00
Tom Rhodes
35da865ad7 Add a HISTORY section.
PR:	75282
2005-02-24 06:03:31 +00:00
Ruslan Ermilov
0227791b40 Expand *n't contractions. 2005-02-13 22:25:33 +00:00
Ruslan Ermilov
5c8e5f2462 Fixed xrefs. 2005-01-21 10:35:40 +00:00
Ruslan Ermilov
59a3c79da6 Sort sections. 2005-01-18 20:02:45 +00:00
Xin LI
9e3daa8dcf 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
2005-01-04 02:24:01 +00:00
Brooks Davis
5616e1bc20 Mention "-d directory" in usage().
Pointy hat to:	brooks
2004-10-06 04:47:37 +00:00
Brooks Davis
59fdf30f92 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.
2004-10-05 22:16:31 +00:00
Brooks Davis
842ba60ee2 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.
2004-10-04 23:35:13 +00:00
Maxim Sobolev
ea6902220d 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
2004-07-04 17:24:12 +00:00
Ruslan Ermilov
07bfccd71e Mechanically kill hard sentence breaks. 2004-07-02 23:13:00 +00:00
Garance A Drosehn
fbb4e16a3b Fix the format-string in a call to err(). It was causing a warning if
compiled on 4.x-stable.
2004-06-20 17:26:47 +00:00
Garance A Drosehn
5ff798ca5f 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
2004-06-19 03:28:42 +00:00
Ruslan Ermilov
9cdb6ee164 Assorted markup, grammar, and spelling fixes. 2004-06-13 18:03:44 +00:00
Garance A Drosehn
c8fd7c3227 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
2004-06-12 19:53:08 +00:00
Garance A Drosehn
398faf1205 Drop the include for <stdint.h>, it was only needed when this was
using __DECONST() for something, and that reference has been removed.

Noticed by:	Helge Oldach
MFC after:	13 days
2004-06-07 21:53:27 +00:00
Garance A Drosehn
4559c1817b 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
2004-06-07 21:18:09 +00:00
Garance A Drosehn
aa6904eb66 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
2004-06-07 21:09:58 +00:00
Garance A Drosehn
7f5b34d7c0 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
2004-06-07 02:10:10 +00:00
Garance A Drosehn
9d780a43c4 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
2004-06-07 01:21:30 +00:00
Garance A Drosehn
d7dc92dc0f Style-istic fix to a number of #define's that were not followed by a tab...
MFC after:	16 days
2004-06-03 23:44:38 +00:00
Garance A Drosehn
55bf17e958 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
2004-06-03 23:41:49 +00:00
Garance A Drosehn
b2cd42638f 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
2004-06-03 22:26:16 +00:00
Garance A Drosehn
efdb85c8f4 Improved versions of the is*ch() and tolowerch() macros that I like to use. 2004-06-02 00:14:28 +00:00
Garance A Drosehn
f1da56014e 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
2004-06-02 00:02:12 +00:00
Philippe Charnier
66e338b333 Do not :-terminate err(3) string, one will be added anyway. 2004-04-04 19:25:39 +00:00
Tom Rhodes
491abe5ac7 Move newsyslog.conf.5 to usr.sbin/newsyslog. There is no real history
other than 'initial revision' thus I did not request a repocopy.

Requested by:   ru, gad
2004-03-12 16:03:26 +00:00
Tom Rhodes
ef4b3aa2e3 Remove information about the configuration file.
Add an Xref to newsyslog.conf.5 and bzip2.1.
2004-03-11 04:32:16 +00:00
Garance A Drosehn
c303328741 Handle a 'const' parameter without using __DECONST().
MFC after:	14 days
2003-10-04 02:24:47 +00:00
Garance A Drosehn
6a1485e2fe 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
2003-09-23 00:00:26 +00:00
Garance A Drosehn
526d55a405 Correct the calculation of "a leap year" in parseDWM. The calculation
would only match a leap year every 400 years.  The parseDWM code first
showed up in April 2000, so the first time this bug would cause any
confusion is in Feb 2004.

MFC after:	18 days
2003-09-14 00:56:50 +00:00