[lxc-devel] [lxd/master] lxc/storage/volume: Adds volume snapshot rename check for same parent…

tomponline on Github lxc-bot at linuxcontainers.org
Wed Oct 23 13:57:07 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 375 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191023/ff15ac9c/attachment.bin>
-------------- next part --------------
From 316e1f0847b2ca3b7dd5774f5cd3929db39cd449 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 23 Oct 2019 14:55:41 +0100
Subject: [PATCH] lxc/storage/volume: Adds volume snapshot rename check for
 same parent volume

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxc/storage_volume.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lxc/storage_volume.go b/lxc/storage_volume.go
index 9bdc70de5e..33e5d85d31 100644
--- a/lxc/storage_volume.go
+++ b/lxc/storage_volume.go
@@ -1214,7 +1214,11 @@ func (c *cmdStorageVolumeRename) Run(cmd *cobra.Command, args []string) error {
 	if isSnapshot {
 		// Create the storage volume entry
 		vol := api.StorageVolumeSnapshotPost{}
-		_, dstSnapName, dstIsSnap := shared.ContainerGetParentAndSnapshotName(args[2])
+		dstParentName, dstSnapName, dstIsSnap := shared.ContainerGetParentAndSnapshotName(args[2])
+
+		if dstParentName != fields[0] {
+			return fmt.Errorf("Invalid new snapshot name, parent volume must be the same as source")
+		}
 
 		if !dstIsSnap {
 			return fmt.Errorf("Invalid new snapshot name")


More information about the lxc-devel mailing list