[Libguestfs] [v2v PATCH] libvirt: make use of libvirt's default auth handler (RHBZ#1838425)

Pino Toscano ptoscano at redhat.com
Thu May 21 11:35:24 UTC 2020


Use the default libvirt authentication handler as base for ours,
overriding it with our callback only in case we have a password to
supply.
---
 v2v/libvirt_utils.ml | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/v2v/libvirt_utils.ml b/v2v/libvirt_utils.ml
index 7df17b29..4d0b8639 100644
--- a/v2v/libvirt_utils.ml
+++ b/v2v/libvirt_utils.ml
@@ -33,10 +33,14 @@ let auth_for_password_file ?password_file () =
     ) creds
   in
 
-  {
-    Libvirt.Connect.credtype = [ Libvirt.Connect.CredentialPassphrase ];
-    cb = auth_fn;
-  }
+  let base_auth = Libvirt.Connect.get_auth_default () in
+
+  if password_file = None then
+    base_auth
+  else
+    { base_auth with
+      cb = auth_fn;
+    }
 
 let get_domain conn name =
   let dom =
-- 
2.25.4




More information about the Libguestfs mailing list