if users are None/empty, dont assume sameness (#58875)

This commit is contained in:
Brian Coca 2019-07-17 11:17:48 -04:00 committed by GitHub
parent 48d4d6ec69
commit 4ef2545eb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1039,9 +1039,11 @@ class ActionBase(with_metaclass(ABCMeta, object)):
display.debug("_low_level_execute_command(): changing cwd to %s for this command" % chdir) display.debug("_low_level_execute_command(): changing cwd to %s for this command" % chdir)
cmd = self._connection._shell.append_command('cd %s' % chdir, cmd) cmd = self._connection._shell.append_command('cd %s' % chdir, cmd)
if (sudoable and self._connection.transport != 'network_cli' and self._connection.become and ruser = self._get_remote_user()
(C.BECOME_ALLOW_SAME_USER or buser = self.get_become_option('become_user')
self.get_become_option('become_user') != self._get_remote_user())): if (sudoable and self._connection.become and # if sudoable and have become
self._connection.transport != 'network_cli' and # if not using network_cli
(C.BECOME_ALLOW_SAME_USER or (buser != ruser and (ruser or buser)))): # if we allow same user PE or users are different and either is set
display.debug("_low_level_execute_command(): using become for this command") display.debug("_low_level_execute_command(): using become for this command")
cmd = self._connection.become.build_become_command(cmd, self._connection._shell) cmd = self._connection.become.build_become_command(cmd, self._connection._shell)