Permalink
Browse files

Explicitly clear softwareupdate's LastSessionSuccessful value before …

…checking for updates to minimize false reports of unsuccessful sessions.
  • Loading branch information...
gregneagle committed Mar 28, 2018
1 parent 332212b commit e1f5f0204b73a8dc74775b9cbc5cd0ae54728340
Showing with 16 additions and 0 deletions.
  1. +3 −0 code/client/munkilib/appleupdates/au.py
  2. +13 −0 code/client/munkilib/appleupdates/su_prefs.py
@@ -143,6 +143,9 @@ def download_available_updates(self):
else:
catalog_url = self.applesync.get_apple_catalogurl()

# before we call softwareupdate,
# clear stored value for LastSessionSuccessful
su_prefs.set_pref('LastSessionSuccessful', None)
retcode = self._run_softwareupdate(
['-d', '-a'], catalog_url=catalog_url, stop_allowed=True)
if retcode: # there was an error
@@ -59,6 +59,19 @@ def pref(pref_name):
pref_name, APPLE_SOFTWARE_UPDATE_PREFS_DOMAIN)


def set_pref(pref_name, value):
"""Sets a value in /Library/Preferences/com.apple.SoftwareUpdate.
Uses CoreFoundation.
Args:
pref_name: str preference name to set.
valueL value to set it to.
"""
CFPreferencesSetValue(
pref_name, value,
APPLE_SOFTWARE_UPDATE_PREFS_DOMAIN,
kCFPreferencesAnyUser, kCFPreferencesCurrentHost)


def catalogurl_is_managed():
"""Returns True if Software Update's CatalogURL is managed
via MCX or Profiles"""

0 comments on commit e1f5f02

Please sign in to comment.