Skip to content

Commit

Permalink
Fix: report: should not try to su if effective uid != 0 (bsc#1228899)
Browse files Browse the repository at this point in the history
Trying to do that will not succeed and generates misleading error
messages.
  • Loading branch information
nicholasyang2022 committed Sep 13, 2024
1 parent a4c37d4 commit 4620ba8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crmsh/report/utillib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,12 @@ def start_slave_collector(node, arg_str):
cmd = r'ssh {} {} "{} {}"'.format(constants.SSH_OPTS, node, constants.SUDO, cmd)
for item in arg_str.split():
cmd += " {}".format(str(item))
code, out, err = crmutils.su_get_stdout_stderr(constants.SSH_USER, cmd)
if constants.SSH_USER and os.geteuid() == 0:
code, out, err = crmutils.su_get_stdout_stderr(constants.SSH_USER, cmd)
else:
# a remote user is not specfied
# or current user is not root, impossible to su
code, out, err = crmutils.get_stdout_stderr(cmd)
if code != 0:
logger.warning(err)
for ip in get_peer_ip():
Expand Down

0 comments on commit 4620ba8

Please sign in to comment.