Commit Graph

99 Commits

Author SHA1 Message Date
Garance A Drosehn
4adea93613 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
2003-05-05 23:38:03 +00:00
Garance A Drosehn
bedb455962 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
2003-05-05 22:27:37 +00:00
David E. O'Brien
b728350ee6 Use __FBSDID over rcsid[]. Protect copyright[] where needed. 2003-05-03 21:06:42 +00:00
Garance A Drosehn
28045703cc 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
2003-04-27 23:37:31 +00:00
Garance A Drosehn
bc6c007686 Document support for the new 'U' flag, which was implemented back in March
as revision 1.64 of newsyslog.c.  I plan to MFC these changes next week.

MFC after:	1 week
2003-04-24 20:50:01 +00:00
Garance A Drosehn
3d3e9b01a1 Document support for the new -s and -R command-line options, and
the 'N' flag.  These were coded in March as revisions 1.55 and 1.56
of newsyslog.c.  I intend to MFC all the matching changes next week.
This also reorganizes the description of the 'flags' field to give
list of the valid flags, instead of a long paragraph explaining
each of the possible values.

Obtained from:	NetBSD (in spirit at least, for -s and N)
MFC after:	1 week
2003-04-24 01:34:40 +00:00
Garance A Drosehn
356e4049da Document support for the <default> entry, which was implemented in
revision 1.50 of newsyslog.c , back in February.  I intend to MFC
those changes soon.

MFC after:	4 days
2003-04-23 21:26:12 +00:00
Garance A Drosehn
9ffd2d77ef 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
2003-03-09 03:19:52 +00:00
Garance A Drosehn
4ebd61a3cf 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
2003-03-09 00:29:40 +00:00
Garance A Drosehn
ae77078c25 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
2003-03-08 20:07:01 +00:00
Garance A Drosehn
a42568171f 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
2003-03-07 21:29:34 +00:00
Garance A Drosehn
40fe458d04 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
2003-03-07 21:06:32 +00:00
Garance A Drosehn
69ea8786d6 Add missing 'static' on two routines, so they match their declarations.
PR:		29363 (a small part of)
Submitted by:	dinoex
MFC after:	3 weeks
2003-03-03 15:31:35 +00:00
Garance A Drosehn
d4948dc25e 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
2003-03-03 02:53:35 +00:00
Garance A Drosehn
2f5d9e2994 Collapse two more parameters to dotrim() into the 'ent' parameter that is
already there.  This should not effect anything.

MFC after:	3 weeks
2003-03-03 01:58:33 +00:00
Garance A Drosehn
e2fe500ec5 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
2003-03-03 01:23:34 +00:00
Garance A Drosehn
7cf31d2ff5 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)
2003-03-03 00:01:51 +00:00
Garance A Drosehn
9fb022b6d6 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)
2003-03-02 23:23:11 +00:00
Garance A Drosehn
f2c3715aa7 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
2003-03-02 22:05:17 +00:00
Garance A Drosehn
5ac30d6d34 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
2003-02-26 03:20:38 +00:00
Garance A Drosehn
39d0141328 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
2003-02-24 02:28:46 +00:00
Garance A Drosehn
27f1bc0c71 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
2003-02-24 02:09:02 +00:00
Garance A Drosehn
debfc5e11d Minor style fix. Add parenthesis around 'return' values.
Reviewed by:	md5
MFC after:	3 weeks
2003-02-24 01:05:05 +00:00
Garance A Drosehn
93943fff46 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
2003-02-24 00:51:41 +00:00
Jens Schweikhardt
57bd0fc6e8 english(4) police. 2002-12-27 12:15:40 +00:00
Tom Rhodes
35c45e664a Make newsyslog(8) print the correct date when the logs are turned over.
PR:		46395
Submitted by:	maxim
MFC:		eventually
2002-12-21 22:27:26 +00:00
Maxim Sobolev
bffa911730 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
2002-12-15 19:28:02 +00:00
Maxim Sobolev
4ea03b3140 Backout unapproved WARNS level change occasionally slipped into previous
commit.

Big pointy hat to:	sobomax
2002-12-11 01:21:57 +00:00
Maxim Sobolev
f2562be03e - Allow comments to be placed at the end of configuration line.
Sponsored by:   Porta Software Ltd
Approved by:    re
MFC after:      2 weeks
2002-12-11 01:19:56 +00:00
Ruslan Ermilov
c041c1e0d9 mdoc(7) police: markup fixes.
Approved by:	re
2002-11-27 15:31:08 +00:00
Maxim Sobolev
2e01a2be1e 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
2002-11-14 08:43:07 +00:00
Maxim Konovalov
a9a25f59fa 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
2002-10-16 14:20:20 +00:00
Philippe Charnier
490d5836b5 The .Nm utility 2002-07-14 14:47:15 +00:00
Maxim Konovalov
21ee796112 Remove the last EOF spaces I missed in rev. 1.43.
MFC after:	1 week
2002-07-01 13:18:52 +00:00
Maxim Konovalov
cc37581539 style(9): sort includes, remove EOL spaces.
MFC after:	1 week
2002-05-03 21:03:37 +00:00
Maxim Konovalov
021e53b8df 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
2002-05-03 20:53:37 +00:00
Sheldon Hearn
669d663174 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
2002-04-10 10:38:44 +00:00
Crist J. Clark
aeeb2b2bbb Produce a different error message for mktime(3) failure than for bad
newsyslog.conf syntax.

PR:		bin/36641
2002-04-02 12:03:16 +00:00
Peter Pentchev
115f46ff8f Fix -F with logfiles rotated on time only.
Approved by:	silence on -audit
MFC after:	1 month
2002-02-05 09:33:07 +00:00
David E. O'Brien
a4482d5ce1 Fix the type of the NULL arg to execl(). 2001-11-14 17:00:58 +00:00
Ruslan Ermilov
eb6626f52a WARNS= -> WARNS?= 2001-09-21 07:25:53 +00:00
David E. O'Brien
904cc0c45c jhb says a 10 line change containing casts is more invasive than a 28 line
change.
2001-07-31 16:25:55 +00:00
David E. O'Brien
f1d4135bd9 Use the POSIX syntax for chown.
Submmited by:	garrett
2001-07-30 23:26:19 +00:00
Garrett Wollman
ef404327b0 Simplify (and hopefully clarify) some date-parsing arithmetic. 2001-07-30 18:27:21 +00:00
David E. O'Brien
4c9237c908 style(9) 2001-07-30 16:27:16 +00:00
David E. O'Brien
9674b13dcb WARNS-2'ify.
(this included removing the funny "if (unsigned_var < 0)" test)
2001-07-30 15:41:20 +00:00
David E. O'Brien
e12f0d2fac Add the ability to Bzip2 your logs.
PR:		27901
Submitted by:	Anders Nordby <anders@fix.no> (stylistic changes by me)
2001-07-30 15:17:17 +00:00
David E. O'Brien
90e655ea4e Perform a major cleanup of the usr.sbin Makefiles.
These are not perfectly in agreement with each other style-wise, but they
are orders of orders of magnitude more consistent style-wise than before.
2001-07-20 06:20:32 +00:00
Garrett Wollman
9fb54cb322 Note the equivalence of certain time formats. 2001-07-19 15:52:02 +00:00
Dima Dorfman
5d88e21a2a Instead of giving an example of rotating logs at the end of the month,
give an example of how to rotate logs at the beginning of the month.
Although they sound the same, since both of them rotate logs at the
beginning of the day, the former ended up taking place on, e.g., July
31 00:00 instead of the expected July 31 23:59.  This is contraty to POLA.

Submitted by:	Dan Langille <dan@langille.org>
2001-07-19 11:18:42 +00:00