[lxc-devel] [lxd/master] ceph: sanitize path return from rbd map

brauner on Github lxc-bot at linuxcontainers.org
Thu Aug 31 00:33:20 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 381 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170831/a92acd5c/attachment.bin>
-------------- next part --------------
From baba9d5e556f76a78dbd3be281c645949597cb2a Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 31 Aug 2017 02:31:54 +0200
Subject: [PATCH] ceph: sanitize path return from rbd map

Closes #3726.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/storage_ceph_utils.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lxd/storage_ceph_utils.go b/lxd/storage_ceph_utils.go
index 060f30d12..1f4ec0e2e 100644
--- a/lxd/storage_ceph_utils.go
+++ b/lxd/storage_ceph_utils.go
@@ -133,6 +133,12 @@ func cephRBDVolumeMap(clusterName string, poolName string, volumeName string,
 		return "", err
 	}
 
+	idx := strings.Index(devPath, "/dev/rbd")
+	if idx < 0 {
+		return "", fmt.Errorf("Failed to detect mapped device path")
+	}
+
+	devPath = devPath[idx:]
 	return strings.TrimSpace(devPath), nil
 }
 


More information about the lxc-devel mailing list