File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -367,10 +367,15 @@ def _setup_cwd(self):
367367 """
368368 For situations like sudo to a non-privileged account, CWD could be
369369 $HOME of the old account, which could have mode go=, which means it is
370- impossible to restore the old directory, so don't even try .
370+ impossible to restore the old directory. Fallback to a neutral temp if so .
371371 """
372372 if self .cwd :
373- os .chdir (self .cwd )
373+ try :
374+ os .chdir (self .cwd )
375+ except OSError :
376+ LOG .debug ('%r: could not CHDIR to %r fallback to %r' ,
377+ self , self .cwd , self .good_temp_dir )
378+ os .chdir (self .good_temp_dir )
374379
375380 def _setup_environ (self ):
376381 """
Original file line number Diff line number Diff line change @@ -198,6 +198,7 @@ v0.3.9 (2024-08-13)
198198v0.3.8 (2024-07-30)
199199-------------------
200200
201+ * :gh:issue: `636 ` os.chdir fails if the sudo/become user lacks adequate permissions to chdir prior to task
201202* :gh:issue: `952 ` Fix Ansible `--ask-become-pass `, add test coverage
202203* :gh:issue: `957 ` Fix Ansible exception when executing against 10s of hosts
203204 "ValueError: filedescriptor out of range in select()"
You can’t perform that action at this time.
0 commit comments