Commit Graph

226 Commits

Author SHA1 Message Date
Bryan Drewery
28323add09 Fix improper use of "its".
Sponsored by:	Dell EMC Isilon
2016-11-08 23:59:41 +00:00
Ed Schouten
23e591f485 Properly patch up dirname()/basename() calls to not clobber ent->log.
It turns out that we had a couple of more calls to dirname()/basename()
in newsyslog(8) that assume the input isn't clobbered. This is bad,
because it apparently breaks log rotation now that the new dirname()
implementation has been merged.

Fix this by first copying the input and then calling
dirname()/basename(). While there, improve the naming of variables in
this function a bit.

Reported by:	Ryan Steinmetz, gjb
Reviewed by:	bdrewery, allanjude
Differential Revision:	https://reviews.freebsd.org/D7838
2016-09-09 07:10:50 +00:00
Enji Cooper
771e2c7753 Expect sub testcases 2-4 in :tests_time_rotate to fail today due to changes
to newsyslog, etc made in the past month.

The issue is being root-caused as part of the bug noted below. This commit
will need to be partially reverted once the issue has been found/fixed

PR:		212160
Reported by:	Jenkins
Sponsored by:	EMC / Isilon Storage Division
2016-08-29 18:46:04 +00:00
Ed Schouten
f0d2919243 Clean up use of basename() and dirname().
Pull copies of the input pathname string before calling basename() and
dirname() to make this comply to POSIX. Free these copies at the end of
this function. While there, remove the duplication of the 's' ->
'logfname' string. There is no need for this.
2016-07-28 16:02:30 +00:00
Eric van Gyzen
c152ba971f newsyslog: Eliminate unnecessary sleep(10) when -R and -s are specified
After going through the signal work list, during which do_sigwork()
is called and essentially does nothing because -s and -R were
specified on the command line, newsyslog will sleep for 10 seconds
as the (verbose) code says: "Pause 10 seconds to allow daemon(s)
to close log file(s)".

However, the man page verbiage for -R (and -s) seems quite clear
that this sleep() is unnecessary because the daemon was expected
to have already closed the log file before calling newsyslog.

PR:		210020
Submitted by:	David A. Bright <david_a_bright@dell.com>
MFC after:	1 week
Sponsored by:	Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D6727
2016-06-06 22:54:08 +00:00
Enji Cooper
430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
Glen Barber
7d536dc855 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-10 21:16:01 +00:00
Bryan Drewery
15c433351f DIRDEPS_BUILD: Connect MK_TESTS.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:46:01 +00:00
Glen Barber
43faedc133 First pass to fix the 'tests' packages.
Sponsored by:	The FreeBSD Foundation
2016-02-02 22:26:49 +00:00
Baptiste Daroussin
caeff1fd44 newsyslog: treat 'c' flag in the config as 'C'
When -C was introduced in r114137 the plan was to have -C and -c being used for
"create" due to a typo in FreeBSD <= 4.8 a temporary compatibility hack has been
added to make -c being like -G aka GLOB and a warning was issued for the user to
be aware of the futur change for -c.

12 years later it is more than time to remove that hack and finish the what was
intent in r114137

Submitted by:	Alexandre Perrin <alex@kaworu.ch>
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D4000
2015-10-31 09:45:11 +00:00
Baptiste Daroussin
c91d99bf1c newsyslog.conf: allow to configure the signal using the signal name.
Submitted by:	Alexandre Perrin <alex@kaworu.ch>
MFC after:	1 week
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D3961
2015-10-24 13:55:12 +00:00
Eitan Adler
463a577b27 Fix a ton of speelling errors
arc lint is helpful

Reviewed By: allanjude, wblock, #manpages, chris@bsdjunk.com
Differential Revision: https://reviews.freebsd.org/D3337
2015-10-21 05:37:09 +00:00
Enji Cooper
b2d48be1bc Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) and
netbsd-tests.test.mk (r289151)

- Eliminate explicit OBJTOP/SRCTOP setting
- Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk
- Remove unnecessary TESTSDIR setting
- Use SRCTOP where possible for clarity

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Divison
2015-10-12 08:16:03 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Mark Johnston
9f08174d47 If we fail to send a signal after rotation, print the pidfile from which
the corresponding PID was obtained.

PR:		194143
Submitted by:	Lyndon Nerenberg <lyndon@orthanc.ca>
MFC after:	1 week
2014-10-08 17:44:30 +00:00
Bryan Drewery
0fb1b79f4d Make it more explicitly clear that -t will not change filename.
MFC after:	3 days
2014-09-23 13:58:39 +00:00
Simon J. Gerraty
ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Bryan Drewery
b39df8fe2d - Include /etc/newsyslog.conf.d/* and /usr/local/etc/newsyslog.conf.d/* by
default for newsyslog(8).

  The /usr/local/etc/newsyslog.conf.d will give packages an opportunity to
  install a default configuration to handle their own log files.

MFC after:	2 weeks
Relnotes:	yes
2014-05-20 03:00:20 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty
cc3f4b9965 Merge from head 2014-05-08 23:54:15 +00:00
Warner Losh
c6063d0da8 Use src.opts.mk in preference to bsd.own.mk except where we need stuff
from the latter.
2014-05-06 04:22:01 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Julio Merino
d14afb2adc Migrate tools/regression/{usr.bin/lastcomm,usr.sbin}/ to the new tests layout.
This change was originally going to only migrate the usr.sbin tests but, as
it turns out, the usr.sbin/sa/ tests require files from usr.bin/lastcomm/
so it's better to just also migrate the latter at the same time.  The other
usr.bin tests will be moved separately.

To make these tests work within the test suite, some of them have required
changes to prevent modifying the source directory and instead just rely on
the current directory for file manipulation.
2014-03-16 04:09:22 +00:00
Bryan Drewery
e3b7979645 Fix newsyslog(8) to use the size of the file instead of the blocks it
takes on disk, as advertised in newsyslog.conf(5).

This fixes newsyslog(8) on ZFS with compression enabled to not have
large files compared to the expected rotation size.

  # grep remotes/messages /etc/newsyslog.conf
  /var/log/remote/messages       root:info       640  5     500  *     JC
  # ls -alh /var/log/remote/messages
  -rw-r-----  1 root  info    3.2M Jan 31 20:02 /var/log/remote/messages
  # newsyslog -vN|grep remote/messages
  /var/log/remote/messages <5J>: size (Kb): 464 [500] --> skipping
  # stat -f "st_size: %z st_blocks: %b" /var/log/remote/messages
  st_size: 3372627 st_blocks: 928
  # zfs get -H compressratio zroot/syslogs
  zroot/syslogs    compressratio   3.77x   -

With fix:

  # newsyslog -v | grep remote/messages
  /var/log/remote/messages <5J>: size (Kb): 3338 [500] --> trimming log....

Approved by:	bapt (mentor)
PR:		docs/150877
Reported by:	Joshua Isom <jrisom@gmail.com>
MFC after:	2 weeks
2014-02-02 14:11:34 +00:00
Mark Johnston
de6d612a0e Initialize the struct tm before handing it to strptime(3).
PR:		183550
MFC after:	2 weeks
2013-11-04 02:50:43 +00:00
Simon J. Gerraty
d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Tim Kientzle
8f95d0d822 Fix -Wunsequenced
Submitted by:	dt71@gmx.com
2013-06-29 15:58:03 +00:00
Mark Johnston
950ff8e4dd We want to stat the archived log file rather than the logfile itself.
PR:		bin/179122
Submitted by:	Oliver Fromme <olli@secnetix.de>
MFC after:	3 days
2013-06-02 01:10:49 +00:00
Mark Johnston
3cc26586e6 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.

Reported by:	jilles
Reviewed by:	jilles
MFC after:	2 weeks
2013-05-12 01:58:04 +00:00
Simon J. Gerraty
69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Mark Johnston
91ba008fc5 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.

PR:		bin/166448
Approved by:	emaste (co-mentor)
Tested by:	Marco Steinbach <coco executive-computing.de>
MFC after:	2 weeks
2013-03-26 23:11:30 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
David E. O'Brien
d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
Mark Johnston
6a82e4291b Rename the run_cmd field to sw_runcmd to make it consistent with the
other fields in struct sigwork_entry.

Approved by:	rstone (co-mentor)
MFC after:	1 week
2013-01-27 06:03:57 +00:00
Mark Johnston
6df0ff43f0 Ensure that newsyslog -n prints the correct message for a rotation rule
that uses the 'R' flag.

Reviewed by:	gad
Approved by:	rstone (co-mentor)
MFC after:	1 week
2013-01-27 06:02:38 +00:00
Mark Johnston
3b58eef59e 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().

PR:		bin/175330
Reviewed by:	gad
Approved by:	rstone (co-mentor)
MFC after:	1 week
2013-01-27 06:01:35 +00:00
Mark Johnston
9df22a6e88 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.

PR:		bin/174438
Reviewed by:	gad
Approved by:	rstone (co-mentor)
MFC after:	1 week
2013-01-03 16:14:51 +00:00
Mark Johnston
468d206524 Have -n imply -r, since dry-run mode obviously doesn't require root
privileges.

Approved by:	rstone (co-mentor)
MFC after:	1 week
2013-01-03 16:12:48 +00:00
Mark Johnston
220936938f Fix a typo in an error message.
Approved by:	rstone (co-mentor)
MFC after:	1 week
2013-01-03 16:11:24 +00:00
Simon J. Gerraty
23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Ed Schouten
eccad22277 More -Wmissing-variable-declarations fixes.
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.
2012-10-20 10:33:15 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Andrey V. Elsukov
131f6ef034 We don't need to check the result of sending signal when -R option is
specified.

Submitted by:	Ilya A. Arkhipov
MFC after:	1 week
2012-07-09 07:37:10 +00:00
Joel Dahl
ba0edfb981 mdoc: fix mandoc "Oc breaks Op" warning. 2012-06-09 09:54:07 +00:00
Joel Dahl
8972c8b6a5 Minor spelling fixes. 2012-06-03 11:29:48 +00:00
Gleb Kurtsou
0bb2aabf26 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.

Sponsored by:	Google Summer Of Code 2011
2012-05-19 12:44:27 +00:00