]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virsh: Do not try connecting first time without polkit agent
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 16 Nov 2021 14:00:19 +0000 (15:00 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 23 Nov 2021 11:51:09 +0000 (12:51 +0100)
commit0ac13b189f0fe6f12546e7aaf6ad07ba81b55d9e
tree5d9e9ad709f8665e86c4f4b2dd976e014f769762
parent32d100ca5c1f296ab0e1f7691c1dd068bd93573e
virsh: Do not try connecting first time without polkit agent

Trying to connect once without a polkit agent will generate an error on the
server side which seems too rough given it only serves the purpose of the client
(virsh in this case) to figure out that an agent is needed.  Thankfully we can
just try running the agent.  It does not break anything as we are running it
with `--fallback`, which makes sure it does not replace an existing agent in
case there is one already registered.

The second piece of code trying to start the polkit text agent is kept in order
to _really_ try out starting the agent (and error out when failing to do so)
just in case the agent was not available the first time it was ran.  Even though
it should not happen it avoids a very rare race condition and really does not
add much complexity.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1945501
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virsh.c