mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Only expand '~' based on become_user/remote_user
Change brought forward from #00c023e in stable-2.5. Closes #39281 (bug report) Closes #39540 (PR with substantially the same change)
This commit is contained in:
parent
f526a461ee
commit
0a119c391a
1 changed files with 6 additions and 5 deletions
|
@ -567,11 +567,12 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
||||||
split_path = path.split(os.path.sep, 1)
|
split_path = path.split(os.path.sep, 1)
|
||||||
expand_path = split_path[0]
|
expand_path = split_path[0]
|
||||||
|
|
||||||
if sudoable and expand_path == '~' and self._play_context.become and self._play_context.become_user:
|
if expand_path == '~':
|
||||||
expand_path = '~%s' % self._play_context.become_user
|
if sudoable and self._play_context.become and self._play_context.become_user:
|
||||||
else:
|
expand_path = '~%s' % self._play_context.become_user
|
||||||
# use remote user instead, if none set default to current user
|
else:
|
||||||
expand_path = '~%s' % self._play_context.remote_user or self._connection.default_user or ''
|
# use remote user instead, if none set default to current user
|
||||||
|
expand_path = '~%s' % self._play_context.remote_user or self._connection.default_user or ''
|
||||||
|
|
||||||
# use shell to construct appropriate command and execute
|
# use shell to construct appropriate command and execute
|
||||||
cmd = self._connection._shell.expand_user(expand_path)
|
cmd = self._connection._shell.expand_user(expand_path)
|
||||||
|
|
Loading…
Reference in a new issue