Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: ship falcoctl bundled with Falco #2345

Merged
merged 20 commits into from
Jan 25, 2023
Merged

new: ship falcoctl bundled with Falco #2345

merged 20 commits into from
Jan 25, 2023

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Jan 10, 2023

What type of PR is this?

/kind feature

Any specific area of the project related to this PR?

/area build

What this PR does / why we need it:

This PR bundles falcoctl inside Falco; moreover, it adds a new systemd service for falcoctl that will be used during DEB/RPM installation; moreover, the user will be asked (through a dialog) to enable the automatic feed; by default (when dialog is missing or we are in a non interactive mode), falcoctl is not enabled.

Finally, if no driver is chosen at package installation time, falcoctl dialog won't be shown.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

new!: ship falcoctl inside Falco

CMakeLists.txt Show resolved Hide resolved

string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} FALCOCTL_SYSTEM_NAME)

set(FALCOCTL_VERSION "0.2.0-rc1")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RC version for now. To be bumped before release.

BUILD_COMMAND ""
INSTALL_COMMAND "")

install(PROGRAMS "${PROJECT_BINARY_DIR}/falcoctl-prefix/src/falcoctl/falcoctl" DESTINATION "${FALCO_BIN_DIR}" COMPONENT "${FALCO_COMPONENT_NAME}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Install it under the FALCO_COMPONENT_NAME, just like we do for falco-driver-loader.

@@ -17,19 +17,19 @@
#

chosen_driver=
enable_falcoctl=0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled by default.


if [ "$1" = "configure" ]; then
if [ -x /usr/bin/dialog ]; then
# If dialog is installed, create a dialog to let users choose the correct driver for them
CHOICE=$(dialog --clear --backtitle "Choose your preferred driver" --title "Falco drivers" --menu "Choose one of the following options:" 15 40 5 \
CHOICE=$(dialog --clear --title "Falco drivers" --menu "Choose your preferred driver:" 12 40 5 \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small tweaks.

scripts/systemd/falcoctl.service Outdated Show resolved Hide resolved
@jasondellaluce
Copy link
Contributor

/milestone 0.34.0

@poiana poiana added this to the 0.34.0 milestone Jan 10, 2023
@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 11, 2023

CI timed out :/

@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 11, 2023

@LucaGuerra @loresuso @alacuku
Let me know if this works for you, given you are the most active devs on falcoctl :D

Minor refinements might be needed on systemd service permissions; moreover, i am not getting who is supposed to ship:

  • etc/falcoctl/config.yaml
  • /etc/falcoctl/follow.yaml

ProtectKernelTunables=true
RestrictRealtime=true
#RestrictAddressFamilies=~AF_PACKET
#StandardOutput=null
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need StandardOutput=null for all other services?
/cc @leogr

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FedeDP
I'm unsure, but we likely need to keep it. The reason is to avoid polluting /var/logs/messages. See this my old comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thank you!

@poiana poiana requested a review from leogr January 18, 2023 09:59
@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 18, 2023

Side note: if we want falcoctl.service to start after falco service, we would need to create a falco.target so that falcoctl.service can have a After=falco.target line, and every falco-*.service will be PartOf falco target.

Do you think this is important?
@leogr @loresuso

@leogr
Copy link
Member

leogr commented Jan 19, 2023

Side note: if we want falcoctl.service to start after falco service, we would need to create a falco.target so that falcoctl.service can have a After=falco.target line, and every falco-*.service will be PartOf falco target.

Do you think this is important? @leogr @loresuso

@FedeDP
Yes, I think so. Although falcoctl should correctly handle the case falco is not yet ready, I believe we should also enforce that via systemd for consistency.

@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 19, 2023

Ok, i will add support for it :)

@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 19, 2023

Support added in latest commit; basically:

  • all the falco-X units are PartOf falco.target
  • falco.target declares how units are installed
  • falcoctl.service runs after and binds to falco.target; this means that it is run after the falco target and if the falco target is stopped it gets stopped
  • preuninstall deb/rpm scripts will then stop just the falco.target, that will then stop falcoctl and falco-X services

@@ -17,19 +17,19 @@
#

chosen_driver=
enable_falcoctl=1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabled by default.

clear
esac

CHOICE=$(dialog --clear --title "Falcoctl" --menu "Do you want to follow automatic ruleset updates?" 10 40 2 \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choice is always requested for falcoctl, even when no driver was chosen.

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 'falco.target' || true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all units are PartOf falco.target, and falcoctl service is bound to it, we can just stop falco.target.

Copy link
Contributor

@jasondellaluce jasondellaluce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work! LGTM so far!

@Andreagit97
Copy link
Member

/hold

@Andreagit97 Andreagit97 force-pushed the new/falcoctl branch 2 times, most recently from be97f3a to 80ef2e2 Compare January 23, 2023 21:31
FedeDP and others added 6 commits January 24, 2023 12:42
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
FedeDP and others added 2 commits January 24, 2023 13:36
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
cmake/modules/falcoctl.cmake Outdated Show resolved Hide resolved
@poiana poiana added size/XL and removed size/L labels Jan 25, 2023
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
@LucaGuerra LucaGuerra mentioned this pull request Jan 25, 2023
48 tasks
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Copy link
Contributor

@jasondellaluce jasondellaluce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@poiana
Copy link
Contributor

poiana commented Jan 25, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP, jasondellaluce, leogr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [FedeDP,jasondellaluce,leogr]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Andreagit97
Copy link
Member

/unhold

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants