Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_available_services from launchctl module fails #8759

Closed
miroswan opened this issue Nov 22, 2013 · 3 comments
Closed

_available_services from launchctl module fails #8759

miroswan opened this issue Nov 22, 2013 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix

Comments

@miroswan
Copy link
Contributor

Anything that calls _available_services in the launchctl module seems to fail. I closely followed the steps in the HACKING.rst file to set up my environment. When I ran salt-call -c "path_to_config_directory" service.get_all, which calls _available_services, this is what I got:

[INFO ] Executing command 'launchctl list' in directory '/Users/demitriswan'
[INFO ] Executing command '/usr/bin/plutil -convert xml1 -o - -- "/Library/LaunchAgents/com.oracle.java.Java-Updater.plist"' in directory '/Users/demitriswan'
[ERROR ] Command '/usr/bin/plutil -convert xml1 -o - -- "/Library/LaunchAgents/com.oracle.java.Java-Updater.plist"' failed with return code: 1
[ERROR ] stdout: /Library/LaunchAgents/com.oracle.java.Java-Updater.plist: file does not exist or is not readable or is not a regular file
[ERROR ] An un-handled exception was caught by salt's global exception handler:
ExpatError: not well-formed (invalid token): line 1, column 0
Traceback (most recent call last):
File "/usr/local/bin/salt-call", line 9, in
load_entry_point('salt==0.17.2', 'console_scripts', 'salt-call')()
File "/Library/Python/2.7/site-packages/salt/scripts.py", line 77, in salt_call
client.run()
File "/Library/Python/2.7/site-packages/salt/cli/init.py", line 303, in run
caller.run()
File "/Library/Python/2.7/site-packages/salt/cli/caller.py", line 135, in run
ret = self.call()
File "/Library/Python/2.7/site-packages/salt/cli/caller.py", line 78, in call
ret['return'] = func(_args, *_kwargs)
File "/Library/Python/2.7/site-packages/salt/modules/launchctl.py", line 110, in get_all
service_labels_from_services = _available_services().keys()
File "/Library/Python/2.7/site-packages/salt/utils/decorators.py", line 192, in _memoize
cache[args] = func(*args)
File "/Library/Python/2.7/site-packages/salt/modules/launchctl.py", line 56, in _available_services
plist = plistlib.readPlistFromString(plist_xml)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 103, in readPlistFromString
return readPlist(StringIO(data))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 78, in readPlist
rootObject = p.parse(pathOrFile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 406, in parse
parser.ParseFile(fileobj)
ExpatError: not well-formed (invalid token): line 1, column 0
Traceback (most recent call last):
File "/usr/local/bin/salt-call", line 9, in
load_entry_point('salt==0.17.2', 'console_scripts', 'salt-call')()
File "/Library/Python/2.7/site-packages/salt/scripts.py", line 77, in salt_call
client.run()
File "/Library/Python/2.7/site-packages/salt/cli/init.py", line 303, in run
caller.run()
File "/Library/Python/2.7/site-packages/salt/cli/caller.py", line 135, in run
ret = self.call()
File "/Library/Python/2.7/site-packages/salt/cli/caller.py", line 78, in call
ret['return'] = func(_args, *_kwargs)
File "/Library/Python/2.7/site-packages/salt/modules/launchctl.py", line 110, in get_all
service_labels_from_services = _available_services().keys()
File "/Library/Python/2.7/site-packages/salt/utils/decorators.py", line 192, in _memoize
cache[args] = func(*args)
File "/Library/Python/2.7/site-packages/salt/modules/launchctl.py", line 56, in _available_services
plist = plistlib.readPlistFromString(plist_xml)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 103, in readPlistFromString
return readPlist(StringIO(data))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 78, in readPlist
rootObject = p.parse(pathOrFile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 406, in parse
parser.ParseFile(fileobj)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0

I tried running the command as root and got very similar output, which – I assume – would rule out a permissions issue. Looks like it doesn't handle symbolic links in _launchd_paths properly. This is the ls output I get on that file:

lrwxr-xr-x 1 root wheel 104B Feb 15 2013 /Library/LaunchAgents/com.oracle.java.Java-Updater.plist -> /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Resources/com.oracle.java.Java-Updater.plist

Perhaps the exception needs to follow symbolic links.

@miroswan
Copy link
Contributor Author

I've figured out a resolution and committed to my forked repo:

https://github.com/miroswan/salt/commit/d37bfe6e6b8d0cbfd0311475c5b008660ede6c5a

Not submitting a pull request just yet, as I have to learn about the policies and standards for doing so in this project.

@cachedout
Copy link
Contributor

@miroswan Super! We look forward to seeing your PR as soon as you're ready to send it! Thanks so much for reporting this issue and even more for fixing it. I love it when that happens. :]

@miroswan
Copy link
Contributor Author

Just submitted my pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix
Projects
None yet
Development

No branches or pull requests

2 participants