GODT-1795: fix automatic installation of profile for AppleMail on macOS Ventura beta (qt 5).

This commit is contained in:
Xavier Michelon
2022-08-25 11:02:16 +02:00
committed by Jakub Cuth
parent b3f8866ef7
commit 0d25c607e7
2 changed files with 17 additions and 4 deletions

View File

@ -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" {

View File

@ -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