View | Details | Raw Unified | Return to bug 245283 | Differences between
and this patch

Collapse All | Expand All

(-)sysutils/checkrestart/Makefile (-4 / +5 lines)
Lines 3-8 Link Here
3
PORTNAME=	checkrestart
3
PORTNAME=	checkrestart
4
DISTVERSIONPREFIX=	v
4
DISTVERSIONPREFIX=	v
5
DISTVERSION=	0.5.0
5
DISTVERSION=	0.5.0
6
PORTREVISION=	1
6
CATEGORIES=	sysutils
7
CATEGORIES=	sysutils
7
8
8
MAINTAINER=	tom@hur.st
9
MAINTAINER=	tom@hur.st
Lines 18-31 Link Here
18
19
19
PLIST_FILES=	bin/checkrestart \
20
PLIST_FILES=	bin/checkrestart \
20
		share/man/man1/checkrestart.1.gz \
21
		share/man/man1/checkrestart.1.gz \
21
		etc/periodic/daily/checkrestart
22
		${PERIODIC_SECURITY}/checkrestart
22
23
23
PERIODIC_DAILY=	etc/periodic/daily
24
PERIODIC_SECURITY=	etc/periodic/security/
24
25
25
do-install:
26
do-install:
26
	${INSTALL_PROGRAM} ${WRKSRC}/checkrestart ${STAGEDIR}${PREFIX}/bin
27
	${INSTALL_PROGRAM} ${WRKSRC}/checkrestart ${STAGEDIR}${PREFIX}/bin
27
	${INSTALL_MAN} ${WRKSRC}/checkrestart.1 ${STAGEDIR}${MAN1PREFIX}/share/man/man1
28
	${INSTALL_MAN} ${WRKSRC}/checkrestart.1 ${STAGEDIR}${MAN1PREFIX}/share/man/man1
28
	@${MKDIR} ${STAGEDIR}${PREFIX}/${PERIODIC_DAILY}
29
	@${MKDIR} ${STAGEDIR}${PREFIX}/${PERIODIC_SECURITY}
29
	${INSTALL_SCRIPT} ${WRKDIR}/checkrestart ${STAGEDIR}${PREFIX}/${PERIODIC_DAILY}
30
	${INSTALL_SCRIPT} ${WRKDIR}/checkrestart ${STAGEDIR}${PREFIX}/${PERIODIC_SECURITY}
30
31
31
.include <bsd.port.mk>
32
.include <bsd.port.mk>
(-)sysutils/checkrestart/files/checkrestart.in (-29 / +17 lines)
Lines 6-18 Link Here
6
    source_periodic_confs
6
    source_periodic_confs
7
fi
7
fi
8
8
9
: "${daily_checkrestart_enable:=NO}"
9
: "${security_checkrestart_enable:=NO}"
10
: "${daily_checkrestart_weekdays:=1234567}" # Days of the week to run, Monday=1
10
: "${security_checkrestart_period:=DAILY}"
11
: "${daily_checkrestart_users:=}"           # User names or IDs to check
11
: "${security_checkrestart_users:=}"           # User names or IDs to check
12
: "${daily_checkrestart_jails:=}"           # Jail names or IDs to check
12
: "${security_checkrestart_jails:=}"           # Jail names or IDs to check
13
: "${daily_checkrestart_procs:=}"           # Process names or IDs to check
13
: "${security_checkrestart_procs:=}"           # Process names or IDs to check
14
14
15
checkrestartcmd=/usr/local/bin/checkrestart
15
checkrestartcmd=%%PREFIX%%/bin/checkrestart
16
hflag=""
16
hflag=""
17
rc=0
17
rc=0
18
18
Lines 20-26 Link Here
20
20
21
checkrestart() {
21
checkrestart() {
22
    local result
22
    local result
23
    result="$(${checkrestartcmd} ${hflag} "$@" -- ${daily_checkrestart_procs} 2>&1)"
23
    result="$(${checkrestartcmd} ${hflag} "$@" -- ${security_checkrestart_procs} 2>&1)"
24
    if [ "$result" ]; then
24
    if [ "$result" ]; then
25
        echo "${result}"
25
        echo "${result}"
26
        rc=3
26
        rc=3
Lines 29-36 Link Here
29
}
29
}
30
30
31
checkrestart_each_user() {
31
checkrestart_each_user() {
32
    if [ -n "${daily_checkrestart_users}" ]; then
32
    if [ -n "${security_checkrestart_users}" ]; then
33
        for user in ${daily_checkrestart_users}; do
33
        for user in ${security_checkrestart_users}; do
34
            checkrestart -u "${user}" "$@"
34
            checkrestart -u "${user}" "$@"
35
        done
35
        done
36
    else
36
    else
Lines 39-46 Link Here
39
}
39
}
40
40
41
checkrestart_start() {
41
checkrestart_start() {
42
    if [ -n "${daily_checkrestart_jails}" ]; then
42
    if [ -n "${security_checkrestart_jails}" ]; then
43
        for jail in ${daily_checkrestart_jails}; do
43
        for jail in ${security_checkrestart_jails}; do
44
            checkrestart_each_user -j "${jail}"
44
            checkrestart_each_user -j "${jail}"
45
        done
45
        done
46
    else
46
    else
Lines 48-70 Link Here
48
    fi
48
    fi
49
}
49
}
50
50
51
checkday() {
51
if check_yesno_period security_checkrestart_enable
52
    if echo "${daily_checkrestart_weekdays}" | grep -vq '^[1-7, ]*$'; then
52
then
53
        echo "daily_checkrestart_weekdays must have values 1-7"
53
    echo
54
        exit 2
54
    echo 'Checking for stale processes:'
55
    fi
55
    checkrestart_start
56
fi
56
57
57
    echo "${daily_checkrestart_weekdays}" | grep -Fq "$(date +%u)"
58
}
59
60
case "${daily_checkrestart_enable}" in
61
    [Yy][Ee][Ss])
62
    if checkday; then
63
        echo
64
        echo 'Checking for stale processes:'
65
        checkrestart_start
66
    fi
67
    ;;
68
esac
69
70
exit $rc
58
exit $rc
(-)sysutils/checkrestart/pkg-message (-5 / +25 lines)
Lines 4-16 Link Here
4
In order to enable periodic(8) checks, set the following in /etc/periodic.conf
4
In order to enable periodic(8) checks, set the following in /etc/periodic.conf
5
5
6
# Required
6
# Required
7
security_checkrestart_enable="YES"
8
9
# Optional
10
security_checkrestart_period="DAILY"     # or WEEKY, or MONTHLY
11
security_checkrestart_jails="0 web"      # limit to jails 0 and web
12
security_checkrestart_users="root www"   # limit to root and www users
13
security_checkrestart_procs="smbd httpd" # limit to samba and httpd
14
EOM,
15
},
16
{ type: upgrade,
17
  maximum_version: "0.5.0_1",
18
  message: <<EOM
19
The periodic(8) script is now a security script.  All 'daily_checkrestart_'
20
instances in /etc/periodic.conf should be changed to 'security_checkrestart_'.
21
22
i.e.
23
7
daily_checkrestart_enable="YES"
24
daily_checkrestart_enable="YES"
8
25
9
# Optional
26
is now:
10
daily_checkrestart_weekdays="1 4"     # only run on Monday and Thursday
27
11
daily_checkrestart_jails="0 web"      # limit to jails 0 and web
28
security_checkrestart_enable="YES"
12
daily_checkrestart_users="root www"   # limit to root and www users
29
13
daily_checkrestart_procs="smbd httpd" # limit to samba and httpd
30
daily_checkrestart_weekdays is no longer supported.  The security period
31
mechanism should be used instead:
32
33
security_checkrestart_period="DAILY" # or WEEKLY, or MONTHLY
14
EOM
34
EOM
15
}
35
}
16
]
36
]

Return to bug 245283