render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Daniel P. Berrange 7d193b
diff -rupN libvirt-0.4.0.orig/src/remote_internal.c libvirt-0.4.0.new/src/remote_internal.c
Daniel P. Berrange 7d193b
--- libvirt-0.4.0.orig/src/remote_internal.c	2008-01-11 10:39:34.000000000 -0500
Daniel P. Berrange 7d193b
+++ libvirt-0.4.0.new/src/remote_internal.c	2008-01-11 10:43:12.000000000 -0500
Daniel P. Berrange 7d193b
@@ -3054,8 +3054,12 @@ remoteAuthSASL (virConnectPtr conn, stru
Daniel P. Berrange 7d193b
     if ((remoteAddr = addrToString(&sa, salen)) == NULL)
Daniel P. Berrange 7d193b
         goto cleanup;
Daniel P. Berrange 7d193b
 
Daniel P. Berrange 7d193b
-    if ((saslcb = remoteAuthMakeCallbacks(auth->credtype, auth->ncredtype)) == NULL)
Daniel P. Berrange 7d193b
-        goto cleanup;
Daniel P. Berrange 7d193b
+    if (auth) {
Daniel P. Berrange 7d193b
+        if ((saslcb = remoteAuthMakeCallbacks(auth->credtype, auth->ncredtype)) == NULL)
Daniel P. Berrange 7d193b
+            goto cleanup;
Daniel P. Berrange 7d193b
+    } else {
Daniel P. Berrange 7d193b
+        saslcb = NULL;
Daniel P. Berrange 7d193b
+    }
Daniel P. Berrange 7d193b
 
Daniel P. Berrange 7d193b
     /* Setup a handle for being a client */
Daniel P. Berrange 7d193b
     err = sasl_client_new("libvirt",
Daniel P. Berrange 7d193b
@@ -3168,15 +3172,21 @@ remoteAuthSASL (virConnectPtr conn, stru
Daniel P. Berrange 7d193b
             goto cleanup;
Daniel P. Berrange 7d193b
         }
Daniel P. Berrange 7d193b
         /* Run the authentication callback */
Daniel P. Berrange 7d193b
-        if ((*(auth->cb))(cred, ncred, auth->cbdata) < 0) {
Daniel P. Berrange 7d193b
+        if (auth && auth->cb) {
Daniel P. Berrange 7d193b
+            if ((*(auth->cb))(cred, ncred, auth->cbdata) < 0) {
Daniel P. Berrange 7d193b
+                __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
Daniel P. Berrange 7d193b
+                                 VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
Daniel P. Berrange 7d193b
+                                 "Failed to collect auth credentials");
Daniel P. Berrange 7d193b
+                goto cleanup;
Daniel P. Berrange 7d193b
+            }
Daniel P. Berrange 7d193b
+            remoteAuthFillInteract(cred, interact);
Daniel P. Berrange 7d193b
+            goto restart;
Daniel P. Berrange 7d193b
+        } else {
Daniel P. Berrange 7d193b
             __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
Daniel P. Berrange 7d193b
                              VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
Daniel P. Berrange 7d193b
-                             "Failed to collect auth credentials");
Daniel P. Berrange 7d193b
+                             "No authentication callback available");
Daniel P. Berrange 7d193b
             goto cleanup;
Daniel P. Berrange 7d193b
-            return -1;
Daniel P. Berrange 7d193b
         }
Daniel P. Berrange 7d193b
-        remoteAuthFillInteract(cred, interact);
Daniel P. Berrange 7d193b
-        goto restart;
Daniel P. Berrange 7d193b
     }
Daniel P. Berrange 7d193b
     free(iret.mechlist);
Daniel P. Berrange 7d193b
 
Daniel P. Berrange 7d193b
@@ -3240,15 +3250,22 @@ remoteAuthSASL (virConnectPtr conn, stru
Daniel P. Berrange 7d193b
                 return -1;
Daniel P. Berrange 7d193b
             }
Daniel P. Berrange 7d193b
             /* Run the authentication callback */
Daniel P. Berrange 7d193b
-            if ((*(auth->cb))(cred, ncred, auth->cbdata) < 0) {
Daniel P. Berrange 7d193b
+            if (auth && auth->cb) {
Daniel P. Berrange 7d193b
+                if ((*(auth->cb))(cred, ncred, auth->cbdata) < 0) {
Daniel P. Berrange 7d193b
+                    __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
Daniel P. Berrange 7d193b
+                                     VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
Daniel P. Berrange 7d193b
+                                     "Failed to collect auth credentials");
Daniel P. Berrange 7d193b
+                    goto cleanup;
Daniel P. Berrange 7d193b
+                    return -1;
Daniel P. Berrange 7d193b
+                }
Daniel P. Berrange 7d193b
+                remoteAuthFillInteract(cred, interact);
Daniel P. Berrange 7d193b
+                goto restep;
Daniel P. Berrange 7d193b
+            } else {
Daniel P. Berrange 7d193b
                 __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
Daniel P. Berrange 7d193b
                                  VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
Daniel P. Berrange 7d193b
-                                 "Failed to collect auth credentials");
Daniel P. Berrange 7d193b
+                                 "No authentication callback available");
Daniel P. Berrange 7d193b
                 goto cleanup;
Daniel P. Berrange 7d193b
-                return -1;
Daniel P. Berrange 7d193b
             }
Daniel P. Berrange 7d193b
-            remoteAuthFillInteract(cred, interact);
Daniel P. Berrange 7d193b
-            goto restep;
Daniel P. Berrange 7d193b
         }
Daniel P. Berrange 7d193b
 
Daniel P. Berrange 7d193b
         if (serverin) {
Daniel P. Berrange 7d193b
@@ -3319,7 +3336,8 @@ remoteAuthSASL (virConnectPtr conn, stru
Daniel P. Berrange 7d193b
     if (remoteAddr) free(remoteAddr);
Daniel P. Berrange 7d193b
     if (serverin) free(serverin);
Daniel P. Berrange 7d193b
 
Daniel P. Berrange 7d193b
-    free(saslcb);
Daniel P. Berrange 7d193b
+    if (saslcb)
Daniel P. Berrange 7d193b
+        free(saslcb);
Daniel P. Berrange 7d193b
     remoteAuthFreeCredentials(cred, ncred);
Daniel P. Berrange 7d193b
     if (ret != 0 && saslconn)
Daniel P. Berrange 7d193b
         sasl_dispose(&saslconn);