Skip to content

Commit

Permalink
Enable osquery watchdog for nightly use (#1374)
Browse files Browse the repository at this point in the history
Co-authored-by: seph <seph@kolide.co>
  • Loading branch information
RebeccaMahany and directionless authored Oct 5, 2023
1 parent 220f185 commit 29bc19e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cmd/launcher/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ func commonRunnerOptions(logger log.Logger, k types.Knapsack) []runtime.OsqueryI
kolidelog.WithKeyValue("osqlevel", "stdout"),
)

// Only enable watchdog internally for now
enableWatchdog := k.UpdateChannel() == "nightly"

return []runtime.OsqueryInstanceOption{
runtime.WithKnapsack(k),
runtime.WithOsquerydBinary(k.OsquerydPath()),
Expand All @@ -223,6 +226,7 @@ func commonRunnerOptions(logger log.Logger, k types.Knapsack) []runtime.OsqueryI
runtime.WithAutoloadedExtensions(k.AutoloadedExtensions()...),
runtime.WithUpdateDirectory(k.UpdateDirectory()),
runtime.WithUpdateChannel(k.UpdateChannel()),
runtime.WithEnableWatchdog(enableWatchdog),
}
}

Expand Down
18 changes: 15 additions & 3 deletions pkg/osquery/runtime/osqueryinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func WithUpdateChannel(channel string) OsqueryInstanceOption {
}
}

func WithEnableWatchdog(enableWatchdog bool) OsqueryInstanceOption {
return func(i *OsqueryInstance) {
i.opts.enableWatchdog = enableWatchdog
}
}

// WithExtensionSocketPath is a functional option which allows the user to
// define the path of the extension socket path that osqueryd will open to
// communicate with other processes.
Expand Down Expand Up @@ -318,6 +324,7 @@ type osqueryOptions struct {
distributedPluginFlag string
extensionPlugins []osquery.OsqueryPlugin
autoloadedExtensions []string
enableWatchdog bool
extensionSocketPath string
enrollSecretPath string
loggerPluginFlag string
Expand Down Expand Up @@ -460,17 +467,22 @@ func calculateOsqueryPaths(opts osqueryOptions) (*osqueryFilePaths, error) {
// which will launch a properly configured osqueryd process.
func (opts *osqueryOptions) createOsquerydCommand(osquerydBinary string, paths *osqueryFilePaths) (*exec.Cmd, error) {
// Create the reference instance for the running osquery instance
cmd := exec.Command(
osquerydBinary,
args := []string{
fmt.Sprintf("--logger_plugin=%s", opts.loggerPluginFlag),
fmt.Sprintf("--distributed_plugin=%s", opts.distributedPluginFlag),
"--disable_distributed=false",
"--distributed_interval=5",
"--pack_delimiter=:",
"--host_identifier=uuid",
"--force=true",
"--disable_watchdog",
"--utc",
}
if !opts.enableWatchdog {
args = append(args, "--disable_watchdog")
}
cmd := exec.Command(
osquerydBinary,
args...,
)

if opts.verbose {
Expand Down

0 comments on commit 29bc19e

Please sign in to comment.