From nobody Wed May 14 11:28:58 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 1523288775927996.3909796338608; Mon, 9 Apr 2018 08:46:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81F68C047B60; Mon, 9 Apr 2018 15:46:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B1005D9CD; Mon, 9 Apr 2018 15:46:14 +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 F1DCD4CAA7; Mon, 9 Apr 2018 15:46:13 +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 w39Fjxi5032419 for ; Mon, 9 Apr 2018 11:45:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1289F2024CA8; 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 6D5EA2024CA7; Mon, 9 Apr 2018 15:45:58 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 9 Apr 2018 16:45:49 +0100 Message-Id: <20180409154551.22604-7-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 6/8] driver: ensure NULL URI isn't passed to drivers with whitelisted URIs 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 09 Apr 2018 15:46:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensuring that we don't call the virDrvConnectOpen method with a NULL URI means that the drivers can drop various checks for NULL URIs. These were not needed anymore since the probe functionality was split Signed-off-by: Daniel P. Berrang=C3=A9 --- src/bhyve/bhyve_driver.c | 26 +++++++---------- src/esx/esx_driver.c | 4 --- src/hyperv/hyperv_driver.c | 4 --- src/interface/interface_backend_netcf.c | 40 +++++++++++-------------- src/interface/interface_backend_udev.c | 40 +++++++++++-------------- src/libvirt.c | 6 +++- src/libxl/libxl_driver.c | 34 ++++++++++----------- src/lxc/lxc_driver.c | 33 +++++++++------------ src/network/bridge_driver.c | 40 +++++++++++-------------- src/node_device/node_device_driver.c | 40 +++++++++++-------------- src/nwfilter/nwfilter_driver.c | 26 +++++++---------- src/openvz/openvz_driver.c | 38 +++++++++++------------- src/phyp/phyp_driver.c | 3 -- src/qemu/qemu_driver.c | 52 +++++++++++++++--------------= ---- src/secret/secret_driver.c | 40 +++++++++++-------------- src/storage/storage_driver.c | 40 +++++++++++-------------- src/test/test_driver.c | 4 --- src/uml/uml_driver.c | 44 +++++++++++++--------------- src/vbox/vbox_common.c | 3 -- src/vbox/vbox_driver.c | 3 -- src/vmware/vmware_driver.c | 17 ++++------- src/vz/vz_driver.c | 3 -- src/xenapi/xenapi_driver.c | 3 -- 23 files changed, 224 insertions(+), 319 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 21754dfc10..7d6439d79d 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -199,21 +199,17 @@ bhyveConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - if (STRNEQ_NULLABLE(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected bhyve URI path '%s', try bhyve://= /system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - - if (bhyve_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("bhyve state driver is not active")); - return VIR_DRV_OPEN_ERROR; - } + if (STRNEQ_NULLABLE(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected bhyve URI path '%s', try bhyve:///sy= stem"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + + if (bhyve_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("bhyve state driver is not active")); + return VIR_DRV_OPEN_ERROR; } =20 if (virConnectOpenEnsureACL(conn) < 0) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 9b6944ba59..335d9a970d 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -851,10 +851,6 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr a= uth, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Decline if the URI is NULL or the scheme is NULL */ - if (!conn->uri) - return VIR_DRV_OPEN_DECLINED; - if (STRCASENEQ(conn->uri->scheme, "vpx") && conn->uri->path && STRNEQ(conn->uri->path, "/")) { VIR_WARN("Ignoring unexpected path '%s' for non-vpx scheme '%s'", diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 4ad8855dcc..d02c0ac373 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -128,10 +128,6 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPt= r auth, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Decline if the URI is NULL or the scheme is NULL */ - if (conn->uri =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - /* Require server part */ if (conn->uri->server =3D=3D NULL) { virReportError(VIR_ERR_INVALID_ARG, "%s", diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index ff3443c8e6..cc2402febb 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -159,31 +159,25 @@ netcfConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("interface state driver is not active")); + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("interface state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try inte= rface:///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected interface URI path '%s', try = interface:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected interface URI path '%s', try = interface:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try inte= rface:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 743aafd8ba..4b975ae4b4 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -1203,31 +1203,25 @@ udevConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("interface state driver is not active")); + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("interface state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try inte= rface:///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected interface URI path '%s', try = interface:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected interface URI path '%s', try = interface:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try inte= rface:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/libvirt.c b/src/libvirt.c index cc1387341a..30345af10d 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1074,9 +1074,13 @@ virConnectOpenInternal(const char *name, } =20 /* Filter drivers based on declared URI schemes */ - if (virConnectDriverTab[i]->uriSchemes && ret->uri) { + if (virConnectDriverTab[i]->uriSchemes) { bool matchScheme =3D false; size_t s; + if (!ret->uri) { + 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; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 872790e743..45d0c99902 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -845,26 +845,22 @@ libxlConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - /* Error if xen or libxl scheme specified but driver not started. = */ - if (libxl_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("libxenlight state driver is not active")); - return VIR_DRV_OPEN_ERROR; - } + /* Error if xen or libxl scheme specified but driver not started. */ + if (libxl_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("libxenlight state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } =20 - /* /session isn't supported in libxenlight */ - if (conn->uri->path && - STRNEQ(conn->uri->path, "") && - STRNEQ(conn->uri->path, "/") && - STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected Xen URI path '%s', try xen:///sys= tem"), - NULLSTR(conn->uri->path)); - return VIR_DRV_OPEN_ERROR; - } + /* /session isn't supported in libxenlight */ + if (conn->uri->path && + STRNEQ(conn->uri->path, "") && + STRNEQ(conn->uri->path, "/") && + STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected Xen URI path '%s', try xen:///system"= ), + NULLSTR(conn->uri->path)); + return VIR_DRV_OPEN_ERROR; } =20 if (virConnectOpenEnsureACL(conn) < 0) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 8b01abf75f..2079dd0704 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -169,26 +169,21 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr = conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - /* If path isn't '/' then they typoed, tell them correct path */ - if (conn->uri->path !=3D NULL && - STRNEQ(conn->uri->path, "/") && - STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected LXC URI path '%s', try lxc:///sys= tem"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + /* If path isn't '/' then they typoed, tell them correct path */ + if (conn->uri->path !=3D NULL && + STRNEQ(conn->uri->path, "/") && + STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected LXC URI path '%s', try lxc:///system"= ), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } =20 - /* URI was good, but driver isn't active */ - if (lxc_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("lxc state driver is not active")); - return VIR_DRV_OPEN_ERROR; - } + /* URI was good, but driver isn't active */ + if (lxc_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("lxc state driver is not active")); + return VIR_DRV_OPEN_ERROR; } =20 if (virConnectOpenEnsureACL(conn) < 0) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 98754d4471..2e9191f75d 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -878,31 +878,25 @@ networkConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (network_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("network state driver is not active")); + if (network_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("network state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (network_driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected network URI path '%s', try networ= k:///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (network_driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected network URI path '%s', try ne= twork:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected network URI path '%s', try ne= twork:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected network URI path '%s', try networ= k:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index a3e3d76dfc..61afa1f8eb 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -54,31 +54,25 @@ nodeConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("nodedev state driver is not active")); + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("nodedev state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected nodedev URI path '%s', try nodede= v:///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected nodedev URI path '%s', try no= dedev:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected nodedev URI path '%s', try no= dedev:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected nodedev URI path '%s', try nodede= v:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 76289265a2..542de03596 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -371,23 +371,17 @@ nwfilterConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("nwfilter state driver is not active")); - return VIR_DRV_OPEN_ERROR; - } + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("nwfilter state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } =20 - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected nwfilter URI path '%s', try nwfil= ter:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected nwfilter URI path '%s', try nwfilter:= ///system"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } =20 if (virConnectOpenEnsureACL(conn) < 0) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 3eab3e47df..33893ac009 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1443,29 +1443,25 @@ static virDrvOpenStatus openvzConnectOpen(virConnec= tPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - /* If path isn't /system, then they typoed, so tell them correct p= ath */ - if (conn->uri->path =3D=3D NULL || - STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected OpenVZ URI path '%s', try openvz:= ///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + /* If path isn't /system, then they typoed, so tell them correct path = */ + if (conn->uri->path =3D=3D NULL || + STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected OpenVZ URI path '%s', try openvz:///s= ystem"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } =20 - if (!virFileExists("/proc/vz")) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("OpenVZ control file /proc/vz does not exist"= )); - return VIR_DRV_OPEN_ERROR; - } + if (!virFileExists("/proc/vz")) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("OpenVZ control file /proc/vz does not exist")); + return VIR_DRV_OPEN_ERROR; + } =20 - if (access("/proc/vz", W_OK) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("OpenVZ control file /proc/vz is not accessib= le")); - return VIR_DRV_OPEN_ERROR; - } + if (access("/proc/vz", W_OK) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("OpenVZ control file /proc/vz is not accessible")= ); + return VIR_DRV_OPEN_ERROR; } =20 /* We now know the URI is definitely for this driver, so beyond diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index ddbd9144bc..55d459df5c 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1141,9 +1141,6 @@ phypConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (!conn || !conn->uri) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->server =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing server name in phyp:// URI")); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8a6d3f9af0..e677bf13b5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1143,38 +1143,34 @@ static virDrvOpenStatus qemuConnectOpen(virConnectP= tr conn, virDrvOpenStatus ret =3D VIR_DRV_OPEN_ERROR; virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - if (qemu_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("qemu state driver is not active")); - goto cleanup; - } + if (qemu_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("qemu state driver is not active")); + goto cleanup; + } + + cfg =3D virQEMUDriverGetConfig(qemu_driver); + if (conn->uri->path =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no QEMU URI path given, try %s"), + cfg->uri); + goto cleanup; + } =20 - cfg =3D virQEMUDriverGetConfig(qemu_driver); - if (conn->uri->path =3D=3D NULL) { + if (virQEMUDriverIsPrivileged(qemu_driver)) { + if (STRNEQ(conn->uri->path, "/system") && + STRNEQ(conn->uri->path, "/session")) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("no QEMU URI path given, try %s"), - cfg->uri); + _("unexpected QEMU URI path '%s', try qemu:///s= ystem"), + conn->uri->path); goto cleanup; } - - if (virQEMUDriverIsPrivileged(qemu_driver)) { - if (STRNEQ(conn->uri->path, "/system") && - STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected QEMU URI path '%s', try qemu:= ///system"), - conn->uri->path); - goto cleanup; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected QEMU URI path '%s', try qemu:= ///session"), - conn->uri->path); - goto cleanup; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected QEMU URI path '%s', try qemu:///s= ession"), + conn->uri->path); + goto cleanup; } } =20 diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index aedfa10dcc..02fcaece35 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -524,31 +524,25 @@ secretConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("secret state driver is not active")); + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("secret state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected secret URI path '%s', try secret:= ///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected secret URI path '%s', try sec= ret:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected secret URI path '%s', try sec= ret:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected secret URI path '%s', try secret:= ///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 1a81733842..6104276730 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -384,31 +384,25 @@ storageConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("storage state driver is not active")); + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("storage state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected storage URI path '%s', try storag= e:///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected storage URI path '%s', try st= orage:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected storage URI path '%s', try st= orage:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected storage URI path '%s', try storag= e:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7f9c7f751e..56d496a849 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1454,10 +1454,6 @@ testConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (!conn->uri) - return VIR_DRV_OPEN_DECLINED; - - /* From this point on, the connection is for us. */ if (!conn->uri->path || conn->uri->path[0] =3D=3D '\0' || (conn->uri->path[0] =3D=3D '/' && conn->uri->path[1] =3D=3D '\0= ')) { diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 2315cd4d15..ac168ce77b 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1203,35 +1203,31 @@ static virDrvOpenStatus umlConnectOpen(virConnectPt= r conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - /* Check path and tell them correct path if they made a mistake */ - if (uml_driver->privileged) { - if (STRNEQ(conn->uri->path, "/system") && - STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected UML URI path '%s', try uml://= /system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected UML URI path '%s', try uml://= /session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + /* Check path and tell them correct path if they made a mistake */ + if (uml_driver->privileged) { + if (STRNEQ(conn->uri->path, "/system") && + STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected UML URI path '%s', try uml:///sys= tem"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } - - /* URI was good, but driver isn't active */ - if (uml_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("uml state driver is not active")); + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected UML URI path '%s', try uml:///ses= sion"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } } =20 + /* URI was good, but driver isn't active */ + if (uml_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("uml state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + if (virConnectOpenEnsureACL(conn) < 0) return VIR_DRV_OPEN_ERROR; =20 diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 4c4c80d45b..05cf9ad0de 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -517,9 +517,6 @@ vboxConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no VirtualBox driver path specified (try vbox://= /session)")); diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c index 395fa8e3d6..9e95ab01c5 100644 --- a/src/vbox/vbox_driver.c +++ b/src/vbox/vbox_driver.c @@ -58,9 +58,6 @@ static virDrvOpenStatus dummyConnectOpen(virConnectPtr co= nn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no VirtualBox driver path specified (try vbox://= /session)")); diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 6118e6fa13..de3708aab3 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -130,17 +130,12 @@ vmwareConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - /* @TODO accept */ - return VIR_DRV_OPEN_DECLINED; - } else { - /* If path isn't /session, then they typoed, so tell them correct = path */ - if (conn->uri->path =3D=3D NULL || STRNEQ(conn->uri->path, "/sessi= on")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected VMware URI path '%s', try vmwarep= layer:///session, vmwarews:///session or vmwarefusion:///session"), - NULLSTR(conn->uri->path)); - return VIR_DRV_OPEN_ERROR; - } + /* If path isn't /session, then they typoed, so tell them correct path= */ + if (conn->uri->path =3D=3D NULL || STRNEQ(conn->uri->path, "/session")= ) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected VMware URI path '%s', try vmwareplaye= r:///session, vmwarews:///session or vmwarefusion:///session"), + NULLSTR(conn->uri->path)); + return VIR_DRV_OPEN_ERROR; } =20 /* We now know the URI is definitely for this driver, so beyond diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index f3047cad6c..5867f1c911 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -358,9 +358,6 @@ vzConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (!conn->uri) - return VIR_DRV_OPEN_DECLINED; - /* From this point on, the connection is for us. */ if (STRNEQ_NULLABLE(conn->uri->path, "/system")) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 86f9e7706d..42b305d316 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -146,9 +146,6 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr= auth, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->server =3D=3D NULL) { xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG, _("Server name not in URI")); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list