]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: don't use "sudo" in commands if user is root 48079/head
authorAdam King <adking@redhat.com>
Thu, 1 Sep 2022 12:37:39 +0000 (08:37 -0400)
committerAdam King <adking@redhat.com>
Tue, 13 Sep 2022 19:18:53 +0000 (15:18 -0400)
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 <adking@redhat.com>
(cherry picked from commit c638d295dd30e202777314571b1075de3334becc)

src/pybind/mgr/cephadm/ssh.py

index e874ba6d78fe860b6ed969f1c6d15a7c71d13193..c40f2a4d8a8db70f30fdcfdf0a7bc77dc99faad6 100644 (file)
@@ -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: