Handle condition going from privileged to non-privileged user

in which the cwd disables descent. Fall back to Mitogen's temporary
directory. Fixes #636.
pull/1080/head
Orion Poplawski 4 months ago
parent 23d9d0bc82
commit 726ab79253

@ -383,10 +383,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):
"""

@ -21,6 +21,7 @@ To avail of fixes in an unreleased version, please download a ZIP file
Unreleased
----------
* :gh:issue:`636` os.chdir fails if the sudo/become user lacks adequate permissions to chdir prior to task
* :gh:issue:`952` Fix Ansible `--ask-become-pass`, add test coverage
* :gh:issue:`957` Fix Ansible exception when executing against 10s of hosts
"ValueError: filedescriptor out of range in select()"

Loading…
Cancel
Save