From: Adam King Date: Thu, 1 Sep 2022 12:37:39 +0000 (-0400) Subject: mgr/cephadm: don't use "sudo" in commands if user is root X-Git-Tag: v17.2.6~502^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F48079%2Fhead;p=ceph.git mgr/cephadm: don't use "sudo" in commands if user is root We had a patch earlier to make us not use sudo unless the user is not root for our other commands, but this specific one that just runs "true" with a timeout to check if the host is online was missed. Fixes: https://tracker.ceph.com/issues/57369 Signed-off-by: Adam King (cherry picked from commit c638d295dd30e202777314571b1075de3334becc) --- diff --git a/src/pybind/mgr/cephadm/ssh.py b/src/pybind/mgr/cephadm/ssh.py index e874ba6d78fe..c40f2a4d8a8d 100644 --- a/src/pybind/mgr/cephadm/ssh.py +++ b/src/pybind/mgr/cephadm/ssh.py @@ -140,7 +140,7 @@ class SSHManager: cmd = sudo_prefix + " ".join(quote(x) for x in cmd) logger.debug(f'Running command: {cmd}') try: - r = await conn.run('sudo true', check=True, timeout=5) + r = await conn.run(f'{sudo_prefix}true', check=True, timeout=5) r = await conn.run(cmd, input=stdin) # handle these Exceptions otherwise you might get a weird error like TypeError: __init__() missing 1 required positional argument: 'reason' (due to the asyncssh error interacting with raise_if_exception) except (asyncssh.ChannelOpenError, asyncssh.ProcessError, Exception) as e: