[PATCH] util: Don't spawn pkttyagent when stdin is not a tty

Martin Kletzander mkletzan at redhat.com
Sat Dec 11 13:23:11 UTC 2021


My idea was that running pkttyagent unconditionally, modulo checks that
pkttyagent itself does to make sure it does not fail, is not going to be an
issue turned out to be wrong.  Adding back the original check for stdin being a
tty helps in some testing scenarios as reported by Jim Fehlig and does not
really cause any issues.  I originally wanted it in because it also made
pkttyagent auth work with redirected input into virsh (with a connection that
requires polkit authentication and without a session-wide polkit tty agent,
basically making pkttyagent necessary to succeed).  But anyone running virsh
like that is asking for problems already anyway =)

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/util/virpolkit.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c
index 8970de192fe1..bb68b5a59614 100644
--- a/src/util/virpolkit.c
+++ b/src/util/virpolkit.c
@@ -237,6 +237,9 @@ virPolkitAgentAvailable(void)
     const char *termid = ctermid(NULL);
     VIR_AUTOCLOSE fd = -1;
 
+    if (!isatty(STDIN_FILENO))
+        return false;
+
     if (!virFileIsExecutable(PKTTYAGENT))
         return false;
 
-- 
2.34.1




More information about the libvir-list mailing list