Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions ansible_mitogen/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,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 fallback to %r',
self, self.cwd, self.good_temp_dir)
os.chdir(self.good_temp_dir)

def _setup_environ(self):
"""
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ v0.3.9 (2024-08-13)
v0.3.8 (2024-07-30)
-------------------

* :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()"
Expand Down
Loading