summaryrefslogtreecommitdiffstats
path: root/usr.sbin/newsyslog/newsyslog.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r261401:bdrewery2014-02-171-1/+1
| | | | | | | 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)
* MFC r257600:markj2014-02-131-0/+1
| | | | Initialize the struct tm before handing it to strptime(3).
* Fix -Wunsequencedkientzle2013-06-291-10/+10
| | | | Submitted by: dt71@gmx.com
* We want to stat the archived log file rather than the logfile itself.markj2013-06-021-1/+1
| | | | | | PR: bin/179122 Submitted by: Oliver Fromme <olli@secnetix.de> MFC after: 3 days
* Some filesystems (NFS in particular) do not fill out the d_type field whenmarkj2013-05-121-6/+17
| | | | | | | | | | | 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. Reported by: jilles Reviewed by: jilles MFC after: 2 weeks
* Fix interval-based rotations when the -t flag is used. In this case, findmarkj2013-03-261-58/+134
| | | | | | | | | | | | | 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. PR: bin/166448 Approved by: emaste (co-mentor) Tested by: Marco Steinbach <coco executive-computing.de> MFC after: 2 weeks
* Rename the run_cmd field to sw_runcmd to make it consistent with themarkj2013-01-271-7/+7
| | | | | | | other fields in struct sigwork_entry. Approved by: rstone (co-mentor) MFC after: 1 week
* Ensure that newsyslog -n prints the correct message for a rotation rulemarkj2013-01-271-4/+9
| | | | | | | | that uses the 'R' flag. Reviewed by: gad Approved by: rstone (co-mentor) MFC after: 1 week
* When the 'R' flag is used with a newsyslog.conf entry, some fields ofmarkj2013-01-271-1/+3
| | | | | | | | | | | | 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(). PR: bin/175330 Reviewed by: gad Approved by: rstone (co-mentor) MFC after: 1 week
* Make sure to update the mtime of a logfile after archiving it. Thismarkj2013-01-031-0/+9
| | | | | | | | | | ensures that the next rotation happens at the correct time when using interval-based rotations. PR: bin/174438 Reviewed by: gad Approved by: rstone (co-mentor) MFC after: 1 week
* Have -n imply -r, since dry-run mode obviously doesn't require rootmarkj2013-01-031-1/+1
| | | | | | | privileges. Approved by: rstone (co-mentor) MFC after: 1 week
* Fix a typo in an error message.markj2013-01-031-1/+1
| | | | | Approved by: rstone (co-mentor) MFC after: 1 week
* More -Wmissing-variable-declarations fixes.ed2012-10-201-21/+23
| | | | | | | | | | In addition to adding missing `static' keywords: - bin/dd: Pull in `extern.h' to guarantee consistency with source file. - libexec/rpc.rusersd: Move shared globals into an extern.h. - libexec/talkd: Move `debug' and `hostname' into extern.h. - usr.bin/cksum: Put counters in extern.h, as they are used by ckdist/mtree. - usr.bin/m4: Move `end_result' into extern.h. - usr.sbin/services_mkdb: Move shared globals into an extern.h.
* We don't need to check the result of sending signal when -R option isae2012-07-091-1/+2
| | | | | | | specified. Submitted by: Ilya A. Arkhipov MFC after: 1 week
* Hide DIR definition by making it an opaque struct typedef.gleb2012-05-191-3/+3
| | | | | | | | | | 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. Sponsored by: Google Summer Of Code 2011
* Don't run through time checks when entry is definitely oversized. Thisglebius2012-03-211-2/+5
| | | | | | leads to newsyslog rotating on (size OR time) if both are specified. PR: 100018, 160432
* Further fix a typo and spelling classic correctly in function names,uqs2012-01-051-8/+8
| | | | | | too. Submitted by: Ben Kaduk <minimarmot@gmail.com>
* Replace index() and rindex() calls with strchr() and strrchr().ed2012-01-031-4/+4
| | | | | | | | | | The index() and rindex() functions were marked LEGACY in the 2001 revision of POSIX and were subsequently removed from the 2008 revision. The strchr() and strrchr() functions are part of the C standard. This makes the source code a lot more consistent, as most of these C files also call into other str*() routines. In fact, about a dozen already perform strchr() calls.
* Spelling fixes for usr.sbin/uqs2011-12-301-2/+2
|
* - Remove extraneous null ptr deref checkseadler2011-12-211-1/+2
| | | | | | | | - Fix memory leak Submitted by: Slono Slono <slonoman2011@yandex.ru> Approved by: jhb MFC after: 1 week
* Add new modifier - "R", when it is specified the path to pid filesobomax2011-05-141-30/+61
| | | | | | | | | 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
* Fix an old bug in newsyslog where we kept one log file more than wassimon2011-04-211-31/+59
| | | | | | | | | | | | | | | 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
* Sync manpage's SYNOPSIS with program's usage.ru2011-03-091-2/+2
|
* Make code more friendly to the non-C99 compilers - don't allocatesobomax2011-02-221-4/+8
| | | | | | 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.
* Add xz(1) support to newsyslog.mm2011-01-311-93/+121
| | | | | | | Rewrite and simplify logfile compression code. Approved by: gad MFC after: 3 weeks
* Make -S functional.brian2010-12-311-1/+1
| | | | MFC after: 1 week
* Fix a typo in a comment.simon2010-11-211-1/+1
| | | | MFC after: 3 days
* Add a -S switch to override the default syslog pid file. This can be usefulbrian2010-07-231-2/+7
| | | | | | if syslogd's -P switch or a syslogd alternative is being used. MFC after: 3 weeks
* Add support for creating the archived log filenames using a time-stampsimon2010-07-221-16/+236
| | | | | | | | | | | | | | | | | | | 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
* Add file include processing for newsyslog.gordon2010-05-291-17/+109
| | | | | | | | | | | | | 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
* Convert newsyslog to using queue(3) macros instead of a home rolled version.gordon2010-05-291-113/+71
| | | | | | Reviewed by: gad@ Approved by: wes@ (mentor) MFC after: 2 months
* Add a new option, -P, which reverts newsyslog(8) to the old behavior,delphij2010-01-201-3/+7
| | | | | | | | | 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
* Don't consider non-existence of a PID file an error, we should be abledelphij2009-12-211-1/+12
| | | | | | | | | 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
* Fix two typos.delphij2008-01-301-2/+2
|
* Use same signedness for i and matched_c. This should makedelphij2006-08-171-1/+2
| | | | newsyslog(8) WARNS=6 clean.
* Remove mention of the `W' flag, which has been turned to no-op by thesobomax2006-07-211-3/+1
| | | | | | | neworder change. Keep the option in a config file parser, to not violate POLA. MFC after: 2 weeks
* Remove the last three calls to strncpy(), two of which would havegad2006-06-271-6/+6
| | | | | | been bugs if the source had ever been too big for the destination. MFC after: 3 weeks
* Remove the "oldorder" processing. The "neworder" processing hasgad2006-06-271-250/+16
| | | | | | been the default for two years now, without any problems reported. MFC after: 3 weeks
* Improve error-handling related to the fork() done to compress files aftergad2006-01-201-15/+38
| | | | | | | | 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
* Fix logic error which causes <null> to be printed instead of thesobomax2005-12-011-1/+1
| | | | | | actual file name in error message. MFC After: 2 weeks
* Add the -N option to not rotate any files. This is to be used inbrooks2005-03-031-3/+13
| | | | | | | | | | 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
* Because the `permission' field in conf_entry is intended to be used asdelphij2005-01-041-1/+1
| | | | | | | | | | 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
* Mention "-d directory" in usage().brooks2004-10-061-1/+1
| | | | Pointy hat to: brooks
* Don't prepend the directory specified by -d when the file is a relativebrooks2004-10-051-1/+1
| | | | | 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.
* Add a new -d argument which is used to specify an alternate root for logbrooks2004-10-041-2/+9
| | | | | files similar to DESTDIR in the BSD make process. This only affects log file paths not config file (-f) or archive directory (-a) paths.
* Nothing says that /var/log can't be not a directory but a symbolic linksobomax2004-07-041-2/+2
| | | | | | | to a directory. Therefore, use stat(2) instead of lstat(2) to check if /var/log exists. MFC after: 7 days
* Fix the format-string in a call to err(). It was causing a warning ifgad2004-06-201-1/+1
| | | | compiled on 4.x-stable.
* Fix the check for a "duplicate filename to compress", so that we're checkinggad2004-06-191-1/+1
| | | | | | | | | 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
* Switch to using the "neworder" for rotating log files, by default. Thegad2004-06-121-1/+9
| | | | | | | 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
* Add an "oldorder" option, so that when the default changes to "neworder",gad2004-06-071-0/+8
| | | | | | people have a way to drop back to the previous logic. MFC after: 13 days
OpenPOWER on IntegriCloud