From 0d25c607e7adf28bf1dd644823d0b8fe3ee7b2b4 Mon Sep 17 00:00:00 2001 From: Xavier Michelon Date: Thu, 25 Aug 2022 11:02:16 +0200 Subject: [PATCH] GODT-1795: fix automatic installation of profile for AppleMail on macOS Ventura beta (qt 5). --- internal/config/useragent/platform.go | 10 ++++++++-- internal/frontend/clientconfig/config_applemail.go | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/internal/config/useragent/platform.go b/internal/config/useragent/platform.go index bf3bfafe..ebe77220 100644 --- a/internal/config/useragent/platform.go +++ b/internal/config/useragent/platform.go @@ -24,18 +24,24 @@ import ( "github.com/Masterminds/semver/v3" ) -// IsCatalinaOrNewer checks whether the host is MacOS Catalina 10.15.x or higher. +// IsCatalinaOrNewer checks whether the host is macOS Catalina 10.15.x or higher. func IsCatalinaOrNewer() bool { return isThisDarwinNewerOrEqual(getMinCatalina()) } -// IsBigSurOrNewer checks whether the host is MacOS BigSur 10.16.x or higher. +// IsBigSurOrNewer checks whether the host is macOS BigSur 10.16.x or higher. func IsBigSurOrNewer() bool { return isThisDarwinNewerOrEqual(getMinBigSur()) } +// IsVenturaOrNewer checks whether the host is macOS BigSur 13.x or higher. +func IsVenturaOrNewer() bool { + return isThisDarwinNewerOrEqual(getMinVentura()) +} + func getMinCatalina() *semver.Version { return semver.MustParse("19.0.0") } func getMinBigSur() *semver.Version { return semver.MustParse("20.0.0") } +func getMinVentura() *semver.Version { return semver.MustParse("22.0.0") } func isThisDarwinNewerOrEqual(minVersion *semver.Version) bool { if runtime.GOOS != "darwin" { diff --git a/internal/frontend/clientconfig/config_applemail.go b/internal/frontend/clientconfig/config_applemail.go index 58d2fd89..279ba8c0 100644 --- a/internal/frontend/clientconfig/config_applemail.go +++ b/internal/frontend/clientconfig/config_applemail.go @@ -36,7 +36,8 @@ import ( ) const ( - bigSurPreferncesPane = "/System/Library/PreferencePanes/Profiles.prefPane" + bigSurPreferencesPane = "/System/Library/PreferencePanes/Profiles.prefPane" + venturaPreferencesPane = "x-apple.systempreferences:com.apple.preferences.configurationprofiles" ) func init() { //nolint:gochecknoinit @@ -56,7 +57,13 @@ func (c *appleMail) Configure(imapPort, smtpPort int, imapSSL, smtpSSL bool, use } if useragent.IsBigSurOrNewer() { - return execabs.Command("open", bigSurPreferncesPane, confPath).Run() //nolint:gosec G204: open command is safe, mobileconfig is generated by us + prefPane := bigSurPreferencesPane + + if useragent.IsVenturaOrNewer() { + prefPane = venturaPreferencesPane + } + + return execabs.Command("open", prefPane, confPath).Run() //nolint:gosec // G204 open command is safe, mobileconfig is generated by us } return execabs.Command("open", confPath).Run() //nolint:gosec G204: open command is safe, mobileconfig is generated by us