mirror of
https://github.com/munki/munki.git
synced 2025-12-21 14:29:32 -06:00
Added new launchapp tool to make sure MunkiStatus.app and Managed Software Update.app are launched only in the context of the current GUI user.
Updated LaunchAgents com.googlecode.munki.munkistatus.plist and com.googlecode.munki.ManagedSoftwareUpdate.plist to call the launchapp tool. git-svn-id: http://munki.googlecode.com/svn/trunk@440 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
60
code/client/launchapp
Executable file
60
code/client/launchapp
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/python
|
||||
# encoding: utf-8
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""
|
||||
launchapp
|
||||
|
||||
Created by Greg Neagle on 2010-02-05.
|
||||
Launches an app only if we're called in the current
|
||||
GUI user's session.
|
||||
Prevents multiple copies of the app from being launched
|
||||
when Fast User Switching is in use
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import optparse
|
||||
import subprocess
|
||||
|
||||
|
||||
def getconsoleuser():
|
||||
from SystemConfiguration import SCDynamicStoreCopyConsoleUser
|
||||
cfuser = SCDynamicStoreCopyConsoleUser( None, None, None )
|
||||
return cfuser[0]
|
||||
|
||||
|
||||
def main():
|
||||
consoleuser = getconsoleuser()
|
||||
try:
|
||||
thisuser = os.environ['USER']
|
||||
except:
|
||||
# when run via launchd at loginwindow context, os.environ['USER']
|
||||
# is undefined, so we'll return root (the effective user)
|
||||
thisuser = "root"
|
||||
|
||||
if (consoleuser == thisuser) or \
|
||||
(consoleuser == None and thisuser == "root"):
|
||||
p = optparse.OptionParser()
|
||||
options, arguments = p.parse_args()
|
||||
try:
|
||||
app = arguments[0]
|
||||
except:
|
||||
print >>sys.stderr, "Must specify an app to launch!"
|
||||
exit(-1)
|
||||
retcode = subprocess.call(["/usr/bin/open", "-a", app])
|
||||
exit(retcode)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
</array>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/bin/open</string>
|
||||
<string>-a</string>
|
||||
<string>/usr/local/munki/launchapp</string>
|
||||
<string>Managed Software Update</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
</array>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/local/munki/launchapp</string>
|
||||
<string>/Library/Application Support/Managed Installs/MunkiStatus.app/Contents/MacOS/MunkiStatus</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
|
||||
Reference in New Issue
Block a user