Skip to content

Commit

Permalink
new(scripts): add a falco.target that consists of falco-X.service units.
Browse files Browse the repository at this point in the history
falcoctl will then run and bind to falco.target.

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Jan 19, 2023
1 parent b34997d commit a405892
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 28 deletions.
3 changes: 2 additions & 1 deletion cmake/cpack/CMakeCPackOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
if(CPACK_GENERATOR MATCHES "DEB" OR CPACK_GENERATOR MATCHES "RPM")
list(APPEND CPACK_INSTALL_COMMANDS "mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
list(APPEND CPACK_INSTALL_COMMANDS "cp -r scripts/systemd/falco-kmod-inject.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/systemd/falco.target _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/systemd/falco-kmod-inject.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/systemd/falco-kmod.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/systemd/falco-bpf.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/systemd/falco-modern-bpf.service _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/usr/lib/systemd/system")
Expand Down
2 changes: 2 additions & 0 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#

# Systemd
file(COPY "${PROJECT_SOURCE_DIR}/scripts/systemd/falco.target"
DESTINATION "${PROJECT_BINARY_DIR}/scripts/systemd")
file(COPY "${PROJECT_SOURCE_DIR}/scripts/systemd/falco-kmod-inject.service"
DESTINATION "${PROJECT_BINARY_DIR}/scripts/systemd")
file(COPY "${PROJECT_SOURCE_DIR}/scripts/systemd/falco-kmod.service"
Expand Down
6 changes: 1 addition & 5 deletions scripts/debian/prerm.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ set -e
case "$1" in
remove|upgrade|deconfigure)
echo "[PRE-REMOVE] Stop all Falco services:"
systemctl --system stop 'falco-kmod.service' || true
systemctl --system stop 'falco-bpf.service' || true
systemctl --system stop 'falco-modern-bpf.service' || true
systemctl --system stop 'falco-plugin.service' || true
systemctl --system stop 'falcoctl.service' || true
systemctl --system stop 'falco.target' || true

echo "[PRE-REMOVE] Call 'falco-driver-loader --clean:'"
falco-driver-loader --clean
Expand Down
6 changes: 1 addition & 5 deletions scripts/rpm/preuninstall.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ set -e

# Currently running falco service uses the driver, so stop it before driver cleanup
echo "[PRE-REMOVE] Stop all Falco services:"
systemctl --system stop 'falco-kmod.service' || true
systemctl --system stop 'falco-bpf.service' || true
systemctl --system stop 'falco-modern-bpf.service' || true
systemctl --system stop 'falco-plugin.service' || true
systemctl --system stop 'falcoctl.service' || true
systemctl --system stop 'falco.target' || true

echo "[PRE-REMOVE] Call 'falco-driver-loader --clean:'"
falco-driver-loader --clean
Expand Down
6 changes: 2 additions & 4 deletions scripts/systemd/falco-bpf.service
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Unit]
Description=Falco: Container Native Runtime Security with ebpf
Documentation=https://falco.org/docs/
PartOf=falco.target
Conflicts=falco-kmod.service
Conflicts=falco-modern-bpf.service
Conflicts=falco-plugin.service
Expand All @@ -21,7 +22,4 @@ ProtectSystem=full
ProtectKernelTunables=true
RestrictRealtime=true
RestrictAddressFamilies=~AF_PACKET
StandardOutput=null

[Install]
WantedBy=multi-user.target
StandardOutput=null
6 changes: 2 additions & 4 deletions scripts/systemd/falco-kmod.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Description=Falco: Container Native Runtime Security with kmod
Documentation=https://falco.org/docs/
After=falco-kmod-inject.service
Requires=falco-kmod-inject.service
PartOf=falco.target
Conflicts=falco-bpf.service
Conflicts=falco-modern-bpf.service
Conflicts=falco-plugin.service
Expand All @@ -23,7 +24,4 @@ ProtectKernelTunables=true
ReadWritePaths=/sys/module/falco
RestrictRealtime=true
RestrictAddressFamilies=~AF_PACKET
StandardOutput=null

[Install]
WantedBy=multi-user.target
StandardOutput=null
6 changes: 2 additions & 4 deletions scripts/systemd/falco-modern-bpf.service
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Unit]
Description=Falco: Container Native Runtime Security with modern ebpf
Documentation=https://falco.org/docs/
PartOf=falco.target
Conflicts=falco-kmod.service
Conflicts=falco-bpf.service
Conflicts=falco-plugin.service
Expand All @@ -20,7 +21,4 @@ ProtectSystem=full
ProtectKernelTunables=true
RestrictRealtime=true
RestrictAddressFamilies=~AF_PACKET
StandardOutput=null

[Install]
WantedBy=multi-user.target
StandardOutput=null
4 changes: 1 addition & 3 deletions scripts/systemd/falco-plugin.service
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Unit]
Description=Falco: Container Native Runtime Security with plugin
Documentation=https://falco.org/docs/
PartOf=falco.target
Conflicts=falco-kmod.service
Conflicts=falco-bpf.service
Conflicts=falco-modern-bpf.service
Expand All @@ -21,6 +22,3 @@ ProtectKernelTunables=true
RestrictRealtime=true
RestrictAddressFamilies=~AF_PACKET
StandardOutput=null

[Install]
WantedBy=multi-user.target
7 changes: 7 additions & 0 deletions scripts/systemd/falco.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Unit]
Description=Main Falco target
Requires=multi-user.target
After=multi-user.target

[Install]
WantedBy=multi-user.target
5 changes: 3 additions & 2 deletions scripts/systemd/falcoctl.service
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[Unit]
Description=Falco: Automatic rules update service
Documentation=https://falco.org/docs/
After=falco.target
BindsTo=falco.target

[Service]
Type=simple
Expand All @@ -15,8 +17,7 @@ NoNewPrivileges=yes
ProtectSystem=true
ProtectKernelTunables=true
RestrictRealtime=true
#RestrictAddressFamilies=~AF_PACKET
#StandardOutput=null
StandardOutput=null

[Install]
WantedBy=multi-user.target

0 comments on commit a405892

Please sign in to comment.