Fix issues in munki.py when writing trigger files; edits to launchdaemons so managedsoftwareupdate-loginwindow runs only when a trigger file is present

This commit is contained in:
Greg Neagle
2011-09-14 15:31:42 -07:00
parent 765bf5094f
commit 239663353f
4 changed files with 22 additions and 10 deletions

View File

@@ -256,8 +256,9 @@ def stringFromDate(nsdate):
def startUpdateCheck():
'''Does launchd magic to run managedsoftwareupdate as root.'''
try:
f = open(UPDATECHECKLAUNCHFILE, 'w')
f.close()
if not os.path.exists(UPDATECHECKLAUNCHFILE):
open(UPDATECHECKLAUNCHFILE, 'w').close()
return 0
except (OSError, IOError):
return 1
@@ -353,8 +354,7 @@ def logoutAndUpdate():
try:
if not os.path.exists(INSTALLATLOGOUTFILE):
f = open(INSTALLATLOGOUTFILE, 'w')
f.close()
open(INSTALLATLOGOUTFILE, 'w').close()
logoutNow()
except (OSError, IOError):
return 1
@@ -376,11 +376,10 @@ def justUpdate():
We touch a file that launchd is is watching
launchd, in turn,
launches managedsoftwareupdate --installwithnologout as root'''
cmd = ["/usr/bin/touch", INSTALLWITHOUTLOGOUTFILE]
return call(cmd)
try:
f = open(INSTALLWITHOUTLOGOUTFILE, 'w')
f.close()
if not os.path.exists(INSTALLWITHOUTLOGOUTFILE):
open(INSTALLWITHOUTLOGOUTFILE, 'w').close()
return 0
except (OSError, IOError):
return 1

View File

@@ -426,6 +426,7 @@ def main():
# delete triggerfile if _not_ checkandinstallatstartup
os.unlink(filename)
if not user_triggered:
# no trigger file was found -- how'd we get launched?
munkicommon.cleanUpTmpDir()
exit(0)

View File

@@ -25,7 +25,7 @@
<dict>
<key>/var/run/com.googlecode.munki.MunkiStatus</key>
<true/>
<key>/private/tmp/com.googlecode.munki.statusatlogout</key>
<key>/private/tmp/com.googlecode.munki.installatlogout</key>
<true/>
</dict>
</dict>

View File

@@ -18,7 +18,19 @@
<string>--logoutinstall</string>
</array>
<key>RunAtLoad</key>
<true/>
<false/>
<key>KeepAlive</key>
<dict>
<key>PathState</key>
<dict>
<key>/private/tmp/com.googlecode.munki.installatlogout</key>
<true/>
<key>/Users/Shared/.com.googlecode.munki.checkandinstallatstartup</key>
<true/>
<key>/Users/Shared/.com.googlecode.munki.installatstartup</key>
<true/>
</dict>
</dict>
</dict>
</plist>