rpms/libvirt/F-7 libvirt-0.4.0-auth-null-cb-2.patch, NONE, 1.1 libvirt-0.4.0-auth-null-cb.patch, NONE, 1.1 libvirt.spec, 1.64, 1.65

Daniel P. Berrange (berrange) fedora-extras-commits at redhat.com
Mon Jan 14 04:16:14 UTC 2008


Author: berrange

Update of /cvs/pkgs/rpms/libvirt/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv21301

Modified Files:
	libvirt.spec 
Added Files:
	libvirt-0.4.0-auth-null-cb-2.patch 
	libvirt-0.4.0-auth-null-cb.patch 
Log Message:
Fix crash when no auth callback

libvirt-0.4.0-auth-null-cb-2.patch:

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

libvirt-0.4.0-auth-null-cb.patch:

--- NEW FILE libvirt-0.4.0-auth-null-cb.patch ---
diff -rup libvirt-0.4.0.orig/src/remote_internal.c libvirt-0.4.0.new/src/remote_internal.c
--- libvirt-0.4.0.orig/src/remote_internal.c	2007-12-17 16:51:09.000000000 -0500
+++ libvirt-0.4.0.new/src/remote_internal.c	2008-01-02 16:28:44.000000000 -0500
@@ -3347,24 +3347,26 @@ remoteAuthPolkit (virConnectPtr conn, st
     };
     remoteDebug(priv, "Client initialize PolicyKit authentication");
 
-    for (i = 0 ; i < auth->ncredtype ; i++) {
-        if (auth->credtype[i] == VIR_CRED_EXTERNAL)
-            allowcb = 1;
-    }
+    if (auth && auth->cb) {
+        /* Check if the neccessary credential type for PolicyKit is supported */
+        for (i = 0 ; i < auth->ncredtype ; i++) {
+            if (auth->credtype[i] == VIR_CRED_EXTERNAL)
+                allowcb = 1;
+        }
 
-    /* Run the authentication callback */
-    if (allowcb) {
-        if (auth && auth->cb &&
-            (*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
-            __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
-                             VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
-                             "Failed to collect auth credentials");
-            return -1;
+        if (allowcb) {
+            /* Run the authentication callback */
+            if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
+                __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
+                                 VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
+                                 "Failed to collect auth credentials");
+                return -1;
+            }
         } else {
-            remoteDebug(priv, "No auth callback provided for PolicyKit");
+            remoteDebug(priv, "Client auth callback does not support PolicyKit");
         }
     } else {
-        remoteDebug(priv, "Client auth callback does not support PolicyKit");
+        remoteDebug(priv, "No auth callback provided");
     }
 
     memset (&ret, 0, sizeof ret);


Index: libvirt.spec
===================================================================
RCS file: /cvs/pkgs/rpms/libvirt/F-7/libvirt.spec,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- libvirt.spec	2 Jan 2008 21:58:20 -0000	1.64
+++ libvirt.spec	14 Jan 2008 04:15:37 -0000	1.65
@@ -15,7 +15,9 @@
 License: LGPL
 Group: Development/Libraries
 Source: libvirt-%{version}.tar.gz
-Patch1: libvirt-%{version}-conffile-size.patch
+Patch1: libvirt-%{version}-auth-null-cb.patch
+Patch2: libvirt-%{version}-conffile-size.patch
+Patch3: libvirt-%{version}-auth-null-cb-2.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-root
 URL: http://libvirt.org/
 BuildRequires: python python-devel
@@ -86,6 +88,8 @@
 %prep
 %setup -q
 %patch1 -p1
+%patch2 -p1
+%patch3 -p1
 
 %build
 %configure --with-init-script=redhat --with-qemud-pid-file=%{_localstatedir}/run/libvirt_qemud.pid --with-remote-file=%{_localstatedir}/run/libvirtd.pid
@@ -205,6 +209,9 @@
 %doc docs/examples/python
 
 %changelog
+* Sun Jan 13 2008 Daniel P. Berrange <berrange at redhat.com> - 0.4.0-3.fc7
+- Fix crash when no auth callback
+
 * Wed Jan  2 2008 Daniel P. Berrange <berrange at redhat.com> - 0.4.0-2.fc7
 - Fix reading large config files (rhbz #426425)
 




More information about the fedora-extras-commits mailing list