From 972391bfe97723300ba6f3978d0b8ac00bfed5de Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 21 Jun 2018 14:25:21 -0400 Subject: [PATCH] librbd: ensure groups and images remain in the same namespace Signed-off-by: Jason Dillaman --- src/librbd/api/Group.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/librbd/api/Group.cc b/src/librbd/api/Group.cc index c2627ba0fb6a6..1d9f6a3434d96 100644 --- a/src/librbd/api/Group.cc +++ b/src/librbd/api/Group.cc @@ -499,6 +499,11 @@ int Group::image_add(librados::IoCtx& group_ioctx, const char *group_name, << " group name " << group_name << " image " << &image_ioctx << " name " << image_name << dendl; + if (group_ioctx.get_namespace() != image_ioctx.get_namespace()) { + lderr(cct) << "group and image cannot be in different namespaces" << dendl; + return -EINVAL; + } + string group_id; int r = cls_client::dir_get_id(&group_ioctx, RBD_GROUP_DIRECTORY, group_name, @@ -573,6 +578,11 @@ int Group::image_remove(librados::IoCtx& group_ioctx, const char *group_name, << " group name " << group_name << " image " << &image_ioctx << " name " << image_name << dendl; + if (group_ioctx.get_namespace() != image_ioctx.get_namespace()) { + lderr(cct) << "group and image cannot be in different namespaces" << dendl; + return -EINVAL; + } + string group_id; int r = cls_client::dir_get_id(&group_ioctx, RBD_GROUP_DIRECTORY, group_name, -- 2.39.5