From c6e3207149cd66b32b199b107d8665d77d205c2d Mon Sep 17 00:00:00 2001 From: zackattack01 Date: Tue, 12 Nov 2024 14:14:44 -0500 Subject: [PATCH 1/2] add versionNum to windows registry on MSI install --- go.mod | 2 +- go.sum | 4 ++-- pkg/packagekit/assets/main.wxs | 1 + pkg/packagekit/package.go | 1 + pkg/packagekit/package_wix.go | 8 ++++++++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f8e2ebc14..394f0e650 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/gorilla/websocket v1.4.2 github.com/groob/plist v0.0.0-20190114192801-a99fbe489d03 github.com/knightsc/system_policy v1.1.1-0.20211029142728-5f4c0d5419cc - github.com/kolide/kit v0.0.0-20240411131714-94dd1939cf50 + github.com/kolide/kit v0.0.0-20241104170139-c647b1ab5279 github.com/kolide/krypto v0.1.1-0.20231229162826-db516b7e0121 github.com/mat/besticon v3.9.0+incompatible github.com/mattn/go-sqlite3 v1.14.19 diff --git a/go.sum b/go.sum index 1335f7765..fc9535927 100644 --- a/go.sum +++ b/go.sum @@ -174,8 +174,8 @@ github.com/kolide/go-ole v0.0.0-20241008210444-65130153c767 h1:kcLxfX6wdtztSwpgz github.com/kolide/go-ole v0.0.0-20241008210444-65130153c767/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/kolide/goleveldb v0.0.0-20240514204455-8d30cd4d31c6 h1:6/RKW8FQlrtaBeL7We3SdpdoiGZk3Pm5STXsSxbm9ho= github.com/kolide/goleveldb v0.0.0-20240514204455-8d30cd4d31c6/go.mod h1:zgOxCKTwS/xpJtz6LH60b3lZoQ30kqtc252N+SM4enc= -github.com/kolide/kit v0.0.0-20240411131714-94dd1939cf50 h1:N7RaYBPTK5o4y2z1z8kl/G3iAeP73QCfAUH4y39GRCc= -github.com/kolide/kit v0.0.0-20240411131714-94dd1939cf50/go.mod h1:pFbEKXFww1uqu4RRO7qCnUmQ2EIwKYRzUqpJbODNlfc= +github.com/kolide/kit v0.0.0-20241104170139-c647b1ab5279 h1:nFN/UwsX1OuTgekQWuynr1SwWlcPT8t1iNtjtm81sMA= +github.com/kolide/kit v0.0.0-20241104170139-c647b1ab5279/go.mod h1:pFbEKXFww1uqu4RRO7qCnUmQ2EIwKYRzUqpJbODNlfc= github.com/kolide/krypto v0.1.1-0.20231229162826-db516b7e0121 h1:f7APX9VNsCkD/tdlAjbU4A22FyfTOCF6QadlvnzZElg= github.com/kolide/krypto v0.1.1-0.20231229162826-db516b7e0121/go.mod h1:/0sxd3OIxciTlMTeZI/9WTaUHsx/K/+3f+NbD5dywTY= github.com/kolide/systray v1.10.5-0.20241021175748-13aef6380bdb h1:d2pfEh5Yd6+C+D096YQlHwcq28TPOjoeoG+lCQojkJM= diff --git a/pkg/packagekit/assets/main.wxs b/pkg/packagekit/assets/main.wxs index 1238c979e..8d31ac1f1 100644 --- a/pkg/packagekit/assets/main.wxs +++ b/pkg/packagekit/assets/main.wxs @@ -57,6 +57,7 @@ + diff --git a/pkg/packagekit/package.go b/pkg/packagekit/package.go index 7198bf3cc..bd88b6d99 100644 --- a/pkg/packagekit/package.go +++ b/pkg/packagekit/package.go @@ -9,6 +9,7 @@ type PackageOptions struct { Root string // source directory to package Scripts string // directory of packaging scripts (postinst, prerm, etc) Version string // package version + VersionNum int // package version in numeric format. used to create comparable windows registry keys FlagFile string // Path to the flagfile for configuration DisableService bool // Whether to install a system service in a disabled state diff --git a/pkg/packagekit/package_wix.go b/pkg/packagekit/package_wix.go index 01fb5d1d4..e5c78b14c 100644 --- a/pkg/packagekit/package_wix.go +++ b/pkg/packagekit/package_wix.go @@ -16,6 +16,7 @@ import ( "text/template" "github.com/google/uuid" + "github.com/kolide/kit/version" "github.com/kolide/launcher/pkg/packagekit/authenticode" "github.com/kolide/launcher/pkg/packagekit/wix" "golang.org/x/text/cases" @@ -52,6 +53,13 @@ func PackageWixMSI(ctx context.Context, w io.Writer, po *PackageOptions, include return err } + // populate VersionNum if it isn't already set by the caller. we'll + // store this in the registry on install to give a comparable field + // for intune to drive upgrade behavior from + if po.VersionNum == 0 { + po.VersionNum = version.VersionNum() + } + // We include a random nonce as part of the ProductCode // guid. This is so that any MSI rebuild triggers the Major // Upgrade flow, and not the "Another version of this product From 6ac1831b125656d8c9b8d79978044b514b6a4dd1 Mon Sep 17 00:00:00 2001 From: zackattack01 Date: Tue, 12 Nov 2024 15:27:22 -0500 Subject: [PATCH 2/2] update registry key name --- pkg/packagekit/assets/main.wxs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/packagekit/assets/main.wxs b/pkg/packagekit/assets/main.wxs index 8d31ac1f1..7a93d0285 100644 --- a/pkg/packagekit/assets/main.wxs +++ b/pkg/packagekit/assets/main.wxs @@ -57,7 +57,7 @@ - +