Skip to content

Commit

Permalink
Handle condition going from privileged to non-privileged user in whic…
Browse files Browse the repository at this point in the history
…h the cwd disables descent.

Fall back to Mitogen's temporary directory. In relation to mitogen-hq#636.
  • Loading branch information
msaladna committed Feb 2, 2021
1 parent 59716a8 commit d4ce85e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ansible_mitogen/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,15 @@ def _setup_cwd(self):
"""
For situations like sudo to a non-privileged account, CWD could be
$HOME of the old account, which could have mode go=, which means it is
impossible to restore the old directory, so don't even try.
impossible to restore the old directory. Fallback to a neutral temp if so.
"""
if self.cwd:
os.chdir(self.cwd)
try:
os.chdir(self.cwd)
except OSError:
LOG.debug('%r: could not CHDIR to %r',
self, self.cwd)
self._revert_cwd()

def _setup_environ(self):
"""
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ v0.3.0 (unreleased)
This release separates itself from the v0.2.X releases. Ansible's API changed too much to support backwards compatibility so from now on, v0.2.X releases will be for Ansible < 2.10 and v0.3.X will be for Ansible 2.10+.
`See here for details <https://github.com/dw/mitogen pull/715#issuecomment-750697248>`_.

* :gh:issue:`636` os.chdir fails if the sudo/become user lacks adequate permissions to chdir prior to task
* :gh:issue:`731` ansible 2.10 support
* :gh:issue:`652` support for ansible collections import hook


v0.2.10 (unreleased)
--------------------

* :gh:issue:`636` os.chdir fails if the sudo/become user lacks adequate permissions to chdir prior to task
* :gh:issue:`597` mitogen does not support Ansible 2.8 Python interpreter detection
* :gh:issue:`655` wait_for_connection gives errors
* :gh:issue:`672` cannot perform relative import error
Expand Down

0 comments on commit d4ce85e

Please sign in to comment.