]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: don't use "sudo" in commands if user is root 47898/head
authorAdam King <adking@redhat.com>
Thu, 1 Sep 2022 12:37:39 +0000 (08:37 -0400)
committerAdam King <adking@redhat.com>
Thu, 1 Sep 2022 12:37:39 +0000 (08:37 -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>
src/pybind/mgr/cephadm/ssh.py

index 6d29e45d43d1c9dbc31c815a58a329e038ee3ca8..bdd3ae046ddaead2e5f22853fee56a8ecbbd255a 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: