Handle condition going from privileged to non-privileged user in which the cwd disables descent.

Fall back to Mitogen's temporary directory. In relation to #636.
pull/805/head
Matt Saladna 4 years ago
parent 59716a8788
commit 6969a0c181
No known key found for this signature in database
GPG Key ID: ED68223DE93752A9

@ -378,10 +378,15 @@ class Runner(object):
"""
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 fallback to %r',
self, self.cwd, self.good_temp_dir)
os.chdir(self.good_temp_dir)
def _setup_environ(self):
"""

@ -23,6 +23,7 @@ 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
@ -30,6 +31,7 @@ This release separates itself from the v0.2.X releases. Ansible's API changed to
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

Loading…
Cancel
Save