Skip to content

Commit

Permalink
Load/unload kernel module on start/stop
Browse files Browse the repository at this point in the history
When falco is started, load the kernel module. (The falco binary also
will do a modprobe if it can't open the inspector, as a backup).

When falco is stopped, unload the kernel module.

This fixes #418.
  • Loading branch information
mstemm committed Nov 6, 2018
1 parent 774046d commit 41c588f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/debian/falco
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ do_start()
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
if [ ! -d /sys/module/falco_probe ]; then
/sbin/modprobe falco-probe || exit 1
fi
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
Expand Down Expand Up @@ -94,6 +97,7 @@ do_stop()
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
/sbin/rmmod falco-probe
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
Expand Down
4 changes: 4 additions & 0 deletions scripts/rpm/falco
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ start() {
# [ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon $exec --daemon --pidfile=$pidfile
if [ ! -d /sys/module/falco_probe ]; then
/sbin/modprobe falco-probe || return $?
fi
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
Expand All @@ -64,6 +67,7 @@ stop() {
killproc -p $pidfile
retval=$?
echo
/sbin/rmmod falco-probe
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
Expand Down

0 comments on commit 41c588f

Please sign in to comment.