]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virnetlibsshsession: Check later for auth callback in virNetLibsshAuthenticatePassword()
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 15 May 2026 07:53:10 +0000 (09:53 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 18 May 2026 07:58:55 +0000 (09:58 +0200)
The first thing that virNetLibsshAuthenticatePassword() does is
read password from config file. For this it does not need auth
callback. If that password fails to authenticate then
corresponding callback from the auth callback is called. This is
actual place where auth callback should be checked for.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Richrad W.M. Jones <rjones@redhat.com>
src/rpc/virnetlibsshsession.c

index 2f590ec1c4cbaa65e22cf4a0184b4da679bc63cf..bbcfb19e5cd940cdb37c7d85a00c6ec7e6277290 100644 (file)
@@ -517,13 +517,6 @@ virNetLibsshAuthenticatePassword(virNetLibsshSession *sess)
 
     VIR_DEBUG("sess=%p", sess);
 
-    /* password authentication with interactive password request */
-    if (!sess->cred || !sess->cred->cb) {
-        virReportError(VIR_ERR_LIBSSH, "%s",
-                       _("Can't perform authentication: Authentication callback not provided"));
-        return SSH_AUTH_ERROR;
-    }
-
     /* first try to get password from config */
     if (virAuthGetCredential("ssh", sess->hostname, "password", sess->authPath,
                              &password) < 0)
@@ -539,6 +532,13 @@ virNetLibsshAuthenticatePassword(virNetLibsshSession *sess)
             goto error;
     }
 
+    /* password authentication with interactive password request */
+    if (!sess->cred || !sess->cred->cb) {
+        virReportError(VIR_ERR_LIBSSH, "%s",
+                       _("Can't perform authentication: Authentication callback not provided"));
+        return SSH_AUTH_ERROR;
+    }
+
     /* Try the authenticating the set amount of times. The server breaks the
      * connection if maximum number of bad auth tries is exceeded */
     while (true) {