Skip to content

Commit

Permalink
security/rkhunter: Modernize and correct the periodic script
Browse files Browse the repository at this point in the history
Modernize the script but use a compatibility shim to maintain previous
variables.

PR:		272516
Reported by:	freebsd@oldach.net
Approved by:	lukasz@wasikowski.net (maintainer)
  • Loading branch information
Helge Oldach authored and Fernando Apesteguía committed Jul 28, 2023
1 parent 467da26 commit c85caa3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion security/rkhunter/Makefile
@@ -1,6 +1,6 @@
PORTNAME= rkhunter
PORTVERSION= 1.4.6
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= security
MASTER_SITES= SF

Expand Down
67 changes: 33 additions & 34 deletions security/rkhunter/files/415.rkhunter.in
Expand Up @@ -2,10 +2,12 @@

# This is a maintenance shell script for the rkhunter security tool.
# You can enable this script in /etc/periodic.conf file by putting these lines into it:
# daily_rkhunter_update_enable="YES"
# daily_rkhunter_update_flags="--update --nocolors"
# daily_rkhunter_check_enable="YES"
# daily_rkhunter_check_flags="--checkall --nocolors --skip-keypress"
# security_rkhunter_update_enable="YES"
# security_rkhunter_update_period="daily"
# security_rkhunter_update_flags="--update --nocolors"
# security_rkhunter_check_enable="YES"
# security_rkhunter_check_period="daily"
# security_rkhunter_check_flags="--checkall --nocolors --skip-keypress"
#
# Written by: Gabor Kovesdan <gabor@FreeBSD.org>

Expand All @@ -14,40 +16,37 @@ if [ -r /etc/defaults/periodic.conf ]; then
source_periodic_confs
fi

SLEEP=/bin/sleep
JOT=/usr/bin/jot

random() {
${JOT} -r 1 0 900
}

: ${daily_rkhunter_update_flags="--update --nocolors"}
: ${daily_rkhunter_check_flags="--checkall --nocolors --skip-keypress"}
# compatibility with pre-stable/12 style variables
for type in update check
do
for mode in enable flags
do
eval old=\"\$daily_rkhunter_${type}_${mode}\"
if test -n "$old"
then
echo "Warning: Variable \$daily_rkhunter_${type}_${mode} is deprecated, use \$security_rkhunter_${type}_${mode} instead." >&2
eval : \${security_rkhunter_${type}_${mode}:="\$daily_rkhunter_${type}_${mode}"}
fi
done
done

case "$daily_rkhunter_update_enable" in
[Yy][Ee][Ss])
# defaults
: ${security_rkhunter_update_period:="daily"}
: ${security_rkhunter_check_period:="daily"}
: ${security_rkhunter_update_flags:="--update --nocolors"}
: ${security_rkhunter_check_flags:="--checkall --nocolors --skip-keypress"}

if check_yesno_period security_rkhunter_update_enable
then
echo ""
echo "Updating the rkhunter database..."
# When non-interactive, sleep to reduce congestion on rkhunter site
if [ "$1" != -nodelay ]; then
# In FreeBSD 12.0 the anticongestion function should be used
# instead of a hard-coded sleep
if [ -n "$anticongestion_sleeptime" ]; then
anticongestion
else
${SLEEP} $(random)
fi
fi
%%PREFIX%%/bin/rkhunter ${daily_rkhunter_update_flags}
;;
esac

case "$daily_rkhunter_check_enable" in
[Yy][Ee][Ss])
anticongestion
%%PREFIX%%/bin/rkhunter ${security_rkhunter_update_flags}
fi

if check_yesno_period security_rkhunter_check_enable
then
echo ""
echo "Running rkhunter..."
%%PREFIX%%/bin/rkhunter ${daily_rkhunter_check_flags}
;;
esac
%%PREFIX%%/bin/rkhunter ${security_rkhunter_check_flags}
fi
10 changes: 6 additions & 4 deletions security/rkhunter/pkg-message
Expand Up @@ -4,14 +4,16 @@
You should keep your rkhunter database up-to-date.
This can be done automatically by putting this line to periodic.conf(5) files:

daily_rkhunter_update_enable="YES"
daily_rkhunter_update_flags="--update --nocolors"
security_rkhunter_update_enable="YES"
security_rkhunter_update_period="daily"
security_rkhunter_update_flags="--update --nocolors"

Also, you can run rkhunter as a part of the daily security check by
putting this line to periodic.conf(5) files:

daily_rkhunter_check_enable="YES"
daily_rkhunter_check_flags="--checkall --nocolors --skip-keypress"
security_rkhunter_check_enable="YES"
security_rkhunter_check_period="daily"
security_rkhunter_check_flags="--checkall --nocolors --skip-keypress"
EOM
}
]

0 comments on commit c85caa3

Please sign in to comment.