You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Running service.get_enabled runas=user (or any other functions inside that module that expose runas that I tested) on MacOS [Monterey] results in an exception.
Setup
M1 Mac + MacOS Monterey
Steps to Reproduce the behavior
$ sudo /opt/salt/bin/salt-call service.get_enabled runas=username[ERROR ] An un-handled exception was caught by salt's global exception handler:NameError: name '__salt__' is not definedTraceback (most recent call last): File "/opt/salt/bin/salt-call", line 11, in <module> load_entry_point('salt==3004', 'console_scripts', 'salt-call')() File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/scripts.py", line 432, in salt_call client.run() File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/cli/call.py", line 55, in run caller.run() File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/cli/caller.py", line 111, in run ret = self.call() File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/cli/caller.py", line 219, in call self.opts, data, func, args, kwargs File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/loader/lazy.py", line 149, in __call__ return self.loader.run(run_func, *args, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/loader/lazy.py", line 1201, in run return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/loader/lazy.py", line 1216, in _run_as return _func_or_method(*args, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/executors/direct_call.py", line 10, in execute return func(*args, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/loader/lazy.py", line 149, in __call__ return self.loader.run(run_func, *args, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/loader/lazy.py", line 1201, in run return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/loader/lazy.py", line 1216, in _run_as return _func_or_method(*args, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/modules/mac_service.py", line 689, in get_enabled stdout = list_(runas=runas) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/modules/mac_service.py", line 354, in list_ return launchctl("list", return_stdout=True, runas=runas) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/modules/mac_service.py", line 318, in launchctl return __utils__["mac_utils.launchctl"](sub_cmd, *args, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/loader/lazy.py", line 149, in __call__ return self.loader.run(run_func, *args, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/loader/lazy.py", line 1201, in run return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/loader/lazy.py", line 1216, in _run_as return _func_or_method(*args, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/utils/mac_utils.py", line 311, in launchctl ret = __salt__["cmd.run_all"](cmd, **kwargs) File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/modules/cmdmod.py", line 986, in _run_all_quiet success_stderr=success_stderr, File "/opt/salt/lib/python3.7/site-packages/salt-3004-py3.7.egg/salt/modules/cmdmod.py", line 442, in _run user_shell = __salt__["user.info"](runas)["shell"]
Expected behavior
Returns a list of launchctl services, including user-specific ones.
Versions Report
Salt Version:
Salt: 3004Dependency Versions:
cffi: 1.14.6cherrypy: unknowndateutil: 2.8.0docker-py: Not Installedgitdb: 4.0.5gitpython: 3.1.12Jinja2: 2.11.3libgit2: Not InstalledM2Crypto: Not InstalledMako: 1.1.4msgpack: 1.0.2msgpack-pure: Not Installedmysql-python: Not Installedpycparser: 2.19pycrypto: Not Installedpycryptodome: 3.9.8pygit2: Not InstalledPython: 3.7.4 (default, Oct 12 2021, 12:57:44)python-gnupg: 0.4.4PyYAML: 5.4.1PyZMQ: 18.0.1smmap: 3.0.2timelib: 0.2.4Tornado: 4.5.3ZMQ: 4.3.1System Versions:
dist: darwin 21.3.0locale: UTF-8machine: x86_64release: 21.3.0system: Darwinversion: 10.16 x86_64
possible fix by importing + aliasing the module if __salt__ is not defined or just calling it directly (not sure about side effects currently) or implementing the lookup without reliance on the module
PR incoming. Just need to figure out how to write the test.
The text was updated successfully, but these errors were encountered:
Description
Running
service.get_enabled runas=user
(or any other functions inside that module that exposerunas
that I tested) on MacOS [Monterey] results in an exception.Setup
M1 Mac + MacOS Monterey
Steps to Reproduce the behavior
Expected behavior
Returns a list of launchctl services, including user-specific ones.
Versions Report
Additional context
Related issue: #47705
I already diagnosed it:
__salt__
needs to be aliased: https://github.com/saltstack/salt/blob/master/salt/utils/mac_utils.py#L41-L44 (see why)_run_all_quiet
is supposed to not depend on any dunders being initialized, calls_run
_run
has a special block forrunas
on MacOS that calls__salt__['user.info']
:salt/salt/modules/cmdmod.py
Line 446 in 1671aab
__salt__
is not defined or just calling it directly (not sure about side effects currently) or implementing the lookup without reliance on the modulePR incoming. Just need to figure out how to write the test.
The text was updated successfully, but these errors were encountered: