mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 03:21:19 +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 *
|
static virSecretDef *
|
||||||
virSecretDefParse(const char *xmlStr,
|
virSecretDefParse(const char *xmlStr,
|
||||||
const char *filename)
|
const char *filename,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
g_autoptr(xmlDoc) xml = NULL;
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
virSecretDef *ret = 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));
|
ret = secretXMLParseNode(xml, xmlDocGetRootElement(xml));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,15 +206,16 @@ virSecretDefParse(const char *xmlStr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virSecretDef *
|
virSecretDef *
|
||||||
virSecretDefParseString(const char *xmlStr)
|
virSecretDefParseString(const char *xmlStr,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
return virSecretDefParse(xmlStr, NULL);
|
return virSecretDefParse(xmlStr, NULL, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
virSecretDef *
|
virSecretDef *
|
||||||
virSecretDefParseFile(const char *filename)
|
virSecretDefParseFile(const char *filename)
|
||||||
{
|
{
|
||||||
return virSecretDefParse(NULL, filename);
|
return virSecretDefParse(NULL, filename, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -35,7 +35,7 @@ struct _virSecretDef {
|
|||||||
void virSecretDefFree(virSecretDef *def);
|
void virSecretDefFree(virSecretDef *def);
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSecretDef, virSecretDefFree);
|
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);
|
virSecretDef *virSecretDefParseFile(const char *filename);
|
||||||
char *virSecretDefFormat(const virSecretDef *def);
|
char *virSecretDefFormat(const virSecretDef *def);
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ secretDefineXML(virConnectPtr conn,
|
|||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
if (!(def = virSecretDefParseString(xml)))
|
if (!(def = virSecretDefParseString(xml, 0)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virSecretDefineXMLEnsureACL(conn, def) < 0)
|
if (virSecretDefineXMLEnsureACL(conn, def) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user