Commit Graph

32 Commits

Author SHA1 Message Date
Alexander Leidinger
b45f09ac57 periodic: switch lockf to silent operation.
This fixes duplicate mails (one from cron, one from periodic)
when a periodic run is not finished bfore the next one starts.

The man page states that the intended use case is cron, and
the error handling of the lockf invocation handles this case
explicitely, as such no error message for the "interactive"
use was considered.
2023-02-28 09:38:42 +01:00
Peter Wemm
81a48881c6
periodic: Use a deterministic $PATH for periodic.
Various tools can have alternate versions elsewhere, eg: the GNU
mailutils port (a dependency of emacs*) brings /usr/local/bin/mail.
Match the preset PATH in /etc/crontab for deterministic path searches
even when run manually with a different environment.

PR:		259265
Reported by:	iandstanley@gmail.com
2021-12-20 18:54:56 -08:00
Alan Somers
9809df467b periodic: replace "tty" with "test -t 0"
Apparently using tty for this purpose has been deprecated since 4.4 Lite.

Reviewed by:	cy
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D21318
2019-08-19 01:14:11 +00:00
Alan Somers
a9ff79e3bb periodic: fix anticongestion for scripts run after security
Revision 316342, which introduced the anticongestion feature, failed to
consider that the periodic scripts are executed by a recursive invocation of
periodic.  The recursive invocation wrongly cleaned up a temporary file that
should've been cleaned up only by the original invocation.  The result is
that if the first script that requests an anticongestion sleep runs after
the security scripts, the sleep won't happen.

Fix this bug by delaying cleanup until the end of the original invocation.

PR:		236564
Submitted by:	Yasuhiro KIMURA <yasu@utahime.org>
Reviewed by:	imp
MFC after:	1 month
2019-08-18 17:12:06 +00:00
Alan Somers
8394104312 periodic: fix exit status for nonexistent arguments
When called with an absolute pathname, periodic should attempt to execute
every script in that directory. If the directory does not exist, it should
print an error and exit 1. Due to a copy/paste mistake in r231568, it exits
0 in that case.

Reported by:	devel/hs-ShellCheck
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D13070
2017-11-20 23:51:51 +00:00
Enji Cooper
84c8bb4fbc periodic(8): delete trailing whitespace
MFC after:	1 month
2017-06-20 06:20:09 +00:00
Alan Somers
86571b9c01 Consolidate random sleeps in periodic scripts
Multiple periodic scripts sleep for a random amount of time in order to
mitigate the thundering herd problem. This is bad, because the sum of
multiple uniformly distributed random variables approaches a normal
distribution, so the problem isn't mitigated as effectively as it would be
with a single sleep.

This change creates a single configurable anticongestion sleep. periodic
will only sleep if at least one script requires it, and it will never sleep
more than once per invocation. It also won't sleep if periodic was run
interactively, fixing an unrelated longstanding bug.

PR:		217055
PR:		210188
Reviewed by:	cy
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D10211
2017-04-01 04:42:35 +00:00
Alan Somers
c5b5b50ded Better document security_show_{success,info,badconfig} in /etc/periodic.conf
periodic(8) already handles the security_show_{success,info,badconfig}
variables correctly. However, those variables aren't explicitly set in
/etc/defaults/periodic.conf or anywhere else, which suggests to the user
that they shouldn't be used.

etc/defaults/periodic.conf
	Explicitly set defaults for security_show_{success,info,badconfig}

usr.sbin/periodic/periodic.sh
	Update usage string

usr.sbin/periodic/periodic.8
	Minor man page updates

One thing I'm _not_ doing is recommending setting security_output to
/var/log/security.log or adding that file to /etc/newsyslog.conf, because
periodic(8) would create it with default permissions, usually 644, and
that's probably a bad idea.

Reviewed by:	brd
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6477
2016-05-21 02:14:11 +00:00
Jeremie Le Hen
94582faa19 Include the calling context in the mail subject, if any.
More concretely, periodic security scripts defaults to being
called from daily ones -- daily context -- so the mail subject
will now be "${HOST} daily security run output" instead of
"{HOST} security run output".

If you switch the period of some security checks to weekly, you
will receive another email "${HOST} weekly security run output".
2013-09-03 13:40:24 +00:00
Jeremie Le Hen
195cf868e2 Export a PERIODIC environment variable from periodic(8). This will
allow periodic security scripts to know if they have been called in
a daily or a weekly context.
2013-08-25 08:56:09 +00:00
Brooks Davis
df01f319c7 Prevent periodic scripts that run longer than the expected period from
starting up before the previous script finishes.  This prevents an
infinite number of them from piling up and slowing a system down.

Since all the refactoring to make this happen required churning the
indenting of most of this file, make the indentation more consistent.

Reviewed by:	simon
MFC after:	1 week
2012-02-12 23:18:05 +00:00
David Malone
68c35072f9 Add an option to make periodic(8) quiet when no output was generated.
The man page part of the patch is my fault, the changes to the
periodic script is Dominik's.

PR:		88486
Submitted by:	Dominik Brettnacher <domi@saargate.de>
Reviewed by:	brian
Approved by:	re
MFC after:	1 month
2007-06-22 10:04:05 +00:00
Brian Somers
cb36028eff Mention the ``end of output'' for each periodic script.
Submitted by:	David Wolfskill <david@catwhisker.org>
PR:		37036
MFC after:	1 week
2002-05-14 01:15:35 +00:00
Kris Kennaway
a3125484c9 Properly fix the temporary file creation in the case of multiple
command-line arguments.

Noticed by:	dynamo <dynamo@ime.net>
2000-11-26 03:37:34 +00:00
Kris Kennaway
5542f1c473 Don't use a trivially predictable temporary filename and keep recreating
it again and again, practically begging the Bad Man to insert his symlink
underneath it and send us down the path to oblivion.

Noticed by:	David Lary <dlary@secureworks.net>
2000-11-02 06:33:57 +00:00
Brian Somers
e4b13c6df1 Fix a typo
Spotted by: Manfred Antar <null@pozo.com>
2000-09-20 19:59:44 +00:00
Brian Somers
df470af5f8 Put temporary output in ${TMPDIR:-/tmp}
If $<basedir>_output is not set, don't redirect output

PR:	21395
2000-09-19 22:15:00 +00:00
Brian Somers
8a7f44a640 Don't clobber $? before using it.
Submitted by:	James Barkley <jbarkley@wgate.com>
2000-09-19 21:46:54 +00:00
Brian Somers
15ef3dc005 Fix situations where none of the scripts executed produce output,
so that we don't see any more ``null message body, hope that's
ok'' messages.

We now see something like ``No output from the 3 files processed''.

Lump all output for a given periodic argument together so that
people with /usr/local/etc/periodic/daily (for example) will
get the output of those jobs together with the normal daily run
rather than getting a second email.

Prompted by: ben
2000-09-16 21:59:34 +00:00
Brian Somers
9ed55d1192 Another overhaul of the periodic stuff.
All periodic sub-scripts <larf> now have their return codes interpreted
by periodic(8).  Output may be masked based on variable values in
periodic.conf.

It's also now possible to email periodic output to arbitrary addresses,
or to send it to a log file, examples of which can be found in
newsyslog.conf.

The upshot of it all should be no discernable changes to the default
behaviour of periodic(8).

PR:	21250
2000-09-14 17:19:15 +00:00
Brian Somers
f3e285ba7d Introduce /etc/defaults/periodic.conf, similar in concept to rc.conf.
The only change in the default functionality should be that
the output reports are slightly more verbose WRT files deleted.

Not objected to by: freebsd-arch
2000-06-23 01:18:31 +00:00
Neil Blakey-Milner
b61bde0916 Update periodic to use the function source_rc_confs that
/etc/defaults/rc.conf now exports.
2000-04-27 17:11:03 +00:00
Chris Piazza
2bed2aa31f export host after setting it.
This is needed so passwd diffs show the hostname instead of
" passwd diffs:"

PR:		17651
Submitted by:	Giorgos Keramidas <keramida@ceid.upatras.gr>
2000-03-29 07:05:29 +00:00
Peter Wemm
97d92980a9 $Id$ -> $FreeBSD$ 1999-08-28 01:35:59 +00:00
Jordan K. Hubbard
f10c8b1a7b Look in correct rc.conf file.
Submitted by:	Kevin Street <street@iname.com
1999-02-14 20:06:02 +00:00
Bill Fumerola
54724311ee Make periodic(8) and the security mailings reflect the full FQDN, as opposed
to a hostname. This will help those who keep a cluster of machines all with
the same hostname but different domain names.

PR:		bin/9091
Submitted By:	Heikki Suonsivu <hsu@clinet.fi>
No Response From: -current mailing list
1999-01-01 17:37:33 +00:00
Tim Vanderhoek
9300774d7e Directories aren't executable.
Submitted by:	Dennis Glatting <dennis.glatting@software-munitions.com>
		(misc/9147)
1998-12-29 22:48:54 +00:00
Paul Traina
02eab22ca1 Change local_cron to local_periodic.
Submitted by:	bde
1997-08-19 16:49:35 +00:00
Paul Traina
2a13325f76 Use /etc/periodic 1997-08-16 17:08:35 +00:00
Paul Traina
a2940c0e75 Back out the fancy directory sorting, it's more pain that its worth,
and it's there in the CVS repository in case someone things that this
idea is superkeen.
1997-08-13 06:23:54 +00:00
Paul Traina
fb1485d3e3 Incorporate some ideas that came up during discussion with msmith. 1997-08-13 06:02:18 +00:00
Paul Traina
c0fa6e333d Initial import of periodic executable control program. 1997-08-12 17:48:49 +00:00