mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
Add ACL checks into the nwfilter driver
Insert calls to the ACL checking APIs in all nwfilter driver entrypoints. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
20d8e1f1d7
commit
1eca3f5bdf
@ -1391,8 +1391,13 @@ noinst_LTLIBRARIES += libvirt_driver_nwfilter.la
|
||||
# Stateful, so linked to daemon instead
|
||||
#libvirt_la_BUILT_LIBADD += libvirt_driver_nwfilter.la
|
||||
endif
|
||||
libvirt_driver_nwfilter_la_CFLAGS = $(LIBPCAP_CFLAGS) \
|
||||
-I$(top_srcdir)/src/conf $(LIBNL_CFLAGS) $(AM_CFLAGS) $(DBUS_CFLAGS)
|
||||
libvirt_driver_nwfilter_la_CFLAGS = \
|
||||
$(LIBPCAP_CFLAGS) \
|
||||
$(LIBNL_CFLAGS) \
|
||||
$(DBUS_CFLAGS) \
|
||||
-I$(top_srcdir)/src/access \
|
||||
-I$(top_srcdir)/src/conf \
|
||||
$(AM_CFLAGS)
|
||||
libvirt_driver_nwfilter_la_LDFLAGS = $(LD_AMFLAGS)
|
||||
libvirt_driver_nwfilter_la_LIBADD = $(LIBPCAP_LIBS) $(LIBNL_LIBS) $(DBUS_LIBS)
|
||||
if WITH_DRIVER_MODULES
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "nwfilter_gentech_driver.h"
|
||||
#include "configmake.h"
|
||||
#include "virstring.h"
|
||||
#include "viraccessapicheck.h"
|
||||
|
||||
#include "nwfilter_ipaddrmap.h"
|
||||
#include "nwfilter_dhcpsnoop.h"
|
||||
@ -374,6 +375,9 @@ nwfilterLookupByUUID(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virNWFilterLookupByUUIDEnsureACL(conn, nwfilter->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virGetNWFilter(conn, nwfilter->def->name, nwfilter->def->uuid);
|
||||
|
||||
cleanup:
|
||||
@ -400,6 +404,9 @@ nwfilterLookupByName(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virNWFilterLookupByNameEnsureACL(conn, nwfilter->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virGetNWFilter(conn, nwfilter->def->name, nwfilter->def->uuid);
|
||||
|
||||
cleanup:
|
||||
@ -434,6 +441,10 @@ nwfilterClose(virConnectPtr conn) {
|
||||
static int
|
||||
nwfilterConnectNumOfNWFilters(virConnectPtr conn) {
|
||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||
|
||||
if (virConnectNumOfNWFiltersEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
return driver->nwfilters.count;
|
||||
}
|
||||
|
||||
@ -445,6 +456,9 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
|
||||
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
|
||||
int got = 0, i;
|
||||
|
||||
if (virConnectListNWFiltersEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
nwfilterDriverLock(driver);
|
||||
for (i = 0; i < driver->nwfilters.count && got < nnames; i++) {
|
||||
virNWFilterObjLock(driver->nwfilters.objs[i]);
|
||||
@ -481,6 +495,9 @@ nwfilterConnectListAllNWFilters(virConnectPtr conn,
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (virConnectListAllNWFiltersEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
nwfilterDriverLock(driver);
|
||||
|
||||
if (!filters) {
|
||||
@ -537,6 +554,9 @@ nwfilterDefineXML(virConnectPtr conn,
|
||||
if (!(def = virNWFilterDefParseString(conn, xml)))
|
||||
goto cleanup;
|
||||
|
||||
if (virNWFilterDefineXMLEnsureACL(conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(nwfilter = virNWFilterObjAssignDef(conn, &driver->nwfilters, def)))
|
||||
goto cleanup;
|
||||
|
||||
@ -578,6 +598,9 @@ nwfilterUndefine(virNWFilterPtr obj) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virNWFilterUndefineEnsureACL(obj->conn, nwfilter->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virNWFilterTestUnassignDef(obj->conn, nwfilter) < 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s",
|
||||
@ -626,6 +649,9 @@ nwfilterGetXMLDesc(virNWFilterPtr obj,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virNWFilterGetXMLDescEnsureACL(obj->conn, nwfilter->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virNWFilterDefFormat(nwfilter->def);
|
||||
|
||||
cleanup:
|
||||
|
Loading…
Reference in New Issue
Block a user