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(docker): allow passing options to falco-driver-loader from the cointainer image #2781

Merged

Conversation

LucaGuerra
Copy link
Contributor

@LucaGuerra LucaGuerra commented Sep 6, 2023

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind feature
/area build

What this PR does / why we need it:

Sometimes we may want to specify options for the driver loader script, for example when we may decide to only download or compile the eBPF probe rather than the kmod. This is not strictly required, more like something that is nice to have.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

new(docker): allow passing options to falco-driver-loader from the driver loader cointainer

Andreagit97
Andreagit97 previously approved these changes Sep 7, 2023
Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

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

/approve

I would document it somewhere!

@poiana
Copy link
Contributor

poiana commented Sep 7, 2023

LGTM label has been added.

Git tree hash: 3938e247ce188b768023e9c7d070fca35fb83e39

@Andreagit97 Andreagit97 added this to the 0.36.0 milestone Sep 7, 2023
@@ -27,7 +27,8 @@ if [[ -z "${SKIP_DRIVER_LOADER}" ]]; then
ln -s "$i" "/usr/src/$base"
done

/usr/bin/falco-driver-loader
falco_driver_loader_option_arr=($FALCO_DRIVER_LOADER_OPTIONS)
/usr/bin/falco-driver-loader "${falco_driver_loader_option_arr[@]}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/usr/bin/falco-driver-loader "${falco_driver_loader_option_arr[@]}"
/usr/bin/falco-driver-loader ${falco_driver_loader_option_arr[@]}

why do we need " here? 🤔
what will happen if $FALCO_DRIVER_LOADER_OPTIONS contains "? 🤔

/hold

Copy link
Contributor Author

@LucaGuerra LucaGuerra Sep 7, 2023

Choose a reason for hiding this comment

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

It's not a good PR review if nobody mentions either mystifying Bash rules or the C standard.

The " is there to prevent variable globbing and expansion, meaning that if you pass a * in the array it will not expand to all files in this directory. Then I tried and I noticed that there is a mistake in the line above, which should be read -a args_arr <<< $FALCO_DRIVER_LOADER_OPTIONS because otherwise ... variable expansion will happen anyways. So I'm going to fix that.

To answer the second part of the question, arguments are simply space-delimited (technically, $IFS delimited).

You can verify by copying these two scripts:

print-args.sh

#!/bin/bash

for arg
do
    printf '%s\n' "$arg"
done

args-from-env.sh

#!/bin/bash

read -a args_arr <<< $MY_ARGS

echo "--- with quotes ---"
./print-args.sh "${args_arr[@]}"

echo "--- without quotes ---"
./print-args.sh ${args_arr[@]}

echo "--- without quotes and array conversion ---"
./print-args.sh ${MY_ARGS}

and running MY_ARGS='hello bash * old not friend' ./args-from-env.sh

Copy link
Member

Choose a reason for hiding this comment

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

🤯

Copy link
Member

Choose a reason for hiding this comment

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

/hold cancel

…ntainer image

Signed-off-by: Luca Guerra <luca@guerra.sh>
@LucaGuerra LucaGuerra force-pushed the new/driver-loader-container-options branch from 99b9bcc to 36a36f0 Compare September 11, 2023 09:04
Copy link
Member

@Andreagit97 Andreagit97 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 poiana added the lgtm label Sep 11, 2023
@poiana
Copy link
Contributor

poiana commented Sep 11, 2023

LGTM label has been added.

Git tree hash: b438a74e81397f2103ed78c7e8c9aa51cbbc8169

Copy link
Contributor

@FedeDP FedeDP 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 Sep 11, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, FedeDP, LucaGuerra

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:

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

@poiana poiana merged commit 37ce18f into falcosecurity:master Sep 11, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants