mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
src/driver.c: add virConnectValidateURIPath()
The code to validate the URI path is repeated across several files. This patch creates a common validation code to be used across all of them. Reviewed-by: Cole Robinson <crobinso@redhat.com> Suggested-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
7e490cdad6
commit
9c57fac9b7
26
src/driver.c
26
src/driver.c
@ -269,3 +269,29 @@ virSetConnectStorage(virConnectPtr conn)
|
||||
VIR_DEBUG("Override storage connection with %p", conn);
|
||||
return virThreadLocalSet(&connectStorage, conn);
|
||||
}
|
||||
|
||||
bool
|
||||
virConnectValidateURIPath(const char *uriPath,
|
||||
const char *entityName,
|
||||
bool privileged)
|
||||
{
|
||||
if (privileged) {
|
||||
if (STRNEQ(uriPath, "/system")) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected %s URI path '%s', try "
|
||||
"%s:///system"),
|
||||
entityName, uriPath, entityName);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (STRNEQ(uriPath, "/session")) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected %s URI path '%s', try "
|
||||
"%s:///session"),
|
||||
entityName, uriPath, entityName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -127,3 +127,7 @@ int virSetConnectNWFilter(virConnectPtr conn);
|
||||
int virSetConnectNodeDev(virConnectPtr conn);
|
||||
int virSetConnectSecret(virConnectPtr conn);
|
||||
int virSetConnectStorage(virConnectPtr conn);
|
||||
|
||||
bool virConnectValidateURIPath(const char *uriPath,
|
||||
const char *entityName,
|
||||
bool privileged);
|
||||
|
@ -1344,6 +1344,7 @@ virStreamClass;
|
||||
|
||||
|
||||
# driver.h
|
||||
virConnectValidateURIPath;
|
||||
virGetConnectInterface;
|
||||
virGetConnectNetwork;
|
||||
virGetConnectNodeDev;
|
||||
|
Loading…
x
Reference in New Issue
Block a user