| 7 | | |
| 8 | | '''Locate plist file that provides given reverse-fqdn name |
| 9 | | /Library/LaunchAgents Per-user agents provided by the administrator. |
| 10 | | /Library/LaunchDaemons System wide daemons provided by the administrator. |
| 11 | | /System/Library/LaunchAgents Mac OS X Per-user agents. |
| 12 | | /System/Library/LaunchDaemons Mac OS X System wide daemons.''' |
| 13 | | plistLocations = ["/Library/LaunchDaemons", "/System/Library/LaunchDaemons"] |
| 14 | | plistMapping = {} |
| 15 | | for directory in plistLocations: |
| 16 | | for daemon in os.listdir(directory): |
| 17 | | try: |
| 18 | | if daemon.endswith(".plist"): |
| 19 | | d = daemon[:-6] |
| 20 | | else: |
| 21 | | d = daemon |
| 22 | | (stdout, _) = popen2.popen2('defaults read %s/%s Label' % (directory, d)) |
| 23 | | label = stdout.read().strip() |
| 24 | | plistMapping[label] = "%s/%s" % (directory, daemon) |
| 25 | | except KeyError: #perhaps this could be more robust |
| 26 | | pass |
| | 19 | def __init__(self, logger, setup, config): |
| | 20 | Bcfg2.Client.Tools.Tool.__init__(self, logger, setup, config) |
| | 21 | |
| | 22 | '''Locate plist file that provides given reverse-fqdn name |
| | 23 | /Library/LaunchAgents Per-user agents provided by the administrator. |
| | 24 | /Library/LaunchDaemons System wide daemons provided by the administrator. |
| | 25 | /System/Library/LaunchAgents Mac OS X Per-user agents. |
| | 26 | /System/Library/LaunchDaemons Mac OS X System wide daemons.''' |
| | 27 | plistLocations = ["/Library/LaunchDaemons", "/System/Library/LaunchDaemons"] |
| | 28 | self.plistMapping = {} |
| | 29 | for directory in plistLocations: |
| | 30 | for daemon in os.listdir(directory): |
| | 31 | try: |
| | 32 | if daemon.endswith(".plist"): |
| | 33 | d = daemon[:-6] |
| | 34 | else: |
| | 35 | d = daemon |
| | 36 | (stdout, _) = popen2.popen2('defaults read %s/%s Label' % (directory, d)) |
| | 37 | label = stdout.read().strip() |
| | 38 | self.plistMapping[label] = "%s/%s" % (directory, daemon) |
| | 39 | except KeyError: #perhaps this could be more robust |
| | 40 | pass |
| | 41 | |