mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
secret_conf: add validation against schema in define
We need to validate the XML against schema if option '--validate' was passed to the virsh command. This patch also includes propagation of flags into the virSecretDefParse() function. Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6589794a1f
commit
9d482a415b
@ -191,12 +191,14 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root)
|
||||
|
||||
static virSecretDef *
|
||||
virSecretDefParse(const char *xmlStr,
|
||||
const char *filename)
|
||||
const char *filename,
|
||||
unsigned int flags)
|
||||
{
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
virSecretDef *ret = NULL;
|
||||
|
||||
if ((xml = virXMLParse(filename, xmlStr, _("(definition_of_secret)"), NULL, false))) {
|
||||
if ((xml = virXMLParse(filename, xmlStr, _("(definition_of_secret)"), "secret.rng",
|
||||
flags & VIR_SECRET_DEFINE_VALIDATE))) {
|
||||
ret = secretXMLParseNode(xml, xmlDocGetRootElement(xml));
|
||||
}
|
||||
|
||||
@ -204,15 +206,16 @@ virSecretDefParse(const char *xmlStr,
|
||||
}
|
||||
|
||||
virSecretDef *
|
||||
virSecretDefParseString(const char *xmlStr)
|
||||
virSecretDefParseString(const char *xmlStr,
|
||||
unsigned int flags)
|
||||
{
|
||||
return virSecretDefParse(xmlStr, NULL);
|
||||
return virSecretDefParse(xmlStr, NULL, flags);
|
||||
}
|
||||
|
||||
virSecretDef *
|
||||
virSecretDefParseFile(const char *filename)
|
||||
{
|
||||
return virSecretDefParse(NULL, filename);
|
||||
return virSecretDefParse(NULL, filename, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -35,7 +35,7 @@ struct _virSecretDef {
|
||||
void virSecretDefFree(virSecretDef *def);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSecretDef, virSecretDefFree);
|
||||
|
||||
virSecretDef *virSecretDefParseString(const char *xml);
|
||||
virSecretDef *virSecretDefParseString(const char *xml, unsigned int flags);
|
||||
virSecretDef *virSecretDefParseFile(const char *filename);
|
||||
char *virSecretDefFormat(const virSecretDef *def);
|
||||
|
||||
|
@ -222,7 +222,7 @@ secretDefineXML(virConnectPtr conn,
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
if (!(def = virSecretDefParseString(xml)))
|
||||
if (!(def = virSecretDefParseString(xml, 0)))
|
||||
return NULL;
|
||||
|
||||
if (virSecretDefineXMLEnsureACL(conn, def) < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user