diff options
author | James Tanner <tanner.jc@gmail.com> | 2013-11-27 17:01:53 -0500 |
---|---|---|
committer | James Tanner <tanner.jc@gmail.com> | 2013-11-27 17:01:53 -0500 |
commit | b6879ca2bd620a2d73db9f2598ad67c66aff3bbb (patch) | |
tree | fcd97ecf76c1eb98a80f628aad121db9fe26a383 | |
parent | 12ed39ef7b94b427e6125730786eb8a7a9cb0d84 (diff) | |
download | ansible-b6879ca2bd620a2d73db9f2598ad67c66aff3bbb.tar.gz |
Fixes #5030 compare connection user and sudo user and disable sudo if identical
-rw-r--r-- | lib/ansible/runner/__init__.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index aafb07bdfa..75866fadca 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -762,10 +762,12 @@ class Runner(object): executable = C.DEFAULT_EXECUTABLE sudo_user = self.sudo_user - - if self.remote_user == sudo_user: - sudoable = False - + + # compare connection user to sudo_user and disable if the same + if hasattr(conn, 'user'): + if conn.user == sudo_user: + sudoable = False + rc, stdin, stdout, stderr = conn.exec_command(cmd, tmp, sudo_user, sudoable=sudoable, executable=executable) if type(stdout) not in [ str, unicode ]: |