def killStupidProcesses(): '''A nasty bit of hackery to get Adobe CS5 AAMEE packages to install when at the loginwindow.''' stupid_processes = ["Adobe AIR Installer", "Adobe AIR Application Installer", "InstallAdobeHelp", "open -a /Library/Application Support/Adobe/SwitchBoard/SwitchBoard.app"] for procname in stupid_processes: pid = utils.getPIDforProcessName(procname) if pid: if not pid in secondsToLive: secondsToLive[pid] = 30 else: secondsToLive[pid] = secondsToLive[pid] - 1 if secondsToLive[pid] == 0: # it's been running too long; kill it munkicommon.log("Killing PID %s: %s" % (pid, procname)) try: os.kill(int(pid), 9) except OSError: pass # remove this PID from our list del secondsToLive[pid] # only kill one process per invocation return
def getMunkiStatusPID(): '''Gets the process ID for Managed Software Update''' return utils.getPIDforProcessName( "Managed Software Update.app/Contents/MacOS/Managed Software Update") \ or utils.getPIDforProcessName( "MunkiStatus.app/Contents/MacOS/MunkiStatus")
def runAdobeCS5AAMEEInstall(dmgpath): '''Installs a CS5 product using an AAMEE-generated package on a disk image.''' munkicommon.display_status_minor( 'Mounting disk image %s' % os.path.basename(dmgpath)) mountpoints = mountAdobeDmg(dmgpath) if not mountpoints: munkicommon.display_error("No mountable filesystems on %s" % dmgpath) return -1 deploymentmanager = findAdobeDeploymentManager(mountpoints[0]) if deploymentmanager: # big hack to convince the Adobe tools to install off a mounted # disk image. # For some reason, the Adobe install tools refuse to install when # the payloads are on a "removable" disk, which includes mounted disk # images. # we create a temporary directory on the local disk and then symlink # some resources from the mounted disk image to the temporary # directory. When we pass this temporary directory to the Adobe # installation tools, they are now happy. basepath = os.path.dirname(deploymentmanager) number_of_payloads = countPayloads(basepath) tmpdir = tempfile.mkdtemp() # make our symlinks os.symlink(os.path.join(basepath,"ASU"), os.path.join(tmpdir, "ASU")) os.symlink(os.path.join(basepath,"ProvisioningTool"), os.path.join(tmpdir, "ProvisioningTool")) realsetupdir = os.path.join(basepath,"Setup") tmpsetupdir = os.path.join(tmpdir, "Setup") os.mkdir(tmpsetupdir) for item in munkicommon.listdir(realsetupdir): os.symlink(os.path.join(realsetupdir, item), os.path.join(tmpsetupdir, item)) optionXMLfile = os.path.join(basepath, "optionXML.xml") if (not munkicommon.getconsoleuser() or munkicommon.getconsoleuser() == u"loginwindow"): # we're at the loginwindow, so we need to run the deployment # manager in the loginwindow context using launchctl bsexec loginwindowPID = utils.getPIDforProcessName("loginwindow") cmd = ['/bin/launchctl', 'bsexec', loginwindowPID] else: cmd = [] cmd.extend([deploymentmanager, '--optXMLPath=%s' % optionXMLfile, '--setupBasePath=%s' % tmpdir, '--installDirPath=/', '--mode=install']) munkicommon.display_status_minor('Starting Adobe CS5 installer...') retcode = runAdobeInstallTool(cmd, number_of_payloads, killAdobeAIR=True) # now clean up our symlink hackfest unused_result = subprocess.call(["/bin/rm", "-rf", tmpdir]) else: munkicommon.display_error( "%s doesn't appear to contain AdobeDeploymentManager" % os.path.basename(dmgpath)) retcode = -1 munkicommon.unmountdmg(mountpoints[0]) return retcode