Skip to content

Commit

Permalink
Move key creation to runLauncher (#1924)
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany authored Oct 29, 2024
1 parent bfc42f4 commit 69277cb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 117 deletions.
8 changes: 8 additions & 0 deletions cmd/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,14 @@ func runLauncher(ctx context.Context, cancel func(), multiSlogger, systemMultiSl
}
}

// make sure keys exist -- we expect these keys to exist before rungroup starts
if err := osquery.SetupLauncherKeys(k.ConfigStore()); err != nil {
return fmt.Errorf("setting up initial launcher keys: %w", err)
}
if err := agent.SetupKeys(ctx, k.Slogger(), k.ConfigStore(), false); err != nil {
return fmt.Errorf("setting up agent keys: %w", err)
}

// init osquery instance history
if err := osqueryInstanceHistory.InitHistory(k.OsqueryHistoryInstanceStore()); err != nil {
return fmt.Errorf("error initializing osquery instance history: %w", err)
Expand Down
12 changes: 0 additions & 12 deletions pkg/osquery/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"time"

"github.com/google/uuid"
"github.com/kolide/launcher/ee/agent"
"github.com/kolide/launcher/ee/agent/startupsettings"
"github.com/kolide/launcher/ee/agent/types"
"github.com/kolide/launcher/ee/uninstall"
Expand Down Expand Up @@ -92,9 +91,6 @@ type ExtensionOpts struct {
// RunDifferentialQueriesImmediately allows the client to execute a new query the first time it sees it,
// bypassing the scheduler.
RunDifferentialQueriesImmediately bool
// skipHardwareKeysSetup is a flag to indicate if we should skip setting up hardware keys.
// This is useful for testing environments where we don't have required hardware.
skipHardwareKeysSetup bool
}

type iterationTerminatedError struct{}
Expand Down Expand Up @@ -130,14 +126,6 @@ func NewExtension(ctx context.Context, client service.KolideService, k types.Kna

configStore := k.ConfigStore()

if err := SetupLauncherKeys(configStore); err != nil {
return nil, fmt.Errorf("setting up initial launcher keys: %w", err)
}

if err := agent.SetupKeys(ctx, slogger, configStore, opts.skipHardwareKeysSetup); err != nil {
return nil, fmt.Errorf("setting up agent keys: %w", err)
}

nodekey, err := NodeKey(configStore)
if err != nil {
slogger.Log(ctx, slog.LevelDebug,
Expand Down
Loading

0 comments on commit 69277cb

Please sign in to comment.