[ansiballz] ensure that '' is not in sys.path (#69342)
Change: On OpenBSD when using pipelining, we do not set cwd which results in a permissions fatal. Ensure that `''` - cwd - is not in `sys.path`. Test Plan: Tested against local OpenBSD VM Tickets: Fixes #69320 Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
parent
79ab798427
commit
2abaf320d7
3 changed files with 7 additions and 2 deletions
2
changelogs/fragments/69320-sys-path-cwd.yml
Normal file
2
changelogs/fragments/69320-sys-path-cwd.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- ansiballz - remove '' and '.' from sys.path to fix a permissions issue on OpenBSD with pipelining (#69320)
|
|
@ -138,6 +138,7 @@ Noteworthy module changes
|
|||
* The parameter ``message`` in :ref:`grafana_dashboard <grafana_dashboard_module>` module is renamed to ``commit_message`` since ``message`` is used by Ansible Core engine internally.
|
||||
* The parameter ``message`` in :ref:`datadog_monitor <datadog_monitor_module>` module is renamed to ``notification_message`` since ``message`` is used by Ansible Core engine internally.
|
||||
* The parameter ``message`` in :ref:`bigpanda <bigpanda_module>` module is renamed to ``deployment_message`` since ``message`` is used by Ansible Core engine internally.
|
||||
* Ansible no longer looks for Python modules in the current working directory (typically the ``remote_user``'s home directory) when an Ansible module is run. This is to fix becoming an unprivileged user on OpenBSD and to mitigate any attack vector if the current working directory is writable by a malicious user. Install any Python modules needed to run the Ansible modules on the managed node in a system-wide location or in another directory which is in the ``remote_user``'s ``$PYTHONPATH`` and readable by the ``become_user``.
|
||||
|
||||
|
||||
Plugins
|
||||
|
|
|
@ -143,8 +143,10 @@ def _ansiballz_main():
|
|||
# OSX raises OSError if using abspath() in a directory we don't have
|
||||
# permission to read (realpath calls abspath)
|
||||
pass
|
||||
if scriptdir is not None:
|
||||
sys.path = [p for p in sys.path if p != scriptdir]
|
||||
|
||||
# Strip cwd from sys.path to avoid potential permissions issues
|
||||
excludes = set(('', '.', scriptdir))
|
||||
sys.path = [p for p in sys.path if p not in excludes]
|
||||
|
||||
import base64
|
||||
import runpy
|
||||
|
|
Loading…
Reference in a new issue