Ejemplo n.º 1
0
 def main(self):
     repo = self.env["MUNKI_REPO"]
     name = self.env["name"]
     opts = '-i %s' % (name, )
     force = self.env.get("force", False)
     # generate icons!
     generate_pngs_from_munki_items(repo, force=force, itemlist=[name])
     # clean up
     munkicommon.cleanUpTmpDir()
Ejemplo n.º 2
0
 def main(self):
     repo = self.env["MUNKI_REPO"]
     name = self.env["name"]
     opts = '-i %s' %(name,)
     force = self.env.get("force", False)
     # generate icons!
     generate_pngs_from_munki_items(repo, force=force,
         itemlist=[name])
     # clean up
     munkicommon.cleanUpTmpDir()
Ejemplo n.º 3
0
def RunPostflight(runtype):
    """Run the full postflight script."""
    # support enterprise/802.1x user-context wifi auth.
    # don't bother to perform postflight and exit OK immediately since there's no
    # network connection.
    if runtype == 'logoutinstall':
        sys.exit(0)


# Ensure MSU is installed to /Applications
    if not IsAppInPlace():
        flight_common.RepairClient()

    url = flight_common.GetServerURL()
    client = mac_client.SimianAuthClient(
        flight_common.GetClientIdentifier('auto')['uuid'], hostname=url)
    client.SetAuthToken(flight_common.GetAuth1Token())

    # read SecureConfig.plist.
    plist = munkicommon.SecureManagedInstallsPreferences()

    # Post client_id to server.
    client_id = flight_common.GetClientIdentifier(runtype)
    pkgs_to_install, apple_updates_to_install = (
        flight_common.GetRemainingPackagesToInstall())
    params = {
        'client_id': flight_common.DictToStr(client_id),
        'pkgs_to_install': pkgs_to_install,
        'apple_updates_to_install': apple_updates_to_install,
    }
    client.PostReport('postflight', params)

    # Report installs/etc to server.
    flight_common.UploadAllManagedInstallReports(
        client, client_id.get('on_corp', 'None'))

    if not client.LogoutAuthToken():
        logging.error('Logout failed')

    # expire auth token and remove cookie from plist.
    RemoveAuthTokenHeaderFromPlist(plist)

    # Delete the temp dir that munkicommon creates on import.
    munkicommon.cleanUpTmpDir()

    # Mark successful run by writing to last success file.
    NoteLastSuccess()

    logging.debug('Postflight completed successfully.')
Ejemplo n.º 4
0
def RunPostflight(runtype):
  """Run the full postflight script."""
  # support enterprise/802.1x user-context wifi auth.
  # don't bother to perform postflight and exit OK immediately since there's no
  # network connection.
  if runtype == 'logoutinstall':
    sys.exit(0)

# Ensure MSU is installed to /Applications
  if not IsAppInPlace():
    flight_common.RepairClient()

  url = flight_common.GetServerURL()
  client = mac_client.SimianAuthClient(
      flight_common.GetClientIdentifier('auto')['uuid'], hostname=url)
  client.SetAuthToken(flight_common.GetAuth1Token())

  # read SecureConfig.plist.
  plist = munkicommon.SecureManagedInstallsPreferences()

  # Post client_id to server.
  client_id = flight_common.GetClientIdentifier(runtype)
  pkgs_to_install, apple_updates_to_install = (
      flight_common.GetRemainingPackagesToInstall())
  params = {
      'client_id': flight_common.DictToStr(client_id),
      'pkgs_to_install': pkgs_to_install,
      'apple_updates_to_install': apple_updates_to_install,
  }
  client.PostReport('postflight', params)

  # Report installs/etc to server.
  flight_common.UploadAllManagedInstallReports(
      client, client_id.get('on_corp', 'None'))

  if not client.LogoutAuthToken():
    logging.error('Logout failed')

  # expire auth token and remove cookie from plist.
  RemoveAuthTokenHeaderFromPlist(plist)

  # Delete the temp dir that munkicommon creates on import.
  munkicommon.cleanUpTmpDir()

  # Mark successful run by writing to last success file.
  NoteLastSuccess()

  logging.debug('Postflight completed successfully.')
Ejemplo n.º 5
0
  # load user settings
  if user_settings:
    regular_config['UserSettings'] = user_settings
  else:
    if 'UserSettings' in regular_config:
      del regular_config['UserSettings']  # wipe existing UserSettings.

  # setup blank directory for capath setting
  path = CreateEmptyDirectory()
  regular_config['SoftwareRepoCAPath'] = path

  # enable MSU logging
  regular_config['MSULogEnabled'] = True


  # If setting is enabled, force Simian Apple SUS integration.
  if client_id.get('applesus'):
    regular_config['InstallAppleSoftwareUpdates'] = True
    # Get Apple Software Update Service catalog from server and set locally.
    flight_common.GetAppleSUSCatalog()

  # Report installs/etc to server.
  flight_common.UploadAllManagedInstallReports(
      client, client_id.get('on_corp', 'None'))

  # Delete the temp dir that munkicommon creates on import.
  munkicommon.cleanUpTmpDir()

  logging.debug('Preflight completed successfully.')
Ejemplo n.º 6
0
def RunPreflight(runtype, server_url=None):
  """Run the full Preflight script."""

  NoteLastRun()
  # support enterprise/802.1x user-context wifi auth.
  # don't bother to perform preflight and exit OK immediately since there's no
  # network connection.
  if runtype == 'logoutinstall':
    sys.exit(0)

  # load the NONSECURE ManagedInstalls.plist
  regular_config = munkicommon.ManagedInstallsPreferences()

  if server_url:
    regular_config['SoftwareRepoURL'] = server_url

  secure_config = munkicommon.SecureManagedInstallsPreferences()

  # update the ClientIdentifier key with the custom client id.
  client_id = flight_common.GetClientIdentifier(runtype)
  secure_config['ClientIdentifier'] = client_id['track']

  # load user settings
  try:
    user_settings = flight_common.GetUserSettings()
  except ValueError as e:
    logging.warning('User settings are malformed: %s', str(e))
    user_settings = {'__malformed': True}

  # If the munki exec is an auto run (launchd), exit if on WWAN or Android WAP.
  client_exit = None
  if runtype == 'auto':
    if network_detect.IsOnWwan():
      client_exit = 'WWAN device ppp0 is active'
    elif network_detect.IsOnAndroidWap():
      client_exit = 'Android WAP tether is active'
    elif network_detect.IsOnIosWap():
      client_exit = 'iOS WAP tether is active'
    elif network_detect.IsOnMifi():
      client_exit = 'MiFi tether is active'
    elif network_detect.IsOnBackoffWLAN():
      client_exit = 'Backoff WLAN SSID detected'

  # get a client auth token/cookie from the server, and post connection data.
  client, feedback = LoginToServer(
      secure_config, client_id, user_settings, client_exit)

  WriteRootCaCerts(client)

  if feedback.get('upload_logs'):
    # write new token/client_id headers to secure plist and upload logs.
    flight_common.UploadClientLogFiles(client)

  if feedback.get('pkill_installd'):
    # terminate any pending installations, like misbehaving Apple updates.
    flight_common.Pkill(process='installd', waitfor=2)

  if feedback.get('pkill_softwareupdated'):
    # terminate potentially hung softareupdated processes.
    flight_common.Pkill(process='softwareupdated', waitfor=2)

  if feedback.get('repair'):
    # write new token/client_id headers to secure plist and repair client.
    try:
      logging.info('Reinstalling Munki client....')
      flight_common.RepairClient()
      logging.info('Client successfully reinstalled.')
    except flight_common.RepairClientError as e:
      logging.exception(u'RepairClientError: %s', e)

  if feedback.get('logging_level'):
    regular_config['LoggingLevel'] = feedback.get('logging_level')
  else:
    regular_config['LoggingLevel'] = 1  # default to 1 if not set by server.

  if feedback.get('exit'):
    logging.warning('preflight received EXIT feedback from server; exiting....')
    sys.exit(STATUS_SERVER_EXIT_FEEDBACK[0])

  # post recent MSU logs
  logs = GetManagedSoftwareUpdateLogs()
  PostManagedSoftwareUpdateLogs(client, logs)

  # load user settings
  if user_settings:
    regular_config['UserSettings'] = user_settings
  else:
    if 'UserSettings' in regular_config:
      del regular_config['UserSettings']  # wipe existing UserSettings.

  # setup blank directory for capath setting
  path = CreateEmptyDirectory()
  regular_config['SoftwareRepoCAPath'] = path

  # enable MSU logging
  regular_config['MSULogEnabled'] = True


  # If setting is enabled, force Simian Apple SUS integration.
  if client_id.get('applesus'):
    regular_config['InstallAppleSoftwareUpdates'] = True
    # Get Apple Software Update Service catalog from server and set locally.
    flight_common.GetAppleSUSCatalog()

  # Report installs/etc to server.
  flight_common.UploadAllManagedInstallReports(
      client, client_id.get('on_corp', 'None'))

  # Delete the temp dir that munkicommon creates on import.
  munkicommon.cleanUpTmpDir()

  logging.debug('Preflight completed successfully.')
Ejemplo n.º 7
0
    PostManagedSoftwareUpdateLogs(client, logs)

    # load user settings
    if user_settings:
        regular_config['UserSettings'] = user_settings
    else:
        if 'UserSettings' in regular_config:
            del regular_config['UserSettings']  # wipe existing UserSettings.

    # setup blank directory for capath setting
    path = CreateEmptyDirectory()
    regular_config['SoftwareRepoCAPath'] = path

    # enable MSU logging
    regular_config['MSULogEnabled'] = True

    # If setting is enabled, force Simian Apple SUS integration.
    if client_id.get('applesus'):
        regular_config['InstallAppleSoftwareUpdates'] = True
        # Get Apple Software Update Service catalog from server and set locally.
        flight_common.GetAppleSUSCatalog()

    # Report installs/etc to server.
    flight_common.UploadAllManagedInstallReports(
        client, client_id.get('on_corp', 'None'))

    # Delete the temp dir that munkicommon creates on import.
    munkicommon.cleanUpTmpDir()

    logging.debug('Preflight completed successfully.')