View | Details | Raw Unified | Return to bug 174054
Collapse All | Expand All

(-)etc/periodic.subr (+82 lines)
Line 0 Link Here
1
#!/bin/sh
2
# $FreeBSD$
3
#
4
# Copyright (c) 2012 The FreeBSD Project.
5
# All rights reserved.
6
#
7
# Redistribution and use in source and binary forms, with or without
8
# modification, are permitted provided that the following conditions
9
# are met:
10
# 1. Redistributions of source code must retain the above copyright
11
#    notice, this list of conditions and the following disclaimer.
12
# 2. Redistributions in binary form must reproduce the above copyright
13
#    notice, this list of conditions and the following disclaimer in the
14
#    documentation and/or other materials provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT AND CONTRIBUTORS
17
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
# POSSIBILITY OF SUCH DAMAGE.
27
#
28
# periodic.subr
29
#	functions used by periodic(5) scripts
30
#
31
32
: ${rcvar_manpage:='periodic.conf(5)'}
33
34
if [ -z "${_periodic_subr_loaded}" ]; then
35
36
_periodic_subr_loaded="YES"
37
38
# If there is a global system configuration file, suck it in.
39
#
40
if [ -r /etc/defaults/periodic.conf ]; then
41
	. /etc/defaults/periodic.conf
42
	source_periodic_confs
43
fi
44
45
. /etc/rc.subr
46
47
# Cat out a [compressed] set of log(s).
48
#
49
# Parameters:
50
# 1 - log directory.
51
# 2 - log basename, e.g. auth, messages, etc.
52
catlogs() {
53
	local _logdir _log_basename rc
54
55
	_logdir="$1"
56
	_log_basename="$2"
57
58
	if [ ! -d "${_logdir:-}" ]; then
59
		err 3 "log directory specified - ${_logdir} doesn't exist"
60
	elif [ -z "${_log_basename:-}" ]; then
61
		err 3 "you must supply a non-zero length log basename"
62
	fi
63
64
	# Cat out the compressed logs.
65
	find "${_logdir}" -name "$log_basename.*" -mtime -2 |
66
	    sort -t. -r -n -k 2,2 |
67
	    while read f
68
	    do
69
		case $f in
70
		*.gz)	zcat -f $f;;
71
		*.bz2)	bzcat -f $f;;
72
		esac
73
	    done
74
	# Cat out the original log.
75
	if [ -f "$_logdir/$_log_basename" ]; then
76
		cat "$_logdir/$_log_basename"
77
	fi
78
}
79
80
fi # [ -z "${_periodic_subr_loaded}" ]
81
82
_periodic_subr_loaded=:
(-)etc/Makefile (+1 lines)
Lines 31-36 Link Here
31
	networks \
31
	networks \
32
	newsyslog.conf \
32
	newsyslog.conf \
33
	nsswitch.conf \
33
	nsswitch.conf \
34
	periodic.subr \
34
	phones \
35
	phones \
35
	profile \
36
	profile \
36
	protocols \
37
	protocols \
(-)etc/defaults/periodic.conf (-5 / +10 lines)
Lines 150-160 Link Here
150
daily_queuerun_enable="YES"				# Run mail queue
150
daily_queuerun_enable="YES"				# Run mail queue
151
daily_submit_queuerun="YES"				# Also submit queue
151
daily_submit_queuerun="YES"				# Also submit queue
152
152
153
# 800.scrub-zfs
153
# 800.zfs_scrub
154
daily_scrub_zfs_enable="NO"
154
daily_scrub_zfs_enable="YES"				# Scrub zpools
155
daily_scrub_zfs_pools=""			# empty string selects all pools
155
daily_scrub_zfs_default_threshold="35"			# scrub every 5 weeks
156
daily_scrub_zfs_default_threshold="35"		# days between scrubs
156
daily_scrub_zfs_pools=""				# zpools to scrub;
157
#daily_scrub_zfs_${poolname}_threshold="35"	# pool specific threshold
157
							# defaults to all
158
#daily_scrub_zfs_${poolname}_threshold="35"		# pool specific scrub
159
							# threshold
158
160
159
# 999.local
161
# 999.local
160
daily_local="/etc/daily.local"				# Local scripts
162
daily_local="/etc/daily.local"				# Local scripts
Lines 266-271 Link Here
266
268
267
# 200.accounting
269
# 200.accounting
268
monthly_accounting_enable="YES"				# Login accounting
270
monthly_accounting_enable="YES"				# Login accounting
271
monthly_accounting_verbose="NO"				# Be verbose when
272
							# reporting login
273
							# accounting info.
269
274
270
# 999.local
275
# 999.local
271
monthly_local="/etc/monthly.local"			# Local scripts
276
monthly_local="/etc/monthly.local"			# Local scripts
(-)etc/periodic/daily/100.clean-disks (-27 / +16 lines)
Lines 5-55 Link Here
5
# Remove garbage files more than $daily_clean_disks_days days old
5
# Remove garbage files more than $daily_clean_disks_days days old
6
#
6
#
7
7
8
# If there is a global system configuration file, suck it in.
8
. /etc/periodic.subr
9
#
10
if [ -r /etc/defaults/periodic.conf ]
11
then
12
    . /etc/defaults/periodic.conf
13
    source_periodic_confs
14
fi
15
9
16
case "$daily_clean_disks_enable" in
10
rc=0
17
    [Yy][Ee][Ss])
11
12
if checkyesno daily_clean_disks_enable; then
18
	if [ -z "$daily_clean_disks_days" ]
13
	if [ -z "$daily_clean_disks_days" ]
19
	then
14
	then
20
	    echo '$daily_clean_disks_enable is set but' \
15
	    err 2 '$daily_clean_disks_enable is set but' \
21
		'$daily_clean_disks_days is not'
16
		'$daily_clean_disks_days is not'
22
	    rc=2
23
	elif [ -z "$daily_clean_disks_files" ]
17
	elif [ -z "$daily_clean_disks_files" ]
24
	then
18
	then
25
	    echo '$daily_clean_disks_enable is set but' \
19
	    err 2 '$daily_clean_disks_enable is set but' \
26
		'$daily_clean_disks_files is not'
20
		'$daily_clean_disks_files is not'
27
	    rc=2
28
	else
21
	else
29
	    echo ""
22
	    if checkyesno daily_clean_disks_verbose; then
30
	    echo "Cleaning disks:"
23
		echo ""
24
		echo "Cleaning disks:"
25
26
		print=-print
27
	    else
28
		print=
29
	    fi
31
	    set -f noglob
30
	    set -f noglob
32
	    args="-name "`echo "$daily_clean_disks_files" |
31
	    args="-name "`echo "$daily_clean_disks_files" |
33
		sed -e 's/^[ 	]*//' \
32
		sed -e 's/^[ 	]*//' \
34
		    -e 's/[ 	]*$//' \
33
		    -e 's/[ 	]*$//' \
35
		    -e 's/[ 	][ 	]*/ -o -name /g'`
34
		    -e 's/[ 	][ 	]*/ -o -name /g'`
36
35
37
	    case "$daily_clean_disks_verbose" in
38
		[Yy][Ee][Ss])
39
		    print=-print;;
40
		*)
41
		    print=;;
42
	    esac
43
44
	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -prune -o \
36
	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -prune -o \
45
		\( $args \) -atime +$daily_clean_disks_days \
37
		\( $args \) -atime +$daily_clean_disks_days \
46
		-execdir rm -df {} \; $print | tee /dev/stderr | wc -l)
38
		-execdir rm -df {} \; $print | tee /dev/stderr | wc -l)
47
	    [ -z "$print" ] && rc=0
48
	    [ $rc -gt 1 ] && rc=1
39
	    [ $rc -gt 1 ] && rc=1
49
	    set -f glob
40
	    set -f glob
50
	fi;;
41
	fi
42
fi
51
43
52
    *)  rc=0;;
53
esac
54
55
exit $rc
44
exit $rc
(-)etc/periodic/daily/110.clean-tmps (-25 / +14 lines)
Lines 6-30 Link Here
6
# don't end up with excessively old files there.
6
# don't end up with excessively old files there.
7
#
7
#
8
8
9
# If there is a global system configuration file, suck it in.
9
. /etc/periodic.subr
10
#
11
if [ -r /etc/defaults/periodic.conf ]
12
then
13
    . /etc/defaults/periodic.conf
14
    source_periodic_confs
15
fi
16
10
17
case "$daily_clean_tmps_enable" in
11
rc=0
18
    [Yy][Ee][Ss])
12
13
if checkyesno daily_clean_tmps_enable; then
19
	if [ -z "$daily_clean_tmps_days" ]
14
	if [ -z "$daily_clean_tmps_days" ]
20
	then
15
	then
21
	    echo '$daily_clean_tmps_enable is set but' \
16
	    err 2 '$daily_clean_tmps_enable is set but' \
22
		'$daily_clean_tmps_days is not'
17
		'$daily_clean_tmps_days is not'
23
	    rc=2
24
	else
18
	else
25
	    echo ""
19
	    if checkyesno daily_clean_tmps_verbose; then
26
	    echo "Removing old temporary files:"
20
		echo ""
21
		echo "Removing old temporary files:"
27
22
23
		print=-print
24
	    else
25
		print=
26
	    fi
28
	    set -f noglob
27
	    set -f noglob
29
	    args="-atime +$daily_clean_tmps_days -mtime +$daily_clean_tmps_days"
28
	    args="-atime +$daily_clean_tmps_days -mtime +$daily_clean_tmps_days"
30
	    args="${args} -ctime +$daily_clean_tmps_days"
29
	    args="${args} -ctime +$daily_clean_tmps_days"
Lines 35-47 Link Here
35
		dargs="$dargs "`echo " ${daily_clean_tmps_ignore% }" |
34
		dargs="$dargs "`echo " ${daily_clean_tmps_ignore% }" |
36
		    sed 's/[ 	][ 	]*/ ! -name /g'`
35
		    sed 's/[ 	][ 	]*/ ! -name /g'`
37
	    }
36
	    }
38
	    case "$daily_clean_tmps_verbose" in
39
		[Yy][Ee][Ss])
40
		    print=-print;;
41
		*)
42
		    print=;;
43
	    esac
44
45
	    rc=$(for dir in $daily_clean_tmps_dirs
37
	    rc=$(for dir in $daily_clean_tmps_dirs
46
		do
38
		do
47
		    [ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && {
39
		    [ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && {
Lines 49-60 Link Here
49
			find -d . ! -name . -type d $dargs -delete $print
41
			find -d . ! -name . -type d $dargs -delete $print
50
		    } | sed "s,^\\.,  $dir,"
42
		    } | sed "s,^\\.,  $dir,"
51
		done | tee /dev/stderr | wc -l)
43
		done | tee /dev/stderr | wc -l)
52
	    [ -z "$print" ] && rc=0
53
	    [ $rc -gt 1 ] && rc=1
44
	    [ $rc -gt 1 ] && rc=1
54
	    set -f glob
45
	    set -f glob
55
	fi;;
46
	fi
47
fi
56
48
57
    *)  rc=0;;
58
esac
59
60
exit $rc
49
exit $rc
(-)etc/periodic/daily/120.clean-preserve (-27 / +15 lines)
Lines 5-53 Link Here
5
# Remove stale files in /var/preserve
5
# Remove stale files in /var/preserve
6
#
6
#
7
7
8
# If there is a global system configuration file, suck it in.
8
. /etc/periodic.subr
9
#
10
if [ -r /etc/defaults/periodic.conf ]
11
then
12
    . /etc/defaults/periodic.conf
13
    source_periodic_confs
14
fi
15
9
16
case "$daily_clean_preserve_enable" in
10
rc=0
17
    [Yy][Ee][Ss])
11
12
if checkyesno daily_clean_preserve_enable; then
18
	if [ -z "$daily_clean_preserve_days" ]
13
	if [ -z "$daily_clean_preserve_days" ]
19
	then
14
	then
20
	    echo '$daily_clean_preserve_enable is set but' \
15
	    err 2 '$daily_clean_preserve_enable is set but' \
21
		'$daily_clean_preserve_days is not'
16
		'$daily_clean_preserve_days is not'
22
	    rc=2
23
	elif [ ! -d /var/preserve ]
17
	elif [ ! -d /var/preserve ]
24
	then
18
	then
25
	    echo '$daily_clean_preserve_enable is set but /var/preserve' \
19
	    err 2 '$daily_clean_preserve_enable is set but /var/preserve' \
26
		"doesn't exist"
20
		"doesn't exist"
27
	    rc=2
28
	else
21
	else
29
	    echo ""
22
	    if checkyesno daily_clean_preserve_verbose; then
30
	    echo "Removing stale files from /var/preserve:"
23
		echo ""
24
		echo "Removing stale files from /var/preserve:"
31
25
26
		print=-print
27
	    else
28
		print=
29
	    fi
32
	    if cd /var/preserve
30
	    if cd /var/preserve
33
	    then
31
	    then
34
		case "$daily_clean_preserve_verbose" in
35
		    [Yy][Ee][Ss])
36
			print=-print;;
37
		    *)
38
			print=;;
39
		esac
40
41
		rc=$(find . ! -name . -mtime +$daily_clean_preserve_days \
32
		rc=$(find . ! -name . -mtime +$daily_clean_preserve_days \
42
		    -delete $print | tee /dev/stderr | wc -l)
33
		    -delete $print | tee /dev/stderr | wc -l)
43
		[ -z "$print" ] && rc=0
44
		[ $rc -gt 1 ] && rc=1
34
		[ $rc -gt 1 ] && rc=1
45
	    else
35
	    else
46
		rc=3
36
		rc=3
47
	    fi
37
	    fi
48
	fi;;
38
	fi
39
fi
49
40
50
    *)  rc=0;;
51
esac
52
53
exit $rc
41
exit $rc
(-)etc/periodic/daily/130.clean-msgs (-15 / +7 lines)
Lines 5-25 Link Here
5
# Remove system	messages
5
# Remove system	messages
6
#
6
#
7
7
8
# If there is a global system configuration file, suck it in.
8
. /etc/periodic.subr
9
#
10
if [ -r /etc/defaults/periodic.conf ]
11
then
12
    . /etc/defaults/periodic.conf
13
    source_periodic_confs
14
fi
15
9
16
case "$daily_clean_msgs_enable" in
10
rc=0
17
    [Yy][Ee][Ss])
11
12
if checkyesno daily_clean_msgs_enable; then
18
	if [ ! -d /var/msgs ]
13
	if [ ! -d /var/msgs ]
19
	then
14
	then
20
	    echo '$daily_clean_msgs_enable is set but /var/msgs' \
15
	    err 2 '$daily_clean_msgs_enable is set but /var/msgs' \
21
		"doesn't exist"
16
		"doesn't exist"
22
	    rc=2
23
	else
17
	else
24
	    echo ""
18
	    echo ""
25
	    echo "Cleaning out old system announcements:"
19
	    echo "Cleaning out old system announcements:"
Lines 27-35 Link Here
27
	    [ -n "$daily_clean_msgs_days" ] &&
21
	    [ -n "$daily_clean_msgs_days" ] &&
28
		arg=-${daily_clean_msgs_days#-} || arg=
22
		arg=-${daily_clean_msgs_days#-} || arg=
29
	    msgs -c $arg && rc=0 || rc=3
23
	    msgs -c $arg && rc=0 || rc=3
30
	fi;;
24
	fi
25
fi
31
26
32
    *)  rc=0;;
33
esac
34
35
exit $rc
27
exit $rc
(-)etc/periodic/daily/140.clean-rwho (-27 / +15 lines)
Lines 5-53 Link Here
5
# Remove stale files in /var/rwho
5
# Remove stale files in /var/rwho
6
#
6
#
7
7
8
# If there is a global system configuration file, suck it in.
8
. /etc/periodic.subr
9
#
10
if [ -r /etc/defaults/periodic.conf ]
11
then
12
    . /etc/defaults/periodic.conf
13
    source_periodic_confs
14
fi
15
9
16
case "$daily_clean_rwho_enable" in
10
rc=0
17
    [Yy][Ee][Ss])
11
12
if checkyesno daily_clean_rwho_enable; then
18
	if [ -z "$daily_clean_rwho_days" ]
13
	if [ -z "$daily_clean_rwho_days" ]
19
	then
14
	then
20
	    echo '$daily_clean_rwho_enable is enabled but' \
15
	    err 2 '$daily_clean_rwho_enable is enabled but' \
21
		'$daily_clean_rwho_days is not set'
16
		'$daily_clean_rwho_days is not set'
22
	    rc=2
23
	elif [ ! -d /var/rwho ]
17
	elif [ ! -d /var/rwho ]
24
	then
18
	then
25
	    echo '$daily_clean_rwho_enable is enabled but /var/rwho' \
19
	    err 2 '$daily_clean_rwho_enable is enabled but /var/rwho' \
26
		"doesn't exist"
20
		"doesn't exist"
27
	    rc=2
28
	else
21
	else
29
	    echo ""
22
	    if checkyesno daily_clean_rwho_verbose; then
30
	    echo "Removing stale files from /var/rwho:"
23
		echo ""
24
		echo "Removing stale files from /var/rwho:"
31
25
32
	    case "$daily_clean_rwho_verbose" in
26
		print=-print
33
		[Yy][Ee][Ss])
27
	    else
34
		    print=-print;;
28
		print=
35
		*)
29
	    fi
36
		    print=;;
37
	    esac
38
39
	    if cd /var/rwho
30
	    if cd /var/rwho
40
	    then
31
	    then
41
		rc=$(find . ! -name . -mtime +$daily_clean_rwho_days \
32
		rc=$(find . ! -name . -mtime +$daily_clean_rwho_days \
42
		    -delete $print | tee /dev/stderr | wc -l)
33
		    -delete $print | tee /dev/stderr | wc -l)
43
		[ -z "$print" ] && rc=0
44
		[ $rc -gt 1 ] && rc=1
34
		[ $rc -gt 1 ] && rc=1
45
	    else
35
	    else
46
		rc=3
36
		rc=3
47
	    fi
37
	    fi
48
	fi;;
38
	fi
39
fi
49
40
50
    *)  rc=0;;
51
esac
52
53
exit $rc
41
exit $rc
(-)etc/periodic/daily/150.clean-hoststat (-13 / +6 lines)
Lines 5-29 Link Here
5
# Remove stale persistent host status files
5
# Remove stale persistent host status files
6
#
6
#
7
7
8
# If there is a global system configuration file, suck it in.
8
. /etc/periodic.subr
9
#
10
if [ -r /etc/defaults/periodic.conf ]; then
11
    . /etc/defaults/periodic.conf
12
    source_periodic_confs
13
fi
14
9
15
case "$daily_clean_hoststat_enable" in
10
rc=0
16
    [Yy][Ee][Ss])
11
12
if checkyesno daily_clean_hoststat_enable; then
17
	if [ -z "$(hoststat 2>&1)" ]; then
13
	if [ -z "$(hoststat 2>&1)" ]; then
18
	    rc=2
14
	    rc=2
19
	else
15
	else
20
	    echo ""
16
	    echo ""
21
	    echo "Removing stale entries from sendmail host status cache:"
17
	    echo "Removing stale entries from sendmail host status cache:"
22
	    rc=0
23
	    purgestat || rc=1
18
	    purgestat || rc=1
24
	fi;;
19
	fi
20
fi
25
21
26
    *)  rc=0;;
27
esac
28
29
exit $rc
22
exit $rc
(-)etc/periodic/daily/200.backup-passwd (-14 / +6 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_backup_passwd_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_backup_passwd_enable; then
16
	if [ ! -f /etc/master.passwd ]
11
	if [ ! -f /etc/master.passwd ]
17
	then
12
	then
18
	    echo '$daily_backup_passwd_enable" is set but /etc/master.passwd' \
13
	    echo '$daily_backup_passwd_enable" is set but /etc/master.passwd' \
Lines 25-31 Link Here
25
	    rc=2
20
	    rc=2
26
	else
21
	else
27
	    bak=/var/backups
22
	    bak=/var/backups
28
	    rc=0
29
23
30
	    echo ""
24
	    echo ""
31
	    echo "Backup passwd and group files:"
25
	    echo "Backup passwd and group files:"
Lines 69-77 Link Here
69
		echo "Verifying group file syntax:"
63
		echo "Verifying group file syntax:"
70
	        chkgrp /etc/group || rc=3
64
	        chkgrp /etc/group || rc=3
71
	    fi
65
	    fi
72
	fi;;
66
	fi
67
fi
73
68
74
    *)  rc=0;;
75
esac
76
77
exit $rc
69
exit $rc
(-)etc/periodic/daily/210.backup-aliases (-16 / +7 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_backup_aliases_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_backup_aliases_enable; then
16
	if [ ! -f /etc/mail/aliases ]
11
	if [ ! -f /etc/mail/aliases ]
17
	then
12
	then
18
	    echo '$daily_backup_aliases_enable is enabled but' \
13
	    echo '$daily_backup_aliases_enable is enabled but' \
Lines 20-26 Link Here
20
	    rc=2
15
	    rc=2
21
	else
16
	else
22
	    bak=/var/backups
17
	    bak=/var/backups
23
	    rc=0
24
18
25
	    echo ""
19
	    echo ""
26
	    echo "Backing up mail aliases:"
20
	    echo "Backing up mail aliases:"
Lines 31-47 Link Here
31
		cp -p /etc/mail/aliases $bak/aliases.bak || rc=3
25
		cp -p /etc/mail/aliases $bak/aliases.bak || rc=3
32
	    fi
26
	    fi
33
27
34
	    if ! cmp -s $bak/aliases.bak /etc/mail/aliases
28
	    if [ $rc -eq 0 ] && ! cmp -s $bak/aliases.bak /etc/mail/aliases
35
	    then
29
	    then
36
		[ $rc -lt 1 ] && rc=1
37
		echo "$host aliases diffs:"
30
		echo "$host aliases diffs:"
38
		diff -u $bak/aliases.bak /etc/mail/aliases
31
		diff -u $bak/aliases.bak /etc/mail/aliases
39
		mv $bak/aliases.bak $bak/aliases.bak2
32
		mv $bak/aliases.bak $bak/aliases.bak2
40
		cp -p /etc/mail/aliases $bak/aliases.bak || rc=3
33
		cp -p /etc/mail/aliases $bak/aliases.bak || rc=3
41
	    fi
34
	    fi
42
	fi;;
35
	fi
36
fi
43
37
44
    *)  rc=0;;
45
esac
46
47
exit $rc
38
exit $rc
(-)etc/periodic/daily/220.backup-pkgdb (-15 / +8 lines)
Lines 3-20 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
rc=0
8
rc=0
15
9
16
case "$daily_backup_pkgdb_enable" in
10
if checkyesno daily_backup_pkgdb_enable; then
17
    [Yy][Ee][Ss])
18
	bak="${daily_backup_pkgdb_dir:-/var/backups}"
11
	bak="${daily_backup_pkgdb_dir:-/var/backups}"
19
	bak_file="${bak}/pkgdb.bak.tbz"
12
	bak_file="${bak}/pkgdb.bak.tbz"
20
13
Lines 23-32 Link Here
23
16
24
	if [ ! -d "$bak" ]
17
	if [ ! -d "$bak" ]
25
	then
18
	then
26
	    install -d -o root -g wheel -m 750 $bak || {
19
	    if ! install -d -o root -g wheel -m 750 $bak; then
27
		echo '$daily_backup_pkgdb_enable is enabled but' \
20
		err 2 '$daily_backup_pkgdb_enable is enabled but' \
28
		    "$daily_backup_pkgdb_dir doesn't exist" ;
21
		    "$daily_backup_pkgdb_dbdir doesn't exist" ;
29
		exit 2 ; }
22
	    fi
30
	fi
23
	fi
31
24
32
	echo ''
25
	echo ''
Lines 45-51 Link Here
45
	    mv "${new_bak_file}" "${bak_file}"
38
	    mv "${new_bak_file}" "${bak_file}"
46
	else
39
	else
47
	    rc=3
40
	    rc=3
48
	fi ;;
41
	fi
49
esac
42
fi
50
43
51
exit $rc
44
exit $rc
(-)etc/periodic/daily/300.calendar (-13 / +6 lines)
Lines 8-29 Link Here
8
# or run it from your ~/.profile or ~/.login.
8
# or run it from your ~/.profile or ~/.login.
9
#
9
#
10
10
11
# If there is a global system configuration file, suck it in.
11
. /etc/periodic.subr
12
#
13
if [ -r /etc/defaults/periodic.conf ]
14
then
15
    . /etc/defaults/periodic.conf
16
    source_periodic_confs
17
fi
18
12
19
case "$daily_calendar_enable" in
13
rc=0
20
    [Yy][Ee][Ss])
14
15
if checkyesno daily_calendar_enable; then
21
	echo ""
16
	echo ""
22
	echo "Running calendar:"
17
	echo "Running calendar:"
23
18
24
	calendar -a && rc=0 || rc=3;;
19
	calendar -a && rc=0 || rc=3
20
fi
25
21
26
    *)  rc=0;;
27
esac
28
29
exit $rc
22
exit $rc
(-)etc/periodic/daily/310.accounting (-18 / +9 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_accounting_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_accounting_enable; then
16
	if [ ! -f /var/account/acct ]
11
	if [ ! -f /var/account/acct ]
17
	then
12
	then
18
	    echo '$daily_accounting_enable is set but /var/account/acct' \
13
	    echo '$daily_accounting_enable is set but /var/account/acct' \
Lines 28-34 Link Here
28
	    echo "Rotating accounting logs and gathering statistics:"
23
	    echo "Rotating accounting logs and gathering statistics:"
29
24
30
	    cd /var/account
25
	    cd /var/account
31
	    rc=0
32
26
33
	    n=$(( $daily_accounting_save - 1 ))
27
	    n=$(( $daily_accounting_save - 1 ))
34
	    for f in acct.*; do
28
	    for f in acct.*; do
Lines 53-65 Link Here
53
	    sa -s $daily_accounting_flags /var/account/acct.merge || rc=3
47
	    sa -s $daily_accounting_flags /var/account/acct.merge || rc=3
54
	    rm acct.merge
48
	    rm acct.merge
55
49
56
	    case "$daily_accounting_compress" in
50
	    if checkyesno daily_accounting_compress; then
57
		[Yy][Ee][Ss])
51
		gzip -f acct.0 || rc=3
58
		    gzip -f acct.0 || rc=3;;
52
	    fi
59
	    esac
53
	fi
60
	fi;;
54
fi
61
55
62
    *)  rc=0;;
63
esac
64
65
exit $rc
56
exit $rc
(-)etc/periodic/daily/330.news (-15 / +7 lines)
Lines 6-34 Link Here
6
# (This is present only for backwards compatibility, usually the news
6
# (This is present only for backwards compatibility, usually the news
7
# system handles this on its own).
7
# system handles this on its own).
8
8
9
# If there is a global system configuration file, suck it in.
9
. /etc/periodic.subr
10
#
11
if [ -r /etc/defaults/periodic.conf ]
12
then
13
    . /etc/defaults/periodic.conf
14
    source_periodic_confs
15
fi
16
10
17
case "$daily_news_expire_enable" in
11
rc=0
18
    [Yy][Ee][Ss])
12
13
if checkyesno daily_news_expire_enable; then
19
	if [ ! -f /etc/news.expire ]
14
	if [ ! -f /etc/news.expire ]
20
	then
15
	then
21
	    echo '$daily_news_expire_enable is set but /etc/news.expire' \
16
	    err 2 '$daily_news_expire_enable is set but /etc/news.expire' \
22
		"doesn't exist"
17
		"doesn't exist"
23
	    rc=2
24
	else
18
	else
25
	    echo ""
19
	    echo ""
26
	    echo "Running news.expire:"
20
	    echo "Running news.expire:"
27
21
28
	    /etc/news.expire && rc=0 || rc=3
22
	    /etc/news.expire && rc=0 || rc=3
29
	fi;;
23
	fi
24
fi
30
25
31
    *)  rc=0;;
32
esac
33
34
exit $rc
26
exit $rc
(-)etc/periodic/daily/400.status-disks (-12 / +8 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_status_disks_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_status_disks_enable; then
16
	echo ""
11
	echo ""
17
	echo "Disk status:"
12
	echo "Disk status:"
18
13
Lines 27-35 Link Here
27
		echo ""
22
		echo ""
28
		dump W || rc=3
23
		dump W || rc=3
29
	fi
24
	fi
25
26
	echo ""
27
	dump W || rc=3
30
	;;
28
	;;
29
fi
31
30
32
    *)  rc=0;;
33
esac
34
35
exit $rc
31
exit $rc
(-)etc/periodic/daily/404.status-zfs (-15 / +5 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_status_zfs_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_status_zfs_enable; then
16
	echo
11
	echo
17
	echo 'Checking status of zfs pools:'
12
	echo 'Checking status of zfs pools:'
18
13
Lines 35-45 Link Here
35
	else
30
	else
36
		rc=1
31
		rc=1
37
	fi
32
	fi
38
	;;
33
fi
39
34
40
    *)
41
	rc=0
42
	;;
43
esac
44
45
exit $rc
35
exit $rc
(-)etc/periodic/daily/405.status-ata-raid (-33 lines)
Lines 1-33 Link Here
1
#!/bin/sh
2
#
3
# $FreeBSD$
4
#
5
6
# If there is a global system configuration file, suck it in.
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
14
case "$daily_status_ata_raid_enable" in
15
    [Yy][Ee][Ss])
16
	echo
17
	echo 'Checking status of ATA raid partitions:'
18
19
	rc=0
20
	for raid in `find /dev/ -name 'ar[0-9]*' -type c | egrep '[0-9]$' \
21
		| egrep -v 's[0-9]' | cut -d / -f 3`
22
	     do
23
		status=`/sbin/atacontrol status $raid`
24
		echo $status
25
		raid_rc=`echo $status | grep -v READY | wc -l`
26
		[ $rc -eq 0 ] && [ $raid_rc -gt 0 ] && rc=3
27
	     done
28
	;;
29
30
    *)  rc=0;;
31
esac
32
33
exit $rc
(-)etc/periodic/daily/406.status-gmirror (-15 / +5 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_status_gmirror_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_status_gmirror_enable; then
16
	echo
11
	echo
17
	echo 'Checking status of gmirror(8) devices:'
12
	echo 'Checking status of gmirror(8) devices:'
18
13
Lines 20-34 Link Here
20
		components="$(gmirror status -s | fgrep -v COMPLETE)"
15
		components="$(gmirror status -s | fgrep -v COMPLETE)"
21
		if [ "${components}" ]; then
16
		if [ "${components}" ]; then
22
			rc=3
17
			rc=3
23
		else
24
			rc=0
25
		fi
18
		fi
26
	else
19
	else
27
		rc=2
20
		rc=2
28
	fi
21
	fi
29
	;;
22
fi
30
23
31
    *)  rc=0;;
32
esac
33
34
exit $rc
24
exit $rc
(-)etc/periodic/daily/407.status-graid3 (-15 / +5 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_status_graid3_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_status_graid3_enable; then
16
	echo
11
	echo
17
	echo 'Checking status of graid3(8) devices:'
12
	echo 'Checking status of graid3(8) devices:'
18
13
Lines 20-34 Link Here
20
		components="$(graid3 status -s | fgrep -v COMPLETE)"
15
		components="$(graid3 status -s | fgrep -v COMPLETE)"
21
		if [ "${components}" ]; then
16
		if [ "${components}" ]; then
22
			rc=3
17
			rc=3
23
		else
24
			rc=0
25
		fi
18
		fi
26
	else
19
	else
27
		rc=2
20
		rc=2
28
	fi
21
	fi
29
	;;
22
fi
30
23
31
    *)  rc=0;;
32
esac
33
34
exit $rc
24
exit $rc
(-)etc/periodic/daily/408.status-gstripe (-15 / +5 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_status_gstripe_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_status_gstripe_enable; then
16
	echo
11
	echo
17
	echo 'Checking status of gstripe(8) devices:'
12
	echo 'Checking status of gstripe(8) devices:'
18
13
Lines 20-34 Link Here
20
		components="$(gstripe status -s | fgrep -v UP)"
15
		components="$(gstripe status -s | fgrep -v UP)"
21
		if [ "${components}" ]; then
16
		if [ "${components}" ]; then
22
			rc=3
17
			rc=3
23
		else
24
			rc=0
25
		fi
18
		fi
26
	else
19
	else
27
		rc=2
20
		rc=2
28
	fi
21
	fi
29
	;;
22
fi
30
23
31
    *)  rc=0;;
32
esac
33
34
exit $rc
24
exit $rc
(-)etc/periodic/daily/409.status-gconcat (-15 / +5 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_status_gconcat_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_status_gconcat_enable; then
16
	echo
11
	echo
17
	echo 'Checking status of gconcat(8) devices:'
12
	echo 'Checking status of gconcat(8) devices:'
18
13
Lines 20-34 Link Here
20
		components="$(gconcat status -s | fgrep -v UP)"
15
		components="$(gconcat status -s | fgrep -v UP)"
21
		if [ "${components}" ]; then
16
		if [ "${components}" ]; then
22
			rc=3
17
			rc=3
23
		else
24
			rc=0
25
		fi
18
		fi
26
	else
19
	else
27
		rc=2
20
		rc=2
28
	fi
21
	fi
29
	;;
22
fi
30
23
31
    *)  rc=0;;
32
esac
33
34
exit $rc
24
exit $rc
(-)etc/periodic/daily/420.status-network (-18 / +11 lines)
Lines 3-29 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_status_network_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_status_network_enable; then
16
	echo ""
11
	echo ""
17
	echo "Network interface status:"
12
	echo "Network interface status:"
18
13
19
	case "$daily_status_network_usedns" in
14
	if checkyesno daily_status_network_usedns; then
20
	    [Yy][Ee][Ss])
15
		netstat_flags="-i"
21
		netstat -id && rc=0 || rc=3;;
16
	else
22
	    *)
17
		netstat_flags="-in"
23
		netstat -idn && rc=0 || rc=3;;
18
	fi
24
	esac;;
19
	netstat $netstat_flags || rc=3
20
fi
25
21
26
    *)  rc=0;;
27
esac
28
29
exit $rc
22
exit $rc
(-)etc/periodic/daily/430.status-rwho (-15 / +8 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_status_rwho_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_status_rwho_enable; then
16
	rwho=$(echo /var/rwho/*)
11
	rwho=$(echo /var/rwho/*)
17
        if [ -f "${rwho%% *}" ]
12
        if [ -f "${rwho%% *}" ]
18
        then
13
        then
Lines 24-38 Link Here
24
	    echo "Local system status:"
19
	    echo "Local system status:"
25
	    prog=uptime
20
	    prog=uptime
26
	fi
21
	fi
27
	rc=$($prog | tee /dev/stderr | wc -l)
22
	n=$($prog | tee /dev/stderr | wc -l)
28
	if [ $? -eq 0 ]
23
	if [ $? -eq 0 ]
29
	then
24
	then
30
	    [ $rc -gt 1 ] && rc=1
25
	    [ $n -gt 1 ] && rc=1
31
	else
26
	else
32
	    rc=3
27
	    rc=3
33
	fi;;
28
	fi
29
fi
34
30
35
    *)  rc=0;;
36
esac
37
38
exit $rc
31
exit $rc
(-)etc/periodic/daily/440.status-mailq (-33 / +22 lines)
Lines 3-66 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_status_mailq_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_status_mailq_enable; then
16
	if [ ! -x /usr/bin/mailq ]
11
	if [ ! -x /usr/bin/mailq ]
17
	then
12
	then
18
	    echo '$daily_status_mailq_enable is set but /usr/bin/mailq' \
13
	    err 2 '$daily_status_mailq_enable is set but /usr/bin/mailq' \
19
		"isn't executable"
14
		"isn't executable"
20
	    rc=2
21
	else
15
	else
22
	    echo ""
16
	    echo ""
23
	    echo "Mail in local queue:"
17
	    echo "Mail in local queue:"
24
18
25
	    rc=$(case "$daily_status_mailq_shorten" in
19
	    n=$(if checkyesno daily_status_mailq_shorten; then
26
		[Yy][Ee][Ss])
27
		    mailq |
20
		    mailq |
28
			egrep -e '^[[:space:]]+[^[:space:]]+@' |
21
			egrep -e '^[[:space:]]+[^[:space:]]+@' |
29
			sort |
22
			sort |
30
			uniq -c |
23
			uniq -c |
31
			sort -nr |
24
			sort -nr |
32
			awk '$1 >= 1 {print $1, $2}';;
25
			awk '$1 >= 1 {print $1, $2}'
33
		*)
26
		else
34
		    mailq;;
27
		    mailq
35
	    esac | tee /dev/stderr |
28
	        fi | tee /dev/stderr |
36
	    egrep -v '(mqueue is empty|Total requests)' | wc -l)
29
	    egrep -v '(mqueue is empty|Total requests)' | wc -l)
37
	    [ $rc -gt 0 ] && rc=1 || rc=0
30
	    [ $n -gt 0 ] && rc=1
38
31
39
	    case "$daily_status_include_submit_mailq" in
32
	    if checkyesno daily_status_include_submit_mailq; then
40
	    [Yy][Ee][Ss])
41
		if [ -f /etc/mail/submit.cf ]
33
		if [ -f /etc/mail/submit.cf ]
42
		then
34
		then
43
		    echo ""
35
		    echo ""
44
		    echo "Mail in submit queue:"
36
		    echo "Mail in submit queue:"
45
37
46
		    rc_submit=$(case "$daily_status_mailq_shorten" in
38
		    n=$(if checkyesno daily_status_mailq_shorten; then
47
			[Yy][Ee][Ss])
48
			    mailq -Ac |
39
			    mailq -Ac |
49
				egrep -e '^[[:space:]]+[^[:space:]]+@' |
40
				egrep -e '^[[:space:]]+[^[:space:]]+@' |
50
				sort |
41
				sort |
51
				uniq -c |
42
				uniq -c |
52
				sort -nr |
43
				sort -nr |
53
				awk '$1 >= 1 {print $1, $2}';;
44
				awk '$1 >= 1 {print $1, $2}'
54
			*)
45
			else
55
			    mailq -Ac;;
46
			    mailq -Ac
56
		    esac | tee /dev/stderr |
47
		        fi | tee /dev/stderr |
57
		    egrep -v '(mqueue is empty|Total requests)' | wc -l)
48
		    egrep -v '(mqueue is empty|Total requests)' | wc -l)
58
		    [ $rc_submit -gt 0 ] && rc=1
49
		    [ $n -gt 0 ] && rc=1
59
		fi;;
50
		fi
60
	    esac
51
	    fi
61
	fi;;
52
	fi
53
fi
62
54
63
    *)  rc=0;;
64
esac
65
66
exit $rc
55
exit $rc
(-)etc/periodic/daily/450.status-security (-20 / +12 lines)
Lines 3-41 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_status_security_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_status_security_enable; then
16
	echo ""
11
	echo ""
17
	echo "Security check:"
12
	echo "Security check:"
18
13
19
	case "$daily_status_security_inline" in
14
	if checkyesno daily_status_security_inline; then
20
	    [Yy][Ee][Ss])
21
		export security_output="";;
15
		export security_output="";;
22
	    *)
16
	else
23
		export security_output="${daily_status_security_output}"
17
		export security_output="${daily_status_security_output}"
24
		case "${daily_status_security_output}" in
18
		case "${daily_status_security_output}" in
25
		    "")
19
		    "")
26
			rc=3;;
20
			rc=3;;
27
		    /*)
21
		    /*)
28
			echo "    (output logged separately)"
22
			echo "    (output logged separately)"
29
			rc=0;;
23
			;;
30
		    *)
24
		    *)
31
			echo "    (output mailed separately)"
25
			echo "    (output mailed separately)"
32
			rc=0;;
26
			;;
33
		esac;;
27
		esac
34
	esac
28
	fi
35
29
36
	periodic security || rc=3;;
30
	periodic security || rc=3
31
fi
37
32
38
    *)  rc=0;;
39
esac
40
41
exit $rc
33
exit $rc
(-)etc/periodic/daily/460.status-mail-rejects (-23 / +14 lines)
Lines 3-38 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
7
8
if [ -r /etc/defaults/periodic.conf ]
8
rc=0
9
then
9
10
    . /etc/defaults/periodic.conf
10
if checkyesno daily_status_mail_rejects_shorten; then
11
    source_periodic_confs
11
	shorten='cut -d" " -f2,3'
12
else
13
	shorten=cat
12
fi
14
fi
13
15
14
case "$daily_status_mail_rejects_shorten" in
16
if checkyesno daily_status_mail_rejects_enable; then
15
[Yy][Ee][Ss])	shorten='cut -d" " -f2,3';;
16
*)		shorten=cat;;
17
esac
18
19
case "$daily_status_mail_rejects_enable" in
20
    [Yy][Ee][Ss])
21
	if [ ! -d /etc/mail ]
17
	if [ ! -d /etc/mail ]
22
	then
18
	then
23
	    echo '$daily_status_mail_rejects_enable is set but /etc/mail' \
19
	    err 2 '$daily_status_mail_rejects_enable is set but /etc/mail' \
24
		"doesn't exist"
20
		"doesn't exist"
25
	    rc=2
26
	elif [ ! -f /var/log/maillog ]
21
	elif [ ! -f /var/log/maillog ]
27
	then
22
	then
28
	    echo '$daily_status_mail_rejects_enable is set but ' \
23
	    err 2 '$daily_status_mail_rejects_enable is set but ' \
29
		"/var/log/maillog doesn't exist"
24
		"/var/log/maillog doesn't exist"
30
	    rc=2
31
	elif [ "$daily_status_mail_rejects_logs" -le 0 ]
25
	elif [ "$daily_status_mail_rejects_logs" -le 0 ]
32
	then
26
	then
33
	    echo '$daily_status_mail_rejects_enable is set but ' \
27
	    err 2 '$daily_status_mail_rejects_enable is set but ' \
34
		'$daily_status_mail_rejects_logs is not greater than zero'
28
		'$daily_status_mail_rejects_logs is not greater than zero'
35
	    rc=2
36
	else
29
	else
37
	    echo
30
	    echo
38
	    echo Checking for rejected mail hosts:
31
	    echo Checking for rejected mail hosts:
Lines 65-73 Link Here
65
		    :end
58
		    :end
66
		}' | eval $shorten | sort -f | uniq -ic | sort -fnr | tee /dev/stderr | wc -l)
59
		}' | eval $shorten | sort -f | uniq -ic | sort -fnr | tee /dev/stderr | wc -l)
67
	    [ $rc -gt 0 ] && rc=1
60
	    [ $rc -gt 0 ] && rc=1
68
	fi;;
61
	fi
62
fi
69
63
70
    *)  rc=0;;
71
esac
72
73
exit $rc
64
exit $rc
(-)etc/periodic/daily/470.status-named (-32 / +10 lines)
Lines 3-45 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
catmsgs() {
8
rc=0
15
	find /var/log -name 'messages.*' -mtime -2 |
16
	    sort -t. -r -n -k 2,2 |
17
	    while read f
18
	    do
19
		case $f in
20
		    *.gz)	zcat -f $f;;
21
		    *.bz2)	bzcat -f $f;;
22
		esac
23
	    done
24
	[ -f /var/log/messages ] && cat /var/log/messages
25
}
26
9
27
case "$daily_status_named_enable" in
10
if checkyesno daily_status_named_enable; then
28
    [Yy][Ee][Ss])
29
	echo
11
	echo
30
	echo 'Checking for denied zone transfers (AXFR and IXFR):'
12
	echo 'Checking for denied zone transfers (AXFR and IXFR):'
31
13
32
	start=`date -v-1d '+%b %e'`
14
	start=`date -v-1d '+%b %e'`
33
	rc=$(catmsgs |
15
	rc=$(catlogs /var/log "messages" |
34
	    fgrep -E "^$start.*named\[[[:digit:]]+\]: transfer of .*failed .*: REFUSED" |
16
	    fgrep -E "^$start.*named\[[[:digit:]]+\]: transfer of .*failed .*: REFUSED" |
35
	    sed -e "s/.*transfer of \'\(.*\)\/IN\' from \(.*\)#[0-9]*: .*/\1 from \2/" |
17
	    sed -e "s/.*transfer of \'\(.*\)\/IN\' from \(.*\)#[0-9]*: .*/\1 from \2/" |
36
	    sort -f | uniq -ic | (
18
	    sort -f | uniq -ic | (
37
		usedns=0
19
		if checkyesno daily_status_named_usedns; then
38
		case "$daily_status_named_usedns" in
20
			usedns=1
39
		'') ;;
21
		else
40
		[yY][eE][sS]) usedns=1 ;;
22
			usedns=0
41
		esac
23
		fi
42
43
		while read line ;do
24
		while read line ;do
44
			ipaddr=`echo "$line" | sed -e 's/^.*from //'`
25
			ipaddr=`echo "$line" | sed -e 's/^.*from //'`
45
			if [ $usedns -eq 1 ]; then
26
			if [ $usedns -eq 1 ]; then
Lines 54-62 Link Here
54
		done ) | \
35
		done ) | \
55
		tee /dev/stderr | wc -l)
36
		tee /dev/stderr | wc -l)
56
	[ $rc -gt 0 ] && rc=1
37
	[ $rc -gt 0 ] && rc=1
57
	;;
38
fi
58
39
59
    *)  rc=0;;
60
esac
61
62
exit $rc
40
exit $rc
(-)etc/periodic/daily/480.status-ntpd (-11 / +3 lines)
Lines 3-20 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
rc=0
8
rc=0
15
9
16
case "$daily_status_ntpd_enable" in
10
if checkyesno daily_status_ntpd_enable; then
17
    [Yy][Ee][Ss])
18
	echo ""
11
	echo ""
19
	echo "NTP status:"
12
	echo "NTP status:"
20
13
Lines 22-28 Link Here
22
	if [ -z "$synchronized" ]; then
15
	if [ -z "$synchronized" ]; then
23
		rc=1
16
		rc=1
24
	fi
17
	fi
25
	;;
18
fi
26
esac
27
19
28
exit $rc
20
exit $rc
(-)etc/periodic/daily/490.status-pkg-changes (-17 / +6 lines)
Lines 3-24 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]; then
9
    . /etc/defaults/periodic.conf
10
    source_periodic_confs
11
fi
12
7
13
case "$daily_status_pkg_changes_enable" in
8
rc=0
14
    [Yy][Ee][Ss])
9
10
if checkyesno daily_status_pkg_changes_enable; then
15
	if [ ! -f /usr/sbin/pkg_info ]; then
11
	if [ ! -f /usr/sbin/pkg_info ]; then
16
	    echo '$daily_status_pkg_changes_enable is enabled but' \
12
	    err 2 '$daily_status_pkg_changes_enable is enabled but' \
17
		 "/usr/sbin/pkg_info doesn't exist"
13
		 "/usr/sbin/pkg_info doesn't exist"
18
	    rc=2
19
	else
14
	else
20
	    bak=/var/backups
15
	    bak=/var/backups
21
	    rc=0
22
16
23
	    if [ -f $bak/pkg_info.bak ]; then
17
	    if [ -f $bak/pkg_info.bak ]; then
24
	    	mv -f $bak/pkg_info.bak $bak/pkg_info.bak2
18
	    	mv -f $bak/pkg_info.bak $bak/pkg_info.bak2
Lines 33-43 Link Here
33
		| grep '^[-+][^-+]' | sort -k 1.2
27
		| grep '^[-+][^-+]' | sort -k 1.2
34
	    fi
28
	    fi
35
	fi
29
	fi
36
	;;
30
fi
37
31
38
    *)
39
	rc=0
40
	;;
41
esac
42
43
exit $rc
32
exit $rc
(-)etc/periodic/daily/500.queuerun (-25 / +13 lines)
Lines 3-36 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$daily_queuerun_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno daily_queuerun_enable; then
16
	if [ ! -x /usr/sbin/sendmail ]
11
	if [ ! -x /usr/sbin/sendmail ]
17
	then
12
	then
18
	    echo '$daily_queuerun_enable is set but /usr/sbin/sendmail' \
13
	    err 2 '$daily_queuerun_enable is set but /usr/sbin/sendmail' \
19
		"isn't executable"
14
		"isn't executable"
20
	    rc=2
15
	fi
21
	else
16
	/usr/sbin/sendmail -q >/dev/null 2>&1 &
22
	    /usr/sbin/sendmail -q >/dev/null 2>&1 &
17
	if checkyesno daily_submit_queuerun; then
23
	    case "$daily_submit_queuerun" in
18
	    if [ -f /etc/mail/submit.cf ]; then
24
	    [Yy][Ee][Ss])
19
		/usr/sbin/sendmail -q -Ac >/dev/null 2>&1 &
25
		if [ -f /etc/mail/submit.cf ]
20
	    fi
26
		then
21
	fi
27
		    /usr/sbin/sendmail -q -Ac >/dev/null 2>&1 &
22
fi
28
		fi;;
29
	    esac
30
	    rc=0
31
	fi;;
32
23
33
    *)  rc=0;;
34
esac
35
36
exit $rc
24
exit $rc
(-)etc/periodic/daily/800.scrub-zfs (-20 / +5 lines)
Lines 3-24 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
7
9
newline="
8
newline=$(echo -ne "\n")
10
" # A single newline
11
9
12
if [ -r /etc/defaults/periodic.conf ]
10
rc=0
13
then
14
    . /etc/defaults/periodic.conf
15
    source_periodic_confs
16
fi
17
11
18
: ${daily_scrub_zfs_default_threshold=35}
12
if checkyesno daily_scrub_zfs_enable; then
19
20
case "$daily_scrub_zfs_enable" in
21
    [Yy][Ee][Ss])
22
	echo
13
	echo
23
	echo 'Scrubbing of zfs pools:'
14
	echo 'Scrubbing of zfs pools:'
24
15
Lines 26-32 Link Here
26
		daily_scrub_zfs_pools="$(zpool list -H -o name)"
17
		daily_scrub_zfs_pools="$(zpool list -H -o name)"
27
	fi
18
	fi
28
19
29
	rc=0
30
	for pool in ${daily_scrub_zfs_pools}; do
20
	for pool in ${daily_scrub_zfs_pools}; do
31
		# sanity check
21
		# sanity check
32
		_status=$(zpool list "${pool}" 2> /dev/null)
22
		_status=$(zpool list "${pool}" 2> /dev/null)
Lines 88-98 Link Here
88
78
89
		echo "      consult 'zpool status ${pool}' for the result"
79
		echo "      consult 'zpool status ${pool}' for the result"
90
	done
80
	done
91
	;;
81
fi
92
82
93
    *)
94
	rc=0
95
	;;
96
esac
97
98
exit $rc
83
exit $rc
(-)etc/periodic/daily/999.local (-7 / +1 lines)
Lines 6-18 Link Here
6
# compatibility more than anything else.
6
# compatibility more than anything else.
7
#
7
#
8
8
9
# If there is a global system configuration file, suck it in.
9
. /etc/periodic.subr
10
#
11
if [ -r /etc/defaults/periodic.conf ]
12
then
13
    . /etc/defaults/periodic.conf
14
    source_periodic_confs
15
fi
16
10
17
rc=0
11
rc=0
18
for script in $daily_local
12
for script in $daily_local
(-)etc/periodic/daily/Makefile (-1 lines)
Lines 9-15 Link Here
9
	220.backup-pkgdb \
9
	220.backup-pkgdb \
10
	330.news \
10
	330.news \
11
	400.status-disks \
11
	400.status-disks \
12
	405.status-ata-raid \
13
	406.status-gmirror \
12
	406.status-gmirror \
14
	407.status-graid3 \
13
	407.status-graid3 \
15
	408.status-gstripe \
14
	408.status-gstripe \
(-)etc/periodic/monthly/200.accounting (-21 / +11 lines)
Lines 3-22 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
oldmask=$(umask)
8
rc=0
9
15
umask 066
10
umask 066
16
case "$monthly_accounting_enable" in
11
if checkyesno monthly_accounting_enable; then
17
    [Yy][Ee][Ss])
18
	W=/var/log/utx.log
12
	W=/var/log/utx.log
19
	rc=0
20
	remove=NO
13
	remove=NO
21
	if [ ! -f $W.0 ]
14
	if [ ! -f $W.0 ]
22
	then
15
	then
Lines 29-51 Link Here
29
		remove=YES
22
		remove=YES
30
		bzcat $W.0.bz2 > $W.0 || rc=1
23
		bzcat $W.0.bz2 > $W.0 || rc=1
31
	    else
24
	    else
32
		echo '$monthly_accounting_enable is set but' \
25
		err 2 '$monthly_accounting_enable is set but' \
33
		    "$W.0 doesn't exist"
26
		    "$W.0 doesn't exist"
34
		rc=2
35
	    fi
27
	    fi
36
	fi
28
	fi
37
	if [ $rc -eq 0 ]
29
	if [ $rc -eq 0 ]
38
	then
30
	then
39
	    echo ""
31
	    if checkyesno monthly_accounting_verbose; then
40
	    echo "Doing login accounting:"
32
		echo ""
41
33
		echo "Doing login accounting:"
34
	    fi
42
	    rc=$(ac -p -w $W.0 | sort -nr -k 2 | tee /dev/stderr | wc -l)
35
	    rc=$(ac -p -w $W.0 | sort -nr -k 2 | tee /dev/stderr | wc -l)
43
	    [ $rc -gt 0 ] && rc=1
36
	    [ $rc -gt 0 ] && rc=1
44
	fi
37
	fi
45
	[ $remove = YES ] && rm -f $W.0;;
38
	[ $remove = YES ] && rm -f $W.0
39
fi
46
40
47
    *)  rc=0;;
48
esac
49
50
umask $oldmask
51
exit $rc
41
exit $rc
(-)etc/periodic/monthly/999.local (-7 / +2 lines)
Lines 3-17 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.conf
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
rc=0
8
rc=0
9
15
for script in $monthly_local
10
for script in $monthly_local
16
do
11
do
17
    echo ''
12
    echo ''
(-)etc/periodic/security/100.chksetuid (-15 / +3 lines)
Lines 27-46 Link Here
27
# $FreeBSD$
27
# $FreeBSD$
28
#
28
#
29
29
30
# If there is a global system configuration file, suck it in.
30
. /etc/periodic.subr
31
#
32
if [ -r /etc/defaults/periodic.conf ]
33
then
34
    . /etc/defaults/periodic.conf
35
    source_periodic_confs
36
fi
37
38
. /etc/periodic/security/security.functions
31
. /etc/periodic/security/security.functions
39
32
40
rc=0
33
rc=0
41
34
42
case "$daily_status_security_chksetuid_enable" in
35
if checkyesno daily_status_security_chksetuid_enable; then
43
    [Yy][Ee][Ss])
44
	echo ""
36
	echo ""
45
	echo 'Checking setuid files and devices:'
37
	echo 'Checking setuid files and devices:'
46
	MP=`mount -t ufs,zfs | awk '$0 !~ /no(suid|exec)/ { print $3 }'`
38
	MP=`mount -t ufs,zfs | awk '$0 !~ /no(suid|exec)/ { print $3 }'`
Lines 49-58 Link Here
49
	    \( -perm -u+s -or -perm -g+s \) -exec ls -liTd \{\} \+ |
41
	    \( -perm -u+s -or -perm -g+s \) -exec ls -liTd \{\} \+ |
50
	check_diff setuid - "${host} setuid diffs:"
42
	check_diff setuid - "${host} setuid diffs:"
51
	rc=$?
43
	rc=$?
52
	;;
44
fi
53
    *)
54
	rc=0
55
	;;
56
esac
57
45
58
exit $rc
46
exit $rc
(-)etc/periodic/security/110.neggrpperm (-12 / +4 lines)
Lines 27-44 Link Here
27
# $FreeBSD$
27
# $FreeBSD$
28
#
28
#
29
29
30
# If there is a global system configuration file, suck it in.
30
. /etc/periodic.subr
31
#
32
if [ -r /etc/defaults/periodic.conf ]
33
then
34
    . /etc/defaults/periodic.conf
35
    source_periodic_confs
36
fi
37
31
38
rc=0
32
rc=0
39
33
40
case "$daily_status_security_neggrpperm_enable" in
34
if checkyesno daily_status_security_neggrpperm_enable; then
41
    [Yy][Ee][Ss])
42
	echo ""
35
	echo ""
43
	echo 'Checking negative group permissions:'
36
	echo 'Checking negative group permissions:'
44
	MP=`mount -t ufs,zfs | awk '$0 !~ /no(suid|exec)/ { print $3 }'`
37
	MP=`mount -t ufs,zfs | awk '$0 !~ /no(suid|exec)/ { print $3 }'`
Lines 47-54 Link Here
47
	    \( ! -perm +020 -and -perm +002 \) -or \
40
	    \( ! -perm +020 -and -perm +002 \) -or \
48
	    \( ! -perm +040 -and -perm +004 \) \) \
41
	    \( ! -perm +040 -and -perm +004 \) \) \
49
	    -exec ls -liTd \{\} \+ | tee /dev/stderr | wc -l)
42
	    -exec ls -liTd \{\} \+ | tee /dev/stderr | wc -l)
50
	[ $n -gt 0 ] && rc=1 || rc=0
43
	[ $n -gt 0 ] && rc=1
51
	;;
44
fi
52
esac
53
45
54
exit $rc
46
exit $rc
(-)etc/periodic/security/200.chkmounts (-20 / +14 lines)
Lines 30-62 Link Here
30
# Show changes in the way filesystems are mounted
30
# Show changes in the way filesystems are mounted
31
#
31
#
32
32
33
# If there is a global system configuration file, suck it in.
33
. /etc/periodic.subr
34
#
35
if [ -r /etc/defaults/periodic.conf ]
36
then
37
    . /etc/defaults/periodic.conf
38
    source_periodic_confs
39
fi
40
41
. /etc/periodic/security/security.functions
34
. /etc/periodic/security/security.functions
42
35
43
ignore="${daily_status_security_chkmounts_ignore}"
36
ignore="${daily_status_security_chkmounts_ignore}"
37
44
rc=0
38
rc=0
45
39
46
case "$daily_status_security_chkmounts_enable" in
40
if checkyesno daily_status_security_chkmounts_enable; then
47
    [Yy][Ee][Ss])
41
	if checkyesno daily_status_security_noamd; then
48
	case "$daily_status_security_noamd" in
49
	    [Yy][Ee][Ss])
50
		ignore="${ignore}|^amd:"
42
		ignore="${ignore}|^amd:"
51
	esac
43
	fi
52
	[ -n "$ignore" ] && cmd="egrep -v ${ignore#|}" || cmd=cat
44
	if [ -n "$ignore" ]; then
53
	if ! [ -f /etc/fstab ]; then
45
		cmd="egrep -v ${ignore#|}"
46
	else
47
		cmd=cat
48
	fi
49
	if [ ! -f /etc/fstab ]; then
54
		export PATH_FSTAB=/dev/null
50
		export PATH_FSTAB=/dev/null
55
	fi
51
	fi
56
	mount -p | sort | ${cmd} |
52
	mount -p | sort | ${cmd} |
57
	  check_diff mount - "${host} changes in mounted filesystems:"
53
	  check_diff mount - "${host} changes in mounted filesystems:"
58
	rc=$?;;
54
	rc=$?
59
    *)	rc=0;;
55
fi
60
esac
56
exit $rc
61
62
exit "$rc"
(-)etc/periodic/security/300.chkuid0 (-13 / +6 lines)
Lines 27-51 Link Here
27
# $FreeBSD$
27
# $FreeBSD$
28
#
28
#
29
29
30
. /etc/periodic.subr
30
31
31
# If there is a global system configuration file, suck it in.
32
rc=0
32
#
33
if [ -r /etc/defaults/periodic.conf ]
34
then
35
    . /etc/defaults/periodic.conf
36
    source_periodic_confs
37
fi
38
33
39
case "$daily_status_security_chkuid0_enable" in
34
if checkyesno daily_status_security_chkuid0_enable; then
40
    [Yy][Ee][Ss])
41
	echo ""
35
	echo ""
42
	echo 'Checking for uids of 0:'
36
	echo 'Checking for uids of 0:'
43
	n=$(awk -F: '/^#/ {next} $3==0 {print $1,$3}' /etc/master.passwd |
37
	n=$(awk -F: '/^#/ {next} $3==0 {print $1,$3}' /etc/master.passwd |
44
	tee /dev/stderr |
38
	tee /dev/stderr |
45
	sed -e '/^root 0$/d' -e '/^toor 0$/d' |
39
	sed -e '/^root 0$/d' -e '/^toor 0$/d' |
46
	wc -l)
40
	wc -l)
47
	[ $n -gt 0 ] && rc=1 || rc=0;;
41
	[ $n -gt 0 ] && rc=1
48
    *)	rc=0;;
42
fi
49
esac
50
43
51
exit "$rc"
44
exit $rc
(-)etc/periodic/security/400.passwdless (-13 / +7 lines)
Lines 27-48 Link Here
27
# $FreeBSD$
27
# $FreeBSD$
28
#
28
#
29
29
30
# If there is a global system configuration file, suck it in.
30
. /etc/periodic.subr
31
#
32
if [ -r /etc/defaults/periodic.conf ]
33
then
34
    . /etc/defaults/periodic.conf
35
    source_periodic_confs
36
fi
37
31
38
case "$daily_status_security_passwdless_enable" in
32
rc=0
39
    [Yy][Ee][Ss])
33
34
if checkyesno daily_status_security_passwdless_enable; then
40
	echo ""
35
	echo ""
41
	echo 'Checking for passwordless accounts:'
36
	echo 'Checking for passwordless accounts:'
42
	n=$(awk -F: 'NF > 1 && $1 !~ /^[#+-]/ && $2=="" {print $0}' /etc/master.passwd |
37
	n=$(awk -F: 'NF > 1 && $1 !~ /^[#+-]/ && $2=="" {print $0}' /etc/master.passwd |
43
	    tee /dev/stderr | wc -l)
38
	    tee /dev/stderr | wc -l)
44
	[ $n -gt 0 ] && rc=1 || rc=0;;
39
	[ $n -gt 0 ] && rc=1
45
    *)	rc=0;;
40
fi
46
esac
47
41
48
exit "$rc"
42
exit $rc
(-)etc/periodic/security/410.logincheck (-18 / +8 lines)
Lines 27-52 Link Here
27
# $FreeBSD$
27
# $FreeBSD$
28
#
28
#
29
29
30
# If there is a global system configuration file, suck it in.
30
. /etc/periodic.subr
31
#
32
if [ -r /etc/defaults/periodic.conf ]
33
then
34
    . /etc/defaults/periodic.conf
35
    source_periodic_confs
36
fi
37
31
38
case "$daily_status_security_logincheck_enable" in
32
rc=0
39
    [Yy][Ee][Ss])
33
34
if checkyesno daily_status_security_logincheck_enable; then
40
	echo ""
35
	echo ""
41
	echo 'Checking login.conf permissions:'
36
	echo 'Checking login.conf permissions:'
42
	if [ -G /etc/login.conf -a -O /etc/login.conf ]; then
37
	if ! [ -G /etc/login.conf -a -O /etc/login.conf ]; then
43
	    n=0
38
		err 1 "Bad ownership of /etc/login.conf"
44
	else
45
	    echo "Bad ownership of /etc/login.conf"
46
	    n=1
47
	fi
39
	fi
48
	[ $n -gt 0 ] && rc=1 || rc=0;;
40
fi
49
    *)	rc=0;;
50
esac
51
41
52
exit "$rc"
42
exit $rc
(-)etc/periodic/security/460.chkportsum (-27 / +25 lines)
Lines 27-68 Link Here
27
# $FreeBSD$
27
# $FreeBSD$
28
#
28
#
29
29
30
if [ -r /etc/defaults/periodic.conf ]
30
. /etc/periodic.subr
31
then
32
    . /etc/defaults/periodic.conf
33
    source_periodic_confs
34
fi
35
36
. /etc/periodic/security/security.functions
31
. /etc/periodic/security/security.functions
37
32
38
rc=0
33
rc=0
39
34
40
echo ""
35
if checkyesno daily_status_security_chkportsum_enable; then
41
echo 'Checking for ports with mismatched checksums:'
36
	if TMP=$(mktemp -t chkportsum); then
42
37
		echo ""
43
case "${daily_status_security_chkportsum_enable}" in
38
		echo 'Checking for ports with mismatched checksums:'
44
	[Yy][Ee][Ss])
39
		set -f
45
	set -f
40
		pkg_info -ga 2>/dev/null | \
46
	pkg_info -ga 2>/dev/null | \
41
		while IFS= read -r line; do
47
	while IFS= read -r line; do
42
			set -- $line
48
		set -- $line
43
			case $1 in
49
		case $1 in
50
			Information)
44
			Information)
51
			case $2 in
45
				case $2 in
52
				for) name="${3%%:}" ;;
46
				for) name="${3%%:}" ;;
53
				*) name='??' ;;
47
				*) name='??' ;;
54
			esac
48
				esac
55
			;;
49
				;;
56
			Mismatched|'') ;;
50
			Mismatched|'') ;;
57
			*) [ -n "${name}" ] &&
51
			*) [ -n "${name}" ] &&
58
				echo "${name}: ${line%% fails the original MD5 checksum}"
52
				echo "${name}: ${line%% fails the original MD5 checksum}"
59
			;;
53
				;;
60
		esac
54
			esac
61
	done
55
		done > $TMP
62
	;;
56
		if [ $(wc -l $TMP) -gt 0 ]; then
63
	*)
57
			cat $TMP
64
	rc=0
58
			rc=1
65
	;;
59
		fi
66
esac
60
		rm -f $TMP
61
	else
62
		rc=3
63
	fi
64
fi
67
65
68
exit $rc
66
exit $rc
(-)etc/periodic/security/500.ipfwdenied (-17 / +14 lines)
Lines 27-53 Link Here
27
# $FreeBSD$
27
# $FreeBSD$
28
#
28
#
29
29
30
# If there is a global system configuration file, suck it in.
30
. /etc/periodic.subr
31
#
32
if [ -r /etc/defaults/periodic.conf ]
33
then
34
    . /etc/defaults/periodic.conf
35
    source_periodic_confs
36
fi
37
38
. /etc/periodic/security/security.functions
31
. /etc/periodic/security/security.functions
39
32
40
rc=0
33
rc=0
41
34
42
case "$daily_status_security_ipfwdenied_enable" in
35
if checkyesno daily_status_security_ipfwdenied_enable; then
43
    [Yy][Ee][Ss])
36
	if TMP=$(mktemp -t security); then
44
	TMP=`mktemp -t security`
37
		if ipfw -a list 2>/dev/null | egrep "deny|reset|unreach" > ${TMP}; then
45
	if ipfw -a list 2>/dev/null | egrep "deny|reset|unreach" > ${TMP}; then
38
			check_diff new_only ipfw ${TMP} \
46
	  check_diff new_only ipfw ${TMP} "${host} ipfw denied packets:"
39
			    "${host} ipfw denied packets:"
40
			rc=$?
41
		else
42
			rc=1
43
		fi
44
		rm -f ${TMP}
45
	else
46
		rc=3
47
	fi
47
	fi
48
	rc=$?
48
fi
49
	rm -f ${TMP};;
50
    *)	rc=0;;
51
esac
52
49
53
exit $rc
50
exit $rc
(-)etc/periodic/security/510.ipfdenied (-17 / +13 lines)
Lines 27-53 Link Here
27
# $FreeBSD$
27
# $FreeBSD$
28
#
28
#
29
29
30
# If there is a global system configuration file, suck it in.
30
. /etc/periodic.subr
31
#
32
if [ -r /etc/defaults/periodic.conf ]
33
then
34
    . /etc/defaults/periodic.conf
35
    source_periodic_confs
36
fi
37
38
. /etc/periodic/security/security.functions
31
. /etc/periodic/security/security.functions
39
32
40
rc=0
33
rc=0
41
34
42
case "$daily_status_security_ipfdenied_enable" in
35
if checkyesno daily_status_security_ipfdenied_enable; then
43
    [Yy][Ee][Ss])
36
	if TMP=$(mktemp -t security); then
44
	TMP=`mktemp -t security`
37
		if ipfstat -nhio 2>/dev/null | grep block > ${TMP}; then
45
	if ipfstat -nhio 2>/dev/null | grep block > ${TMP}; then
38
			check_diff new_only ipf ${TMP} "${host} ipf denied packets:"
46
	  check_diff new_only ipf ${TMP} "${host} ipf denied packets:"
39
			rc=$?
40
		else
41
			rc=1
42
		fi
43
		rm -f ${TMP}
44
	else
45
		rc=3
47
	fi
46
	fi
48
	rc=$?
47
fi
49
	rm -f ${TMP};;
50
    *)	rc=0;;
51
esac
52
48
53
exit $rc
49
exit $rc
(-)etc/periodic/security/520.pfdenied (-17 / +22 lines)
Lines 27-53 Link Here
27
# $FreeBSD$
27
# $FreeBSD$
28
#
28
#
29
29
30
# If there is a global system configuration file, suck it in.
30
. /etc/periodic.subr
31
#
32
if [ -r /etc/defaults/periodic.conf ]
33
then
34
    . /etc/defaults/periodic.conf
35
    source_periodic_confs
36
fi
37
38
. /etc/periodic/security/security.functions
31
. /etc/periodic/security/security.functions
39
32
40
rc=0
33
rc=0
41
34
42
case "$daily_status_security_pfdenied_enable" in
35
if checkyesno daily_status_security_pfdenied_enable; then
43
    [Yy][Ee][Ss])
36
	if TMP=$(mktemp -t security); then
44
	TMP=`mktemp -t security`
37
		pfctl -sr -v 2>/dev/null | \
45
	if pfctl -sr -v 2>/dev/null | nawk '{if (/^block/) {buf=$0; getline; gsub(" +"," ",$0); print buf$0;} }' > ${TMP}; then
38
		    nawk '{
46
	  check_diff new_only pf ${TMP} "${host} pf denied packets:"
39
			if (/^block/) {
40
				buf=$0;
41
				getline;
42
				gsub(" +"," ",$0);
43
				print buf$0;
44
			}
45
		}' > ${TMP}
46
		if [ $? -eq 0 ]; then
47
			check_diff new_only pf ${TMP} "${host} pf denied packets:"
48
			rc=$?
49
		else
50
			rc=1
51
		fi
52
		rm -f ${TMP}
53
	else
54
		rc=3
47
	fi
55
	fi
48
	rc=$?
56
fi
49
	rm -f ${TMP};;
50
    *)	rc=0;;
51
esac
52
57
53
exit $rc
58
exit $rc
(-)etc/periodic/security/550.ipfwlimit (-27 / +21 lines)
Lines 30-68 Link Here
30
# Show ipfw rules which have reached the log limit
30
# Show ipfw rules which have reached the log limit
31
#
31
#
32
32
33
# If there is a global system configuration file, suck it in.
33
. /etc/periodic.subr
34
#
35
if [ -r /etc/defaults/periodic.conf ]
36
then
37
    . /etc/defaults/periodic.conf
38
    source_periodic_confs
39
fi
40
34
41
rc=0
35
rc=0
42
36
43
case "$daily_status_security_ipfwlimit_enable" in
37
if checkyesno daily_status_security_ipfwlimit_enable; then
44
    [Yy][Ee][Ss])
45
	IPFW_VERBOSE=`sysctl -n net.inet.ip.fw.verbose 2> /dev/null`
38
	IPFW_VERBOSE=`sysctl -n net.inet.ip.fw.verbose 2> /dev/null`
46
	if [ $? -ne 0 ] || [ "$IPFW_VERBOSE" -eq 0 ]; then
39
	if [ $? -ne 0 -o "$IPFW_VERBOSE" -eq 0 ]; then
47
		exit 0
40
		exit 0
48
	fi
41
	fi
49
	TMP=`mktemp -t security`
42
	if TMP=`mktemp -t security`; then
50
	ipfw -a list | grep " log " | \
43
		ipfw -a list | grep " log " | \
51
	grep '^[[:digit:]]\+[[:space:]]\+[[:digit:]]\+' | \
44
		grep '^[[:digit:]]\+[[:space:]]\+[[:digit:]]\+' | \
52
	awk \
45
		awk \
53
		'{if ($6 == "logamount") {
46
			'{if ($6 == "logamount") {
54
			if ($2 > $7)
47
				if ($2 > $7)
55
				{print $0}}
48
					{print $0}}
56
		}' > ${TMP}
49
			}' > ${TMP}
57
50
58
	if [ -s "${TMP}" ]; then
51
		if [ -s "${TMP}" ]; then
59
		rc=1
52
			rc=1
60
		echo ""
53
			echo ""
61
		echo 'ipfw log limit reached:'
54
			echo 'ipfw log limit reached:'
62
		cat ${TMP}
55
			cat ${TMP}
56
		fi
57
		rm -f ${TMP}
58
	else
59
		rc=3
63
	fi
60
	fi
64
	rm -f ${TMP};;
61
fi
65
    *)	rc=0;;
66
esac
67
68
exit $rc
62
exit $rc
(-)etc/periodic/security/610.ipf6denied (-17 / +13 lines)
Lines 27-53 Link Here
27
# $FreeBSD$
27
# $FreeBSD$
28
#
28
#
29
29
30
# If there is a global system configuration file, suck it in.
30
. /etc/periodic.subr
31
#
32
if [ -r /etc/defaults/periodic.conf ]
33
then
34
    . /etc/defaults/periodic.conf
35
    source_periodic_confs
36
fi
37
38
. /etc/periodic/security/security.functions
31
. /etc/periodic/security/security.functions
39
32
40
rc=0
33
rc=0
41
34
42
case "$daily_status_security_ipf6denied_enable" in
35
if checkyesno daily_status_security_ipf6denied_enable; then
43
    [Yy][Ee][Ss])
36
	if TMP=$(mktemp -t security); then
44
	TMP=`mktemp ${TMPDIR:-/tmp}/security.XXXXXXXXXX`
37
		if ipfstat -nhio6 2>/dev/null | grep block > ${TMP}; then
45
	if ipfstat -nhio6 2>/dev/null | grep block > ${TMP}; then
38
			check_diff new_only ipf6 ${TMP} "${host} ipf6 denied packets:"
46
	 check_diff new_only ipf6 ${TMP} "${host} ipf6 denied packets:"
39
			rc=$?
40
		else
41
			rc=1
42
		fi
43
		rm -f ${TMP}
44
	else
45
		rc=3
47
	fi
46
	fi
48
	rc=$?
47
fi
49
	rm -f ${TMP};;
50
    *)	rc=0;;
51
esac
52
48
53
exit $rc
49
exit $rc
(-)etc/periodic/security/700.kernelmsg (-13 / +4 lines)
Lines 30-53 Link Here
30
# Show kernel log messages
30
# Show kernel log messages
31
#
31
#
32
32
33
# If there is a global system configuration file, suck it in.
33
. /etc/periodic.subr
34
#
35
if [ -r /etc/defaults/periodic.conf ]
36
then
37
    . /etc/defaults/periodic.conf
38
    source_periodic_confs
39
fi
40
41
. /etc/periodic/security/security.functions
34
. /etc/periodic/security/security.functions
42
35
43
rc=0
36
rc=0
44
37
45
case "$daily_status_security_kernelmsg_enable" in
38
if checkyesno daily_status_security_kernelmsg_enable; then
46
    [Yy][Ee][Ss])
47
	dmesg 2>/dev/null |
39
	dmesg 2>/dev/null |
48
	    check_diff new_only dmesg - "${host} kernel log messages:"
40
	    check_diff new_only dmesg - "${host} kernel log messages:"
49
	rc=$?;;
41
	rc=$?
50
    *)	rc=0;;
42
fi
51
esac
52
43
53
exit $rc
44
exit $rc
(-)etc/periodic/security/800.loginfail (-26 / +7 lines)
Lines 30-68 Link Here
30
# Show login failures
30
# Show login failures
31
#
31
#
32
32
33
# If there is a global system configuration file, suck it in.
33
. /etc/periodic.subr
34
#
35
if [ -r /etc/defaults/periodic.conf ]
36
then
37
    . /etc/defaults/periodic.conf
38
    source_periodic_confs
39
fi
40
34
41
LOG="${daily_status_security_logdir}"
35
LOG="${daily_status_security_logdir}"
42
36
37
rc=0
38
43
yesterday=`date -v-1d "+%b %e "`
39
yesterday=`date -v-1d "+%b %e "`
44
40
45
catmsgs() {
41
if checkyesno daily_status_security_loginfail_enable; then
46
	find ${LOG} -name 'auth.log.*' -mtime -2 |
47
	    sort -t. -r -n -k 2,2 |
48
	    while read f
49
	    do
50
		case $f in
51
		    *.gz)	zcat -f $f;;
52
		    *.bz2)	bzcat -f $f;;
53
		esac
54
	    done
55
	[ -f ${LOG}/auth.log ] && cat $LOG/auth.log
56
}
57
58
case "$daily_status_security_loginfail_enable" in
59
    [Yy][Ee][Ss])
60
	echo ""
42
	echo ""
61
	echo "${host} login failures:"
43
	echo "${host} login failures:"
62
	n=$(catmsgs | egrep -ia "^$yesterday.*: .*(fail|invalid|bad|illegal)" |
44
	n=$(catlogs $LOG auth | egrep -ia "^$yesterday.*: .*(fail|invalid|bad|illegal)" |
63
	    tee /dev/stderr | wc -l)
45
	    tee /dev/stderr | wc -l)
64
	[ $n -gt 0 ] && rc=1 || rc=0;;
46
	[ $n -gt 0 ] && rc=1
65
    *)	rc=0;;
47
fi
66
esac
67
48
68
exit $rc
49
exit $rc
(-)etc/periodic/security/security.functions (-2 / +1 lines)
Lines 73-78 Link Here
73
    mv ${tmpf} ${LOG}/${label}.today || rc=3
73
    mv ${tmpf} ${LOG}/${label}.today || rc=3
74
  fi
74
  fi
75
75
76
  rm -f ${tmpf}
76
  return ${rc}
77
  exit ${rc}
78
}
77
}
(-)etc/periodic/weekly/310.locate (-14 / +7 lines)
Lines 3-32 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$weekly_locate_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno weekly_locate_enable; then
16
	echo ""
11
	echo ""
17
	echo "Rebuilding locate database:"
12
	echo "Rebuilding locate database:"
18
13
19
	locdb=/var/db/locate.database
14
	locdb=/var/db/locate.database
20
15
21
	touch $locdb && rc=0 || rc=3
16
	touch $locdb || rc=3
22
	chown nobody $locdb || rc=3
17
	chown nobody $locdb || rc=3
23
	chmod 644 $locdb || rc=3
18
	chmod 644 $locdb || rc=3
24
19
25
	cd /
20
	cd /
26
	echo /usr/libexec/locate.updatedb | nice -n 5 su -fm nobody || rc=3
21
	echo /usr/libexec/locate.updatedb | nice -n 5 su -fm nobody || rc=3
27
	chmod 444 $locdb || rc=3;;
22
	chmod 444 $locdb || rc=3
23
fi
28
24
29
    *)  rc=0;;
30
esac
31
32
exit $rc
25
exit $rc
(-)etc/periodic/weekly/320.whatis (-16 / +7 lines)
Lines 3-23 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$weekly_whatis_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno weekly_whatis_enable; then
16
	echo ""
11
	echo ""
17
	echo "Rebuilding whatis database:"
12
	echo "Rebuilding whatis database:"
18
13
19
	MANPATH=`/usr/bin/manpath -q`
14
	if MANPATH=$(/usr/bin/manpath -q)
20
	if [ $? = 0 ]
21
	then
15
	then
22
	    if [ -z "${MANPATH}" ]
16
	    if [ -z "${MANPATH}" ]
23
	    then
17
	    then
Lines 25-31 Link Here
25
		rc=3
19
		rc=3
26
	    else
20
	    else
27
		man_locales=`/usr/bin/manpath -qL`
21
		man_locales=`/usr/bin/manpath -qL`
28
		rc=0
29
22
30
	        # Build whatis(1) database(s) for original, non-localized
23
	        # Build whatis(1) database(s) for original, non-localized
31
		#  manpages.
24
		#  manpages.
Lines 43-51 Link Here
43
	    fi
36
	    fi
44
	else
37
	else
45
	    rc=3
38
	    rc=3
46
	fi;;
39
	fi
40
fi
47
41
48
    *)  rc=0;;
49
esac
50
51
exit $rc
42
exit $rc
(-)etc/periodic/weekly/330.catman (-41 / +29 lines)
Lines 3-58 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$weekly_catman_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno weekly_catman_enable; then
16
	if [ ! -d /usr/share/man/cat1 ]
11
	if [ ! -d /usr/share/man/cat1 ]
17
	then
12
	then
18
	    echo '$weekly_catman_enable is set but /usr/share/man/cat1' \
13
	    err 2 '$weekly_catman_enable is set but /usr/share/man/cat1' \
19
		"doesn't exist"
14
		"doesn't exist"
20
	    rc=2
15
	fi
21
	else
16
	echo ""
22
	    echo ""
17
	echo "Reformatting manual pages:"
23
	    echo "Reformatting manual pages:"
24
18
25
	    MANPATH=`/usr/bin/manpath -q`
19
	if MANPATH=`/usr/bin/manpath -q`
26
	    if [ $? = 0 ]
20
	then
21
	    if [ -z "${MANPATH}" ]
27
	    then
22
	    then
28
		if [ -z "${MANPATH}" ]
23
	        err 3 "manpath failed to find any manpath directories"
29
		then
24
	    else
30
		    echo "manpath failed to find any manpath directories"
25
	        man_locales=`/usr/bin/manpath -qL`
31
		    rc=3
32
		else
33
		    man_locales=`/usr/bin/manpath -qL`
34
		    rc=0
35
26
36
		    # Preformat original, non-localized manpages
27
	        # Preformat original, non-localized manpages
37
		    echo /usr/libexec/catman.local -r "$MANPATH" |
28
		echo /usr/libexec/catman.local -r "$MANPATH" |
38
			su -fm man || rc=3
29
		    su -fm man || rc=3
39
30
40
		    # Preformat localized manpages.
31
		# Preformat localized manpages.
41
		    if [ -n "$man_locales" ]
32
		if [ -n "$man_locales" ]
42
		    then
33
		then
43
			for i in $man_locales
34
		    for i in $man_locales
44
			do
35
		    do
45
			    echo /usr/libexec/catman.local -Lr \
36
		        echo /usr/libexec/catman.local -Lr \
46
				"$MANPATH" | LC_ALL=$i su -fm man || rc=3
37
			"$MANPATH" | LC_ALL=$i su -fm man || rc=3
47
			done
38
		    done
48
		    fi
49
		fi
39
		fi
50
	    else
51
		rc=3
52
	    fi
40
	    fi
53
	fi;;
41
	else
42
	    rc=3
43
	fi
44
fi
54
45
55
    *)  rc=0;;
56
esac
57
58
exit $rc
46
exit $rc
(-)etc/periodic/weekly/340.noid (-13 / +5 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$weekly_noid_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno weekly_noid_enable; then
16
	echo ""
11
	echo ""
17
	echo "Check for files with an unknown user or group:"
12
	echo "Check for files with an unknown user or group:"
18
13
Lines 21-29 Link Here
21
	    \( -nogroup -o -nouser \) -print | sed 's/^/  /' |
16
	    \( -nogroup -o -nouser \) -print | sed 's/^/  /' |
22
	    tee /dev/stderr | wc -l)
17
	    tee /dev/stderr | wc -l)
23
	[ $rc -gt 1 ] && rc=1
18
	[ $rc -gt 1 ] && rc=1
24
	;;
19
fi
25
20
26
    *)  rc=0;;
27
esac
28
29
exit $rc
21
exit $rc
(-)etc/periodic/weekly/400.status-pkg (-13 / +6 lines)
Lines 3-18 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
case "$weekly_status_pkg_enable" in
8
rc=0
15
    [Yy][Ee][Ss])
9
10
if checkyesno weekly_status_pkg_enable; then
16
	echo ""
11
	echo ""
17
	echo "Check for out of date packages:"
12
	echo "Check for out of date packages:"
18
13
Lines 25-33 Link Here
25
		-e 's/^\([^ ]*-[^ ]*\)  *? *\(orphaned:.*\)$/  \1 was \2/p' |
20
		-e 's/^\([^ ]*-[^ ]*\)  *? *\(orphaned:.*\)$/  \1 was \2/p' |
26
	    tee /dev/stderr |
21
	    tee /dev/stderr |
27
	    wc -l)
22
	    wc -l)
28
	[ $rc -gt 1 ] && rc=1;;
23
	[ $rc -gt 1 ] && rc=1
24
fi
29
25
30
    *)  rc=0;;
31
esac
32
33
exit $rc
26
exit $rc
(-)etc/periodic/weekly/999.local (-7 / +2 lines)
Lines 3-17 Link Here
3
# $FreeBSD$
3
# $FreeBSD$
4
#
4
#
5
5
6
# If there is a global system configuration file, suck it in.
6
. /etc/periodic.subr
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
7
14
rc=0
8
rc=0
9
15
for script in $weekly_local
10
for script in $weekly_local
16
do
11
do
17
    echo ''
12
    echo ''

Return to bug 174054