forked from rpms/libvirt
93 lines
4.1 KiB
Diff
93 lines
4.1 KiB
Diff
|
From a5496b797498dc5393ccbf2775a2947e67a804eb Mon Sep 17 00:00:00 2001
|
||
|
Message-Id: <a5496b797498dc5393ccbf2775a2947e67a804eb@dist-git>
|
||
|
From: Peter Krempa <pkrempa@redhat.com>
|
||
|
Date: Mon, 16 Mar 2020 22:12:08 +0100
|
||
|
Subject: [PATCH] virStorageSourceParseBackingJSONUri: Handle undocumented
|
||
|
value 'off' for sslverify
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
libguestfs abuses a quirk of qemu's parser to accept also other variants
|
||
|
of the 'sslverify' field which would be valid on the command line but
|
||
|
are not documented in the QMP schema.
|
||
|
|
||
|
If we encounter the 'off' string instead of an boolean handle it rather
|
||
|
than erroring out to continue support of pre-blockdev configurations.
|
||
|
|
||
|
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
||
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||
|
(cherry picked from commit 5179cc6b08a06fad92e8674d048fc0327d48f79e)
|
||
|
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
|
||
|
Message-Id: <8f277a7bede59b7c8b6de9db9c7726b6cbe02192.1584391727.git.pkrempa@redhat.com>
|
||
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||
|
---
|
||
|
src/util/virstoragefile.c | 21 ++++++++++++++-------
|
||
|
tests/virstoragetest.c | 15 +++++++++++++++
|
||
|
2 files changed, 29 insertions(+), 7 deletions(-)
|
||
|
|
||
|
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
|
||
|
index 931f2db6e9..9eca186e99 100644
|
||
|
--- a/src/util/virstoragefile.c
|
||
|
+++ b/src/util/virstoragefile.c
|
||
|
@@ -3278,16 +3278,23 @@ virStorageSourceParseBackingJSONUri(virStorageSourcePtr src,
|
||
|
if (protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS ||
|
||
|
protocol == VIR_STORAGE_NET_PROTOCOL_FTPS) {
|
||
|
if (virJSONValueObjectHasKey(json, "sslverify")) {
|
||
|
+ const char *tmpstr;
|
||
|
bool tmp;
|
||
|
|
||
|
- if (virJSONValueObjectGetBoolean(json, "sslverify", &tmp) < 0) {
|
||
|
- virReportError(VIR_ERR_INVALID_ARG,
|
||
|
- _("malformed 'sslverify' field in backing store definition '%s'"),
|
||
|
- jsonstr);
|
||
|
- return -1;
|
||
|
- }
|
||
|
+ /* libguestfs still uses undocumented legacy value of 'off' */
|
||
|
+ if ((tmpstr = virJSONValueObjectGetString(json, "sslverify")) &&
|
||
|
+ STREQ(tmpstr, "off")) {
|
||
|
+ src->sslverify = VIR_TRISTATE_BOOL_NO;
|
||
|
+ } else {
|
||
|
+ if (virJSONValueObjectGetBoolean(json, "sslverify", &tmp) < 0) {
|
||
|
+ virReportError(VIR_ERR_INVALID_ARG,
|
||
|
+ _("malformed 'sslverify' field in backing store definition '%s'"),
|
||
|
+ jsonstr);
|
||
|
+ return -1;
|
||
|
+ }
|
||
|
|
||
|
- src->sslverify = virTristateBoolFromBool(tmp);
|
||
|
+ src->sslverify = virTristateBoolFromBool(tmp);
|
||
|
+ }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
|
||
|
index 63b991eb71..ca428f5ca7 100644
|
||
|
--- a/tests/virstoragetest.c
|
||
|
+++ b/tests/virstoragetest.c
|
||
|
@@ -1621,6 +1621,21 @@ mymain(void)
|
||
|
" <timeout seconds='2000'/>\n"
|
||
|
"</source>\n", 0);
|
||
|
|
||
|
+ TEST_BACKING_PARSE_FULL("json:{ \"file.cookie\": \"vmware_soap_session=\\\"0c8db85112873a79b7ef74f294cb70ef7f\\\"\","
|
||
|
+ "\"file.sslverify\": \"off\","
|
||
|
+ "\"file.driver\": \"https\","
|
||
|
+ "\"file.url\": \"https://host/folder/esx6.5-rhel7.7-x86%5f64/esx6.5-rhel7.7-x86%5f64-flat.vmdk?dcPath=data&dsName=esx6.5-matrix\","
|
||
|
+ "\"file.timeout\": 2000"
|
||
|
+ "}",
|
||
|
+ "<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk'>\n"
|
||
|
+ " <host name='host' port='443'/>\n"
|
||
|
+ " <ssl verify='no'/>\n"
|
||
|
+ " <cookies>\n"
|
||
|
+ " <cookie name='vmware_soap_session'>"0c8db85112873a79b7ef74f294cb70ef7f"</cookie>\n"
|
||
|
+ " </cookies>\n"
|
||
|
+ " <timeout seconds='2000'/>\n"
|
||
|
+ "</source>\n", 0);
|
||
|
+
|
||
|
#endif /* WITH_YAJL */
|
||
|
|
||
|
cleanup:
|
||
|
--
|
||
|
2.25.1
|
||
|
|