diff --git a/changes/49260-swupdate b/changes/49260-swupdate new file mode 100644 index 0000000000..e10293cbce --- /dev/null +++ b/changes/49260-swupdate @@ -0,0 +1 @@ +* Fixed an issue where devices given a mandatory update during ADE enrollment might display a failure or fail to display the update diff --git a/server/fleet/apple_mdm.go b/server/fleet/apple_mdm.go index dd4e809801..b185b705f6 100644 --- a/server/fleet/apple_mdm.go +++ b/server/fleet/apple_mdm.go @@ -1379,10 +1379,15 @@ const MDMAppleSoftwareUpdateRequiredCode = "com.apple.softwareupdate.required" // MDMAppleSoftwareUpdateRequiredDetails is the [details][1] specified by Apple for the // required software update. // +// Apple's schema also defines an optional BuildVersion key, but we deliberately omit it: +// GDMF often publishes multiple concurrent builds of the same OS version that all list the +// same device, and pinning a build the device's software update client won't resolve makes +// the mandatory update fail during Setup Assistant. Sending only OSVersion lets the device +// pick the right build. +// // [1]: https://developer.apple.com/documentation/devicemanagement/errorcodesoftwareupdaterequired/details type MDMAppleSoftwareUpdateRequiredDetails struct { - OSVersion string `json:"OSVersion"` - BuildVersion string `json:"BuildVersion"` + OSVersion string `json:"OSVersion"` } // MDMAppleSoftwareUpdateRequired is the [error response][1] specified by Apple to indicate that the device @@ -1394,18 +1399,13 @@ type MDMAppleSoftwareUpdateRequired struct { Details MDMAppleSoftwareUpdateRequiredDetails `json:"details"` } -func NewMDMAppleSoftwareUpdateRequired(asset MDMAppleSoftwareUpdateAsset) *MDMAppleSoftwareUpdateRequired { +func NewMDMAppleSoftwareUpdateRequired(osVersion string) *MDMAppleSoftwareUpdateRequired { return &MDMAppleSoftwareUpdateRequired{ Code: MDMAppleSoftwareUpdateRequiredCode, - Details: MDMAppleSoftwareUpdateRequiredDetails{OSVersion: asset.ProductVersion, BuildVersion: asset.Build}, + Details: MDMAppleSoftwareUpdateRequiredDetails{OSVersion: osVersion}, } } -type MDMAppleSoftwareUpdateAsset struct { - ProductVersion string `json:"ProductVersion"` - Build string `json:"Build"` -} - type MDMManagedCertificate struct { ProfileUUID string `db:"profile_uuid"` HostUUID string `db:"host_uuid"` diff --git a/server/service/apple_mdm.go b/server/service/apple_mdm.go index 483330eb67..75ff32efa7 100644 --- a/server/service/apple_mdm.go +++ b/server/service/apple_mdm.go @@ -2736,10 +2736,7 @@ func (svc *Service) getAppleSoftwareUpdateRequiredForDEPEnrollment(m fleet.MDMAp return nil, nil } - return fleet.NewMDMAppleSoftwareUpdateRequired(fleet.MDMAppleSoftwareUpdateAsset{ - ProductVersion: latest.ProductVersion, - Build: latest.Build, - }), nil + return fleet.NewMDMAppleSoftwareUpdateRequired(latest.ProductVersion), nil } // enqueueMDMAppleCommandRemoveEnrollmentProfile enqueues a RemoveProfile MDM command for the given host. diff --git a/server/service/apple_mdm_test.go b/server/service/apple_mdm_test.go index 925121823b..089070053b 100644 --- a/server/service/apple_mdm_test.go +++ b/server/service/apple_mdm_test.go @@ -6712,10 +6712,7 @@ func TestCheckMDMAppleEnrollmentWithMinimumOSVersion(t *testing.T) { dev_mode.SetOverride("FLEET_DEV_GDMF_URL", gdmf.URL, t) latestMacOSVersion := "14.6.1" - latestMacOSBuild := "23G93" - latestIOSVersion := "17.6.1" - latestIOSBuild := "21G93" testCases := []struct { name string @@ -6755,8 +6752,7 @@ func TestCheckMDMAppleEnrollmentWithMinimumOSVersion(t *testing.T) { SoftwareUpdateDeviceID: "J516sAP", }, updateRequired: &fleet.MDMAppleSoftwareUpdateRequiredDetails{ - OSVersion: latestMacOSVersion, - BuildVersion: latestMacOSBuild, + OSVersion: latestMacOSVersion, }, }, { @@ -6846,8 +6842,7 @@ func TestCheckMDMAppleEnrollmentWithMinimumOSVersion(t *testing.T) { var details *fleet.MDMAppleSoftwareUpdateRequiredDetails if tt.updateRequired != nil { details = &fleet.MDMAppleSoftwareUpdateRequiredDetails{ - OSVersion: latestIOSVersion, - BuildVersion: latestIOSBuild, + OSVersion: latestIOSVersion, } } diff --git a/server/service/integration_mdm_dep_test.go b/server/service/integration_mdm_dep_test.go index 7a864803a6..ec4ddcc92d 100644 --- a/server/service/integration_mdm_dep_test.go +++ b/server/service/integration_mdm_dep_test.go @@ -2335,7 +2335,6 @@ func (s *integrationMDMTestSuite) TestEnforceMiniumOSVersion() { s.enableABM(t.Name()) latestMacOSVersion := "14.6.1" // this is the latest version in our test data (see ../mdm/apple/gdmf/testdata/gdmf.json) - latestMacOSBuild := "23G93" // this is the latest version in our test data (see ../mdm/apple/gdmf/testdata/gdmf.json) deadline := "2023-12-31" scepChallenge := "scepcha/>