mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Ignore plist files without Label key
Some of the files in the directories listed in `launchctl._launchd_paths()` might not represent a service and have no Label key (for example `/System/Library/LaunchDaemons/com.apple.jetsamproperties.Mac.plist ` on MacOS 10.12). Previously this prevented the `service` module from working correctly as any state trying to access `launchctl._available_services()` would fail with an uncaught `AttributeError` exception when encountering such a file.
This commit is contained in:
parent
6869621ed1
commit
616292c6b1
1 changed files with 11 additions and 5 deletions
|
@ -77,11 +77,17 @@ def _available_services():
|
|||
else:
|
||||
plist = plistlib.readPlistFromBytes(salt.utils.to_bytes(plist_xml))
|
||||
|
||||
available_services[plist.Label.lower()] = {
|
||||
'filename': filename,
|
||||
'file_path': true_path,
|
||||
'plist': plist,
|
||||
}
|
||||
try:
|
||||
available_services[plist.Label.lower()] = {
|
||||
'filename': filename,
|
||||
'file_path': true_path,
|
||||
'plist': plist,
|
||||
}
|
||||
except AttributeError:
|
||||
# As of MacOS 10.12 there might be plist files without Label key
|
||||
# in the searched directories. As these files do not represent
|
||||
# services, thay are not added to the list.
|
||||
pass
|
||||
|
||||
return available_services
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue