]> xenbits.xensource.com Git - libvirt.git/commitdiff
nwfilter: Disallow binding creation in session mode
authorJohn Ferlan <jferlan@redhat.com>
Mon, 27 Aug 2018 14:41:35 +0000 (10:41 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 6 Sep 2018 22:38:06 +0000 (18:38 -0400)
Similar to nwfilterDefineXML, let's be sure the a filter binding
creation is not attempted in session mode and generate the proper
error message.

Failure to open nwfilter in session mode (nwfilterConnectOpen)
fails already, but that doesn't stop the free thinker from using
a different connection in order to attempt to attempt to create
the binding. Although even doing that would result in a failure:

$ virsh nwfilter-binding-create QEMUGuest1-binding.xml
error: Failed to create network filter from QEMUGuest1-binding.xml
error: internal error: Could not get access to ACL tech driver 'ebiptables'

$

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/nwfilter/nwfilter_driver.c

index ac3a96438855649dd7cc6b394c133c248ae1725a..1ee5162b9a3bddd3dd59552fa2e645c76880a3d5 100644 (file)
@@ -745,6 +745,12 @@ nwfilterBindingCreateXML(virConnectPtr conn,
 
     virCheckFlags(0, NULL);
 
+    if (!driver->privileged) {
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("Can't define NWFilter bindings in session mode"));
+        return NULL;
+    }
+
     def = virNWFilterBindingDefParseString(xml);
     if (!def)
         return NULL;