Repository navigation
Restart osctrld on every platform - #25
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restart osqueryd on every platform, run the service as root, harden extensions and HTTP
Two changes, one per repo, make an operator's flag edits in osctrl reach osquery on every node. jmpsec/osctrl#1089 makes the server serve the flags operators actually edit. This PR makes osctrld apply them on every platform: it writes the flagfile and restarts osqueryd. It builds on #24, which aligned osctrld's requests with the current server.
Server side: jmpsec/osctrl#1089
Before #1089, osctrl's osctrld endpoints served a freshly generated default flag set, so an operator's edits to an environment's flags never reached nodes managed by osctrld.
FlagsHandlerandVerifyHandlernow use the newNodeFlags. It serves the environment's stored, operator-edited flags with the secret and certificate paths filled in. Environments with no stored flags still get the generated defaults.FillFlagPathsis shared. It replaces__SECRET_FILE__and__CERT_FILE__; an empty path keeps its placeholder, the same as the generated flags. osctrl-api's per-platform flag substitution now uses it too.verifyno longer reports a mismatch against defaults nobody deployed.osctrld_flags_test.gocovers four cases: stored flags are served with paths filled, placeholders are kept when no paths are given, generated flags are the fallback when nothing is stored, and a wrong secret is rejected.Client side: this PR (osctrld)
Problems
systemctl, so hosts without systemd never applied new flags.installalready managed the service through the Windows service manager./opt/osctrld, but the deb, rpm and apk packages install to/usr/bin/osctrld.User=osctrld, which can't write/etc/osqueryor restart osqueryd, the daemon's whole job./path/to/placeholders.filepath.Join, so a manifest entry named../xcould write anywhere the daemon can.Changes
systemctl, thenservice, then/etc/init.d/osqueryd, the same chaininstalluses for stop and start./usr/bin/osctrldas root afternetwork-online.target, and logs to journald./usr/local/bin/osctrldand logs to/var/log/osctrld.log./etc/osctrld/osctrld.yamlis installed0600, since it holds the osctrl secret. The README install steps match the packaged paths.Security and operational impact
/opt/osctrldper the old README must move the binary to/usr/bin/osctrldor edit the unit.Validation
go test ./cmd/osctrld/ -race: all 109 tests ran, 0 failuresgo vetandgolangci-lint run ./...forGOOS=darwin,linuxandwindows: clean, 0 issuesplutil -linton the plist: OKTestOsqueryRestartCandidates,TestRestartOsqueryDarwin,TestSyncExtensions_RejectsNamesOutsideTheDirectoryandTestSendRequestTimesOutpass.TestRestartOsqueryFallsBackWithoutSystemdis Linux-only; it runs in CI onubuntu-latestand skips on macOS.goreleaser check: the config is valid. The check still fails on the existingbrewsdeprecation, which this PR doesn't touch.