diff --git a/orbit/pkg/packaging/packaging.go b/orbit/pkg/packaging/packaging.go index 05d0995805..756a85359d 100644 --- a/orbit/pkg/packaging/packaging.go +++ b/orbit/pkg/packaging/packaging.go @@ -117,6 +117,8 @@ type Options struct { LocalWixDir string // HostIdentifier is the host identifier to use in osquery. HostIdentifier string + // EnableHostIdentifierProperty is a boolean indicating whether to enable END_USER_EMAIL property in Windows MSI package. + EnableEndUserEmailProperty bool // EndUserEmail is the email address of the end user that uses the host on // which the agent is going to be installed. EndUserEmail string diff --git a/orbit/pkg/packaging/windows.go b/orbit/pkg/packaging/windows.go index fad9fc4e1c..e32eeaca6f 100644 --- a/orbit/pkg/packaging/windows.go +++ b/orbit/pkg/packaging/windows.go @@ -24,6 +24,7 @@ import ( "github.com/fleetdm/fleet/v4/pkg/secure" "github.com/josephspurrier/goversioninfo" "github.com/rs/zerolog/log" + "golang.org/x/mod/semver" ) const wixDownload = "https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip" @@ -87,6 +88,15 @@ func BuildMSI(opt Options) (string, error) { opt.Version = updatesData.OrbitVersion } + orbitVersion := updatesData.OrbitVersion + if !strings.HasPrefix(orbitVersion, "v") { + orbitVersion = "v" + orbitVersion + } + // v1.28.0 introduced configurable END_USER_EMAIL property for MSI package: https://github.com/fleetdm/fleet/issues/19219 + if semver.Compare(orbitVersion, "v1.28.0") >= 0 { + opt.EnableEndUserEmailProperty = true + } + // Write files if err := writeSecret(opt, orbitRoot); err != nil { diff --git a/orbit/pkg/packaging/windows_templates.go b/orbit/pkg/packaging/windows_templates.go index 5a6106e4c1..70fd998b45 100644 --- a/orbit/pkg/packaging/windows_templates.go +++ b/orbit/pkg/packaging/windows_templates.go @@ -58,7 +58,13 @@ var windowsWixTemplate = template.Must(template.New("").Option("missingkey=error - + {{ $endUserEmailArg := "" }} + {{ if .EnableEndUserEmailProperty }} + + {{ $endUserEmailArg = " --end-user-email=\"[END_USER_EMAIL]\"" }} + {{ else if .EndUserEmail }} + {{ $endUserEmailArg = printf " --end-user-email \"%s\"" .EndUserEmail }} + {{ end }} @@ -102,7 +108,7 @@ var windowsWixTemplate = template.Must(template.New("").Option("missingkey=error Start="auto" Type="ownProcess" Description="This service runs Fleet's osquery runtime and autoupdater (Orbit)." - Arguments='--root-dir "[ORBITROOT]." --log-file "[System64Folder]config\systemprofile\AppData\Local\FleetDM\Orbit\Logs\orbit-osquery.log" --fleet-url "[FLEET_URL]"{{ if .FleetCertificate }} --fleet-certificate "[ORBITROOT]fleet.pem"{{ end }}{{ if .EnrollSecret }} --enroll-secret-path "[ORBITROOT]secret.txt"{{ end }}{{if .Insecure }} --insecure{{ end }}{{ if .Debug }} --debug{{ end }}{{ if .UpdateURL }} --update-url "{{ .UpdateURL }}"{{ end }}{{ if .UpdateTLSServerCertificate }} --update-tls-certificate "[ORBITROOT]update.pem"{{ end }}{{ if .DisableUpdates }} --disable-updates{{ end }} --fleet-desktop="[FLEET_DESKTOP]" --desktop-channel {{ .DesktopChannel }}{{ if .FleetDesktopAlternativeBrowserHost }} --fleet-desktop-alternative-browser-host {{ .FleetDesktopAlternativeBrowserHost }}{{ end }} --orbit-channel "{{ .OrbitChannel }}" --osqueryd-channel "{{ .OsquerydChannel }}" --enable-scripts="[ENABLE_SCRIPTS]" {{ if and (ne .HostIdentifier "") (ne .HostIdentifier "uuid") }}--host-identifier={{ .HostIdentifier }}{{ end }} --end-user-email "[END_USER_EMAIL]"{{ if .OsqueryDB }} --osquery-db="{{ .OsqueryDB }}"{{ end }}' + Arguments='--root-dir "[ORBITROOT]." --log-file "[System64Folder]config\systemprofile\AppData\Local\FleetDM\Orbit\Logs\orbit-osquery.log" --fleet-url "[FLEET_URL]"{{ if .FleetCertificate }} --fleet-certificate "[ORBITROOT]fleet.pem"{{ end }}{{ if .EnrollSecret }} --enroll-secret-path "[ORBITROOT]secret.txt"{{ end }}{{if .Insecure }} --insecure{{ end }}{{ if .Debug }} --debug{{ end }}{{ if .UpdateURL }} --update-url "{{ .UpdateURL }}"{{ end }}{{ if .UpdateTLSServerCertificate }} --update-tls-certificate "[ORBITROOT]update.pem"{{ end }}{{ if .DisableUpdates }} --disable-updates{{ end }} --fleet-desktop="[FLEET_DESKTOP]" --desktop-channel {{ .DesktopChannel }}{{ if .FleetDesktopAlternativeBrowserHost }} --fleet-desktop-alternative-browser-host {{ .FleetDesktopAlternativeBrowserHost }}{{ end }} --orbit-channel "{{ .OrbitChannel }}" --osqueryd-channel "{{ .OsquerydChannel }}" --enable-scripts="[ENABLE_SCRIPTS]" {{ if and (ne .HostIdentifier "") (ne .HostIdentifier "uuid") }}--host-identifier={{ .HostIdentifier }}{{ end }}{{ $endUserEmailArg }}{{ if .OsqueryDB }} --osquery-db="{{ .OsqueryDB }}"{{ end }}' >