Have remote_expanduser honor sudo and su users.

Fixes #9663
This commit is contained in:
Toshio Kuratomi
2014-12-03 10:45:54 -08:00
parent f1386bb114
commit 1ec8b6e3c5
5 changed files with 57 additions and 1 deletions

View File

@@ -1196,8 +1196,16 @@ class Runner(object):
''' takes a remote path and performs tilde expansion on the remote host '''
if not path.startswith('~'):
return path
split_path = path.split(os.path.sep, 1)
cmd = conn.shell.expand_user(split_path[0])
expand_path = split_path[0]
if expand_path == '~':
if self.sudo and self.sudo_user:
expand_path = '~%s' % self.sudo_user
elif self.su and self.su_user:
expand_path = '~%s' % self.su_user
cmd = conn.shell.expand_user(expand_path)
data = self._low_level_exec_command(conn, cmd, tmp, sudoable=False, su=False)
initial_fragment = utils.last_non_blank_line(data['stdout'])