From 000258631b76f68429560d27ee5e894b8ecc20c9 Mon Sep 17 00:00:00 2001 From: zack olson Date: Fri, 16 Aug 2024 14:34:43 -0400 Subject: [PATCH] only write out identifier to flags file if non-default --- pkg/launcher/options.go | 4 ++-- pkg/launcher/options_test.go | 2 +- pkg/packaging/packaging.go | 9 ++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/launcher/options.go b/pkg/launcher/options.go index 7d2b71e00..3b5b7f3ce 100644 --- a/pkg/launcher/options.go +++ b/pkg/launcher/options.go @@ -17,7 +17,7 @@ import ( "github.com/peterbourgon/ff/v3" ) -const defaultLauncherIdentifier string = "kolide-k2" +const DefaultLauncherIdentifier string = "kolide-k2" // Options is the set of options that may be configured for Launcher. type Options struct { @@ -259,7 +259,7 @@ func ParseOptions(subcommandName string, args []string) (*Options, error) { flIAmBreakingEELicense = flagset.Bool("i-am-breaking-ee-license", false, "Skip license check before running localserver (default: false)") flDelayStart = flagset.Duration("delay_start", 0*time.Second, "How much time to wait before starting launcher") flLocalDevelopmentPath = flagset.String("localdev_path", "", "Path to local launcher build") - flPackageIdentifier = flagset.String("identifier", defaultLauncherIdentifier, "packaging identifier used to determine service names, paths, etc. (default: kolide-k2)") + flPackageIdentifier = flagset.String("identifier", DefaultLauncherIdentifier, "packaging identifier used to determine service names, paths, etc. (default: kolide-k2)") // deprecated options, kept for any kind of config file compatibility _ = flagset.String("debug_log_file", "", "DEPRECATED") diff --git a/pkg/launcher/options_test.go b/pkg/launcher/options_test.go index c8dadf3bf..3146f6c81 100644 --- a/pkg/launcher/options_test.go +++ b/pkg/launcher/options_test.go @@ -265,7 +265,7 @@ func getArgsAndResponse() (map[string]string, *Options) { WatchdogDelaySec: 120, WatchdogMemoryLimitMB: 600, WatchdogUtilizationLimitPercent: 50, - Identifier: defaultLauncherIdentifier, + Identifier: DefaultLauncherIdentifier, } return args, opts diff --git a/pkg/packaging/packaging.go b/pkg/packaging/packaging.go index c10f55dd5..8a1027370 100644 --- a/pkg/packaging/packaging.go +++ b/pkg/packaging/packaging.go @@ -16,6 +16,7 @@ import ( "text/template" "github.com/kolide/kit/fsutil" + "github.com/kolide/launcher/pkg/launcher" "github.com/kolide/launcher/pkg/packagekit" "go.opencensus.io/trace" @@ -124,7 +125,13 @@ func (p *PackageOptions) Build(ctx context.Context, packageWriter io.Writer, tar "root_directory": p.canonicalizeRootDir(p.rootDir), "osqueryd_path": p.canonicalizePath(filepath.Join(p.binDir, "osqueryd")), "enroll_secret_path": p.canonicalizePath(filepath.Join(p.confDir, "secret")), - "identifier": p.Identifier, + } + + // to avoid writing additional flags without a real need (newly introduced flags + // can cause issues with rolling back), we only set the identifier in the flags file + // if it is not the default value + if p.Identifier != launcher.DefaultLauncherIdentifier { + launcherMapFlags["identifier"] = p.Identifier } launcherBoolFlags := []string{}