Skip to content

Commit

Permalink
Load/unload kernel module on start/stop (#459)
Browse files Browse the repository at this point in the history
* Load/unload kernel module on start/stop

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.

* Put script execute line in right place.
  • Loading branch information
mstemm authored Nov 6, 2018
1 parent 6eac49e commit 32f8e30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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
7 changes: 6 additions & 1 deletion scripts/rpm/falco
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh

#
# Copyright (C) 2016-2018 Draios Inc dba Sysdig.
#
Expand All @@ -16,7 +18,6 @@
# limitations under the License.
#

#!/bin/sh
#
# falco syscall monitoring agent
#
Expand Down Expand Up @@ -53,6 +54,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 +68,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 32f8e30

Please sign in to comment.