From 0ef9c4be8dc95a59d92028e69364ad9f332fed66 Mon Sep 17 00:00:00 2001 From: Micah-Kolide Date: Wed, 11 Sep 2024 15:47:34 -0700 Subject: [PATCH 1/2] Update macos autoupdate managed --- ee/tables/macos_software_update/SUSharedPrefs.h | 2 +- ee/tables/macos_software_update/software_update_table.go | 6 +++--- ee/tables/macos_software_update/sus.h | 2 +- ee/tables/macos_software_update/sus.m | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ee/tables/macos_software_update/SUSharedPrefs.h b/ee/tables/macos_software_update/SUSharedPrefs.h index 373ea024e..f7646fd7a 100644 --- a/ee/tables/macos_software_update/SUSharedPrefs.h +++ b/ee/tables/macos_software_update/SUSharedPrefs.h @@ -62,6 +62,7 @@ - (BOOL)bridgeOSUpdatesEnabled; - (BOOL)skipAPFSSnapshotting; - (BOOL)doesAllowBGStageWithoutInactivity; +- (BOOL)isMacOSAutoUpdateManaged; - (BOOL)isAutomaticallyCheckForUpdatesManaged; - (BOOL)isAutomaticallyCheckForUpdatesEnabled; - (BOOL)adminDeferredInstallEnabled; @@ -108,4 +109,3 @@ - (void)reloadPreferences; @end - diff --git a/ee/tables/macos_software_update/software_update_table.go b/ee/tables/macos_software_update/software_update_table.go index e39bff50e..457f1ed28 100644 --- a/ee/tables/macos_software_update/software_update_table.go +++ b/ee/tables/macos_software_update/software_update_table.go @@ -49,7 +49,7 @@ func (table *osUpdateTable) generateMacUpdate(ctx context.Context, queryContext } var ( version = C.int(table.macOSBuildVersionPrefix) - isAutomaticallyCheckForUpdatesManaged = C.int(0) + isMacOSAutoUpdateManaged = C.int(0) isAutomaticallyCheckForUpdatesEnabled = C.int(0) doesBackgroundDownload = C.int(0) doesAppStoreAutoUpdates = C.int(0) @@ -59,7 +59,7 @@ func (table *osUpdateTable) generateMacUpdate(ctx context.Context, queryContext ) C.getSoftwareUpdateConfiguration( version, - &isAutomaticallyCheckForUpdatesManaged, + &isMacOSAutoUpdateManaged, &isAutomaticallyCheckForUpdatesEnabled, &doesBackgroundDownload, &doesAppStoreAutoUpdates, @@ -70,7 +70,7 @@ func (table *osUpdateTable) generateMacUpdate(ctx context.Context, queryContext resp := []map[string]string{ { - "autoupdate_managed": fmt.Sprintf("%d", isAutomaticallyCheckForUpdatesManaged), + "autoupdate_managed": fmt.Sprintf("%d", isMacOSAutoUpdateManaged), "autoupdate_enabled": fmt.Sprintf("%d", isAutomaticallyCheckForUpdatesEnabled), "download": fmt.Sprintf("%d", doesBackgroundDownload), "app_updates": fmt.Sprintf("%d", doesAppStoreAutoUpdates), diff --git a/ee/tables/macos_software_update/sus.h b/ee/tables/macos_software_update/sus.h index d4c115e60..dd8129bdd 100644 --- a/ee/tables/macos_software_update/sus.h +++ b/ee/tables/macos_software_update/sus.h @@ -7,7 +7,7 @@ extern void productNestedKeyValueFound(unsigned int, char*, char*, char*); // Gets software update config flags from SUSharedPrefs API void getSoftwareUpdateConfiguration(int os_version, - int* isAutomaticallyCheckForUpdatesManaged, + int* isMacOSAutoUpdateManaged, int* isAutomaticallyCheckForUpdatesEnabled, int* doesBackgroundDownload, int* doesAppStoreAutoUpdates, diff --git a/ee/tables/macos_software_update/sus.m b/ee/tables/macos_software_update/sus.m index 80bf248f8..cbf41795d 100644 --- a/ee/tables/macos_software_update/sus.m +++ b/ee/tables/macos_software_update/sus.m @@ -6,7 +6,7 @@ #import void getSoftwareUpdateConfiguration(int os_version, - int* isAutomaticallyCheckForUpdatesManaged, + int* isMacOSAutoUpdateManaged, int* isAutomaticallyCheckForUpdatesEnabled, int* doesBackgroundDownload, int* doesAppStoreAutoUpdates, @@ -22,9 +22,9 @@ void getSoftwareUpdateConfiguration(int os_version, Class SUSharedPrefs = [bundle classNamed:@"SUSharedPrefs"]; id manager = [SUSharedPrefs sharedPrefManager]; - BOOL val = [manager isAutomaticallyCheckForUpdatesManaged]; + BOOL val = [manager isMacOSAutoUpdateManaged]; if (val) { - *isAutomaticallyCheckForUpdatesManaged = 1; + *isMacOSAutoUpdateManaged = 1; } val = [manager isAutomaticallyCheckForUpdatesEnabled]; From 38c3035c2a041776791b91dac553970f1f546d15 Mon Sep 17 00:00:00 2001 From: Micah-Kolide Date: Wed, 11 Sep 2024 16:29:46 -0700 Subject: [PATCH 2/2] Re-add deprecated property --- ee/tables/macos_software_update/software_update_table.go | 4 +++- ee/tables/macos_software_update/sus.h | 1 + ee/tables/macos_software_update/sus.m | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ee/tables/macos_software_update/software_update_table.go b/ee/tables/macos_software_update/software_update_table.go index 457f1ed28..5b3a7901a 100644 --- a/ee/tables/macos_software_update/software_update_table.go +++ b/ee/tables/macos_software_update/software_update_table.go @@ -50,6 +50,7 @@ func (table *osUpdateTable) generateMacUpdate(ctx context.Context, queryContext var ( version = C.int(table.macOSBuildVersionPrefix) isMacOSAutoUpdateManaged = C.int(0) + isAutomaticallyCheckForUpdatesManaged = C.int(0) isAutomaticallyCheckForUpdatesEnabled = C.int(0) doesBackgroundDownload = C.int(0) doesAppStoreAutoUpdates = C.int(0) @@ -60,6 +61,7 @@ func (table *osUpdateTable) generateMacUpdate(ctx context.Context, queryContext C.getSoftwareUpdateConfiguration( version, &isMacOSAutoUpdateManaged, + &isAutomaticallyCheckForUpdatesManaged, &isAutomaticallyCheckForUpdatesEnabled, &doesBackgroundDownload, &doesAppStoreAutoUpdates, @@ -70,7 +72,7 @@ func (table *osUpdateTable) generateMacUpdate(ctx context.Context, queryContext resp := []map[string]string{ { - "autoupdate_managed": fmt.Sprintf("%d", isMacOSAutoUpdateManaged), + "autoupdate_managed": fmt.Sprintf("%d", max(isMacOSAutoUpdateManaged, isAutomaticallyCheckForUpdatesManaged)), "autoupdate_enabled": fmt.Sprintf("%d", isAutomaticallyCheckForUpdatesEnabled), "download": fmt.Sprintf("%d", doesBackgroundDownload), "app_updates": fmt.Sprintf("%d", doesAppStoreAutoUpdates), diff --git a/ee/tables/macos_software_update/sus.h b/ee/tables/macos_software_update/sus.h index dd8129bdd..68cdfa025 100644 --- a/ee/tables/macos_software_update/sus.h +++ b/ee/tables/macos_software_update/sus.h @@ -8,6 +8,7 @@ extern void productNestedKeyValueFound(unsigned int, char*, char*, char*); // Gets software update config flags from SUSharedPrefs API void getSoftwareUpdateConfiguration(int os_version, int* isMacOSAutoUpdateManaged, + int* isAutomaticallyCheckForUpdatesManaged, int* isAutomaticallyCheckForUpdatesEnabled, int* doesBackgroundDownload, int* doesAppStoreAutoUpdates, diff --git a/ee/tables/macos_software_update/sus.m b/ee/tables/macos_software_update/sus.m index cbf41795d..f7e050288 100644 --- a/ee/tables/macos_software_update/sus.m +++ b/ee/tables/macos_software_update/sus.m @@ -7,6 +7,7 @@ void getSoftwareUpdateConfiguration(int os_version, int* isMacOSAutoUpdateManaged, + int* isAutomaticallyCheckForUpdatesManaged, int* isAutomaticallyCheckForUpdatesEnabled, int* doesBackgroundDownload, int* doesAppStoreAutoUpdates, @@ -27,6 +28,11 @@ void getSoftwareUpdateConfiguration(int os_version, *isMacOSAutoUpdateManaged = 1; } + val = [manager isAutomaticallyCheckForUpdatesManaged]; + if (val) { + *isAutomaticallyCheckForUpdatesManaged = 1; + } + val = [manager isAutomaticallyCheckForUpdatesEnabled]; if (val) { *isAutomaticallyCheckForUpdatesEnabled = 1;