From nobody Wed May 14 11:31:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523288778906940.3416656033714; Mon, 9 Apr 2018 08:46:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A53BC9B426; Mon, 9 Apr 2018 15:46:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6594161783; Mon, 9 Apr 2018 15:46:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1A7B5180BAE6; Mon, 9 Apr 2018 15:46:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w39Fk03Q032433 for ; Mon, 9 Apr 2018 11:46:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id F12BC2024CA8; Mon, 9 Apr 2018 15:45:59 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A2A92024CA7; Mon, 9 Apr 2018 15:45:59 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 9 Apr 2018 16:45:50 +0100 Message-Id: <20180409154551.22604-8-berrange@redhat.com> In-Reply-To: <20180409154551.22604-1-berrange@redhat.com> References: <20180409154551.22604-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/8] driver: enforce a non-NULL URI scheme X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 09 Apr 2018 15:46:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 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: Daniel P. Berrang=C3=A9 --- src/libvirt.c | 15 ++++++---- src/remote/remote_driver.c | 74 ++++++++++++++++++++----------------------= ---- 2 files changed, 41 insertions(+), 48 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 30345af10d..600beaa4d5 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -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; =20 /* 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)); =20 + if (ret->uri->scheme =3D=3D 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 !=3D NULL && ret->uri->scheme !=3D NULL && + ret->uri !=3D 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 whiteli= st"); - continue; - } VIR_DEBUG("Checking for supported URI schemes"); for (s =3D 0; virConnectDriverTab[i]->uriSchemes[s] !=3D NULL;= s++) { if (STREQ(ret->uri->scheme, virConnectDriverTab[i]->uriSch= emes[s])) { diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 901a2ebfbd..ce2ea27cd8 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -771,51 +771,41 @@ doRemoteOpen(virConnectPtr conn, * URIs we don't care about */ =20 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] !=3D '/') - return VIR_DRV_OPEN_DECLINED; - - transport =3D trans_unix; - } else { - transport_str =3D get_transport_from_scheme(conn->uri->scheme); + transport_str =3D get_transport_from_scheme(conn->uri->scheme); =20 - if (!transport_str) { - if (conn->uri->server) - transport =3D trans_tls; - else - transport =3D trans_unix; - } else { - if (STRCASEEQ(transport_str, "tls")) { - transport =3D trans_tls; - } else if (STRCASEEQ(transport_str, "unix")) { - if (conn->uri->server) { - virReportError(VIR_ERR_INVALID_ARG, - _("using unix socket and remote " - "server '%s' is not supported."), - conn->uri->server); - return VIR_DRV_OPEN_ERROR; - } else { - transport =3D trans_unix; - } - } else if (STRCASEEQ(transport_str, "ssh")) { - transport =3D trans_ssh; - } else if (STRCASEEQ(transport_str, "libssh2")) { - transport =3D trans_libssh2; - } else if (STRCASEEQ(transport_str, "ext")) { - transport =3D trans_ext; - } else if (STRCASEEQ(transport_str, "tcp")) { - transport =3D trans_tcp; - } else if (STRCASEEQ(transport_str, "libssh")) { - transport =3D trans_libssh; - } else { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("remote_open: transport in URL not re= cognised " - "(should be tls|unix|ssh|ext|tcp|libs= sh2)")); + if (!transport_str) { + if (conn->uri->server) + transport =3D trans_tls; + else + transport =3D trans_unix; + } else { + if (STRCASEEQ(transport_str, "tls")) { + transport =3D trans_tls; + } else if (STRCASEEQ(transport_str, "unix")) { + if (conn->uri->server) { + virReportError(VIR_ERR_INVALID_ARG, + _("using unix socket and remote " + "server '%s' is not supported."), + conn->uri->server); return VIR_DRV_OPEN_ERROR; + } else { + transport =3D trans_unix; } + } else if (STRCASEEQ(transport_str, "ssh")) { + transport =3D trans_ssh; + } else if (STRCASEEQ(transport_str, "libssh2")) { + transport =3D trans_libssh2; + } else if (STRCASEEQ(transport_str, "ext")) { + transport =3D trans_ext; + } else if (STRCASEEQ(transport_str, "tcp")) { + transport =3D trans_tcp; + } else if (STRCASEEQ(transport_str, "libssh")) { + transport =3D trans_libssh; + } else { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("remote_open: transport in URL not recogn= ised " + "(should be tls|unix|ssh|ext|tcp|libssh2)= ")); + return VIR_DRV_OPEN_ERROR; } } } else { --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list