mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
virStorageSourceParseBackingJSONUri: Handle undocumented value 'off' for sslverify
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>
This commit is contained in:
parent
77194db01c
commit
5179cc6b08
@ -3278,16 +3278,23 @@ virStorageSourceParseBackingJSONUri(virStorageSourcePtr src,
|
|||||||
if (protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS ||
|
if (protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS ||
|
||||||
protocol == VIR_STORAGE_NET_PROTOCOL_FTPS) {
|
protocol == VIR_STORAGE_NET_PROTOCOL_FTPS) {
|
||||||
if (virJSONValueObjectHasKey(json, "sslverify")) {
|
if (virJSONValueObjectHasKey(json, "sslverify")) {
|
||||||
|
const char *tmpstr;
|
||||||
bool tmp;
|
bool tmp;
|
||||||
|
|
||||||
if (virJSONValueObjectGetBoolean(json, "sslverify", &tmp) < 0) {
|
/* libguestfs still uses undocumented legacy value of 'off' */
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
if ((tmpstr = virJSONValueObjectGetString(json, "sslverify")) &&
|
||||||
_("malformed 'sslverify' field in backing store definition '%s'"),
|
STREQ(tmpstr, "off")) {
|
||||||
jsonstr);
|
src->sslverify = VIR_TRISTATE_BOOL_NO;
|
||||||
return -1;
|
} 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1622,6 +1622,21 @@ mymain(void)
|
|||||||
" <timeout seconds='2000'/>\n"
|
" <timeout seconds='2000'/>\n"
|
||||||
"</source>\n", 0);
|
"</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 */
|
#endif /* WITH_YAJL */
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
Reference in New Issue
Block a user