mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixes #6088 turn off sudo and su if the connection is local the sudo user matches the current user
This commit is contained in:
parent
2a9fcdd87c
commit
cdc0819939
1 changed files with 7 additions and 0 deletions
|
@ -31,6 +31,7 @@ import sys
|
|||
import pipes
|
||||
import jinja2
|
||||
import subprocess
|
||||
import getpass
|
||||
|
||||
import ansible.constants as C
|
||||
import ansible.inventory
|
||||
|
@ -931,6 +932,12 @@ class Runner(object):
|
|||
if conn.user == sudo_user or conn.user == su_user:
|
||||
sudoable = False
|
||||
su = False
|
||||
else:
|
||||
# assume connection type is local if no user attribute
|
||||
this_user = getpass.getuser()
|
||||
if this_user == sudo_user or this_user == su_user:
|
||||
sudoable = False
|
||||
su = False
|
||||
|
||||
if su:
|
||||
rc, stdin, stdout, stderr = conn.exec_command(cmd,
|
||||
|
|
Loading…
Reference in a new issue