[PATCH] Disable nwfilterDefineXML for unprivileged libvirtd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fail in a more friendly way than:
error: cannot create config directory (null): Bad address

https://bugzilla.redhat.com/show_bug.cgi?id=1029266
---
 src/nwfilter/nwfilter_driver.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 6602d73..c3ff4fe 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -551,13 +551,20 @@ nwfilterDefineXML(virConnectPtr conn,
                   const char *xml)
 {
     virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
-    virNWFilterDefPtr def;
+    virNWFilterDefPtr def = NULL;
     virNWFilterObjPtr nwfilter = NULL;
     virNWFilterPtr ret = NULL;
 
     nwfilterDriverLock(driver);
     virNWFilterCallbackDriversLock();
 
+    if (!driver->privileged) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+                       _("network filters are only available when libvirtd "
+                         "runs as root"));
+        goto cleanup;
+    }
+
     if (!(def = virNWFilterDefParseString(xml)))
         goto cleanup;
 
-- 
1.8.3.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]