Skip to content

Commit

Permalink
Return cmd when local node is already the root user.
Browse files Browse the repository at this point in the history
Resolves: #3827
Resolves: #3828

Signed-off-by: Trevor Benson <[email protected]>
  • Loading branch information
TrevorBenson authored and arif-ali committed Nov 16, 2024
1 parent 20fc35f commit 25f5e26
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sos/collector/sosnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ def _format_cmd(self, cmd):
"""If we need to provide a sudo or root password to a command, then
here we prefix the command with the correct bits
"""
is_root = self._env_vars.get("USER", os.environ.get("USER")) == 'root'
if self.local and is_root:
return cmd
if self.opts.become_root:
return f"su -c {quote(cmd)}"
if self.need_sudo:
Expand Down

0 comments on commit 25f5e26

Please sign in to comment.