[libvirt] [PATCH] qemu: Forbid snapshot names starting with '.'

Forbid the names to match the loading procedure of snapshots. --- src/qemu/qemu_driver.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3a54228..8286334 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11348,13 +11348,23 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, goto cleanup; /* reject snapshot names containing slashes as snapshot definitions are - * saved in files containing the name */ - if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) && - strchr(def->name, '/')) { - virReportError(VIR_ERR_XML_DETAIL, - _("invalid snapshot name '%s': name can't contain '/'"), - def->name); - goto cleanup; + * saved in files containing the name and names starting with dots */ + if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { + if (strchr(def->name, '/')) { + virReportError(VIR_ERR_XML_DETAIL, + _("invalid snapshot name '%s': " + "name can't contain '/'"), + def->name); + goto cleanup; + } + + if (def->name[0] == '.') { + virReportError(VIR_ERR_XML_DETAIL, + _("invalid snapshot name '%s': " + "name can't start with '.'"), + def->name); + goto cleanup; + } } /* reject the VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag where not supported */ -- 1.8.1.1

On 01/21/2013 10:10 PM, Peter Krempa wrote:
Forbid the names to match the loading procedure of snapshots. --- src/qemu/qemu_driver.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3a54228..8286334 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11348,13 +11348,23 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, goto cleanup;
/* reject snapshot names containing slashes as snapshot definitions are - * saved in files containing the name */ - if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) && - strchr(def->name, '/')) { - virReportError(VIR_ERR_XML_DETAIL, - _("invalid snapshot name '%s': name can't contain '/'"), - def->name); - goto cleanup; + * saved in files containing the name and names starting with dots */ + if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { + if (strchr(def->name, '/')) { + virReportError(VIR_ERR_XML_DETAIL, + _("invalid snapshot name '%s': " + "name can't contain '/'"), + def->name); + goto cleanup; + } + + if (def->name[0] == '.') { + virReportError(VIR_ERR_XML_DETAIL, + _("invalid snapshot name '%s': " + "name can't start with '.'"), + def->name); + goto cleanup; + } }
/* reject the VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag where not supported */
I'd change the comment to something more readable, like "reject snapshot names containing slashes or starting with dot as snapshot definitions are saved in files containing the name" for example, but it's just a comment, so ACK either way. Martin

On 01/22/13 11:31, Martin Kletzander wrote:
On 01/21/2013 10:10 PM, Peter Krempa wrote:
Forbid the names to match the loading procedure of snapshots. --- src/qemu/qemu_driver.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
I'd change the comment to something more readable, like "reject snapshot names containing slashes or starting with dot as snapshot definitions are saved in files containing the name" for example, but it's just a comment, so ACK either way.
Thanks, I used your wording of the comment and pushed the patch. Peter
Martin
participants (2)
-
Martin Kletzander
-
Peter Krempa