]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Disable nwfilter driver when running unprivileged
authorJán Tomko <jtomko@redhat.com>
Tue, 12 Nov 2013 12:18:54 +0000 (13:18 +0100)
committerJán Tomko <jtomko@redhat.com>
Wed, 13 Nov 2013 09:36:04 +0000 (10:36 +0100)
When opening a new connection to the driver, nwfilterOpen
only succeeds if the driverState has been allocated.

Move the privilege check in driver initialization before
the state allocation to disable the driver.

This changes the nwfilter-define error from:
error: cannot create config directory (null): Bad address
To:
this function is not supported by the connection driver:
virNWFilterDefineXML

https://bugzilla.redhat.com/show_bug.cgi?id=1029266
(cherry picked from commit b7829f959b33c6e32422222a9ed745c0da7dc696)

src/nwfilter/nwfilter_driver.c

index d25c6f2be09248430c37105fff593159c3e7b2c3..0a4d60546895f8992aee2b8162a20b005669ab82 100644 (file)
@@ -174,6 +174,9 @@ nwfilterStateInitialize(bool privileged,
     char *base = NULL;
     DBusConnection *sysbus = NULL;
 
+    if (!privileged)
+        return 0;
+
 #if WITH_DBUS
     if (virDBusHasSystemBus())
         sysbus = virDBusGetSystemBus();
@@ -189,9 +192,6 @@ nwfilterStateInitialize(bool privileged,
     driverState->watchingFirewallD = (sysbus != NULL);
     driverState->privileged = privileged;
 
-    if (!privileged)
-        return 0;
-
     nwfilterDriverLock(driverState);
 
     if (virNWFilterIPAddrMapInit() < 0)