提交 91dd1b0f 编写于 作者: D Daniel P. Berrangé

driver: enforce a non-NULL URI scheme

Now that the legacy Xen driver has been dropped, we no longer need to
support URIs such as "/path/to/xend/socket", and so can mandate that a
URI scheme must always be present.
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 4c8574c8
......@@ -905,7 +905,7 @@ virConnectGetDefaultURI(virConfPtr conf,
static int
virConnectCheckURIMissingSlash(const char *uristr, virURIPtr uri)
{
if (!uri->scheme || !uri->path || !uri->server)
if (!uri->path || !uri->server)
return 0;
/* To avoid false positives, only check drivers that mandate
......@@ -1018,6 +1018,13 @@ virConnectOpenInternal(const char *name,
NULLSTR(ret->uri->user), ret->uri->port,
NULLSTR(ret->uri->path));
if (ret->uri->scheme == NULL) {
virReportError(VIR_ERR_NO_CONNECT,
_("URI '%s' does not include a driver name"),
name);
goto failed;
}
if (virConnectCheckURIMissingSlash(uristr,
ret->uri) < 0) {
goto failed;
......@@ -1038,7 +1045,7 @@ virConnectOpenInternal(const char *name,
* not being able to connect to libvirtd or not being able to find
* certificates. */
if (STREQ(virConnectDriverTab[i]->hypervisorDriver->name, "remote") &&
ret->uri != NULL && ret->uri->scheme != NULL &&
ret->uri != NULL &&
(
#ifndef WITH_PHYP
STRCASEEQ(ret->uri->scheme, "phyp") ||
......@@ -1081,10 +1088,6 @@ virConnectOpenInternal(const char *name,
VIR_DEBUG("No URI, skipping driver with URI whitelist");
continue;
}
if (!ret->uri->scheme) {
VIR_DEBUG("No URI scheme, skipping driver with URI whitelist");
continue;
}
VIR_DEBUG("Checking for supported URI schemes");
for (s = 0; virConnectDriverTab[i]->uriSchemes[s] != NULL; s++) {
if (STREQ(ret->uri->scheme, virConnectDriverTab[i]->uriSchemes[s])) {
......
......@@ -738,15 +738,6 @@ doRemoteOpen(virConnectPtr conn,
* URIs we don't care about */
if (conn->uri) {
if (!conn->uri->scheme) {
/* This is the ///var/lib/xen/xend-socket local path style */
if (!conn->uri->path)
return VIR_DRV_OPEN_DECLINED;
if (conn->uri->path[0] != '/')
return VIR_DRV_OPEN_DECLINED;
transport = trans_unix;
} else {
transport_str = get_transport_from_scheme(conn->uri->scheme);
if (!transport_str) {
......@@ -784,7 +775,6 @@ doRemoteOpen(virConnectPtr conn,
return VIR_DRV_OPEN_ERROR;
}
}
}
} else {
/* No URI, then must be probing so use UNIX socket */
transport = trans_unix;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册