-
Notifications
You must be signed in to change notification settings - Fork 0
fix(falcon): preserve CrowdStrike OTA updates across reboots #1899
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,14 +10,33 @@ fi | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| install -d -m 0770 /opt/CrowdStrike | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Update binaries from the nix store, but preserve runtime state files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # falconstore contains the Agent ID (AID) — if lost, the sensor re-registers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # as a new host and consumes another license seat. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @rsync@/bin/rsync -a --delete \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --exclude=falconstore \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --exclude=falconstore.bak \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --exclude=CsConfig \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "@falcon@/opt/CrowdStrike/" /opt/CrowdStrike/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # CrowdStrike pushes OTA updates that write newer versioned binaries into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # /opt/CrowdStrike/. Only rsync the packaged binaries when the installed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # version is not newer than the package, otherwise the rsync clobbers the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # update and the running sensor can't find its helper binaries (ENOENT). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pkg_ver="@falcon@/opt/CrowdStrike/falconctl" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| installed_ver=/opt/CrowdStrike/falconctl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| need_sync=true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -x "$installed_ver" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pkg_build=$(readlink -f "$pkg_ver" | grep -oP '\d+$' || echo "0") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inst_build=$(readlink -f "$installed_ver" | grep -oP '\d+$' || echo "0") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Version detection silently no-ops on a plain-file falconctl. Reproduced locally: Consider either (a) calling |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$inst_build" -gt "$pkg_build" ] 2>/dev/null; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "falcon-init: installed build $inst_build is newer than packaged $pkg_build, skipping rsync" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| need_sync=false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using external We can make this much more robust and efficient by using Bash's built-in regular expression matching (
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider logging the detected builds unconditionally (e.g. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$need_sync" = true ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Update binaries from the nix store, but preserve runtime state files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # falconstore contains the Agent ID (AID) - if lost, the sensor re-registers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # as a new host and consumes another license seat. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @rsync@/bin/rsync -a --delete \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --exclude=falconstore \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --exclude=falconstore.bak \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --exclude=CsConfig \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "@falcon@/opt/CrowdStrike/" /opt/CrowdStrike/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| chown -R root:root /opt/CrowdStrike | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
pkg_ver/installed_verare misleading — they're paths tofalconctl, not version strings. Renaming topkg_path/installed_pathwould line up with thepkg_build/inst_buildvariables that do hold versions.