From c638d295dd30e202777314571b1075de3334becc Mon Sep 17 00:00:00 2001 From: Adam King Date: Thu, 1 Sep 2022 08:37:39 -0400 Subject: [PATCH] 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 --- src/pybind/mgr/cephadm/ssh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pybind/mgr/cephadm/ssh.py b/src/pybind/mgr/cephadm/ssh.py index 6d29e45d43d..bdd3ae046dd 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: