提交 9c57fac9 编写于 作者: D Daniel Henrique Barboza 提交者: Cole Robinson

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: NCole Robinson <crobinso@redhat.com>
Suggested-by: NCole Robinson <crobinso@redhat.com>
Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
上级 7e490cda
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册