From 8a1de131f4d72cbbe881c5491c62a2cac6fc8ff1 Mon Sep 17 00:00:00 2001 From: Leonardo Grasso Date: Fri, 21 Jan 2022 23:04:32 +0100 Subject: [PATCH] update(scripts/falco-driver-loader): load the latest version first Signed-off-by: Leonardo Grasso --- scripts/falco-driver-loader | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/falco-driver-loader b/scripts/falco-driver-loader index 9494253a..3092bab5 100755 --- a/scripts/falco-driver-loader +++ b/scripts/falco-driver-loader @@ -196,8 +196,12 @@ load_kernel_module_download() { if curl -L --create-dirs "${FALCO_DRIVER_CURL_OPTIONS}" -o "${HOME}/.falco/${FALCO_KERNEL_MODULE_FILENAME}" "${URL}"; then echo "* Download succeeded" chcon -t modules_object_t "${HOME}/.falco/${FALCO_KERNEL_MODULE_FILENAME}" > /dev/null 2>&1 || true - insmod "${HOME}/.falco/${FALCO_KERNEL_MODULE_FILENAME}" && echo "* Success: ${DRIVER_NAME} module found and inserted" - exit $? + if insmod "${HOME}/.falco/${FALCO_KERNEL_MODULE_FILENAME}"; then + echo "* Success: ${DRIVER_NAME} module found and inserted" + exit 0 + else + >&2 echo "Unable to insmod the prebuilt ${DRIVER_NAME} module" + fi else >&2 echo "Unable to find a prebuilt ${DRIVER_NAME} module" return @@ -241,11 +245,6 @@ load_kernel_module() { exit 0 fi - echo "* Trying to load a system ${DRIVER_NAME} module, if present" - if modprobe "${DRIVER_NAME}" > /dev/null 2>&1; then - echo "* Success: ${DRIVER_NAME} module found and loaded with modprobe" - exit 0 - fi echo "* Looking for a ${DRIVER_NAME} module locally (kernel ${KERNEL_RELEASE})" @@ -268,6 +267,13 @@ load_kernel_module() { load_kernel_module_compile fi + # Last try (might load a previous driver version) + echo "* Trying to load a system ${DRIVER_NAME} module, if present" + if modprobe "${DRIVER_NAME}" > /dev/null 2>&1; then + echo "* Success: ${DRIVER_NAME} module found and loaded with modprobe" + exit 0 + fi + # Not able to download a prebuilt module nor to compile one on-the-fly >&2 echo "Consider compiling your own ${DRIVER_NAME} driver and loading it or getting in touch with the Falco community" exit 1