]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: avoid duplicate openstack users
authorYehuda Sadeh <yehuda@hq.newdream.net>
Sat, 12 Mar 2011 00:50:51 +0000 (16:50 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Sat, 12 Mar 2011 00:50:51 +0000 (16:50 -0800)
src/rgw/rgw_admin.cc
src/rgw/rgw_user.cc

index 2ef6da11e274762085e4d4e8ccf70a7230d92083..1c529b6ba56e755ae81425db5dbb2600dd11e933 100644 (file)
@@ -315,7 +315,7 @@ int main(int argc, char **argv)
       info.openstack_name = openstack_user;
   
     if ((err = rgw_store_user_info(info)) < 0) {
-      cerr << "error storing user info" << strerror(-err) << std::endl;
+      cerr << "error storing user info" << strerror(-err) << std::endl;
       break;
     }
 
index f046c463fad1d8a378a54621af75b6a99a54cf25..406615622687b1ba252a37f310d252d1a9fbef23 100644 (file)
@@ -76,6 +76,16 @@ int rgw_store_user_info(RGWUserInfo& info)
   int ret;
   map<string,bufferlist> attrs;
 
+  if (info.openstack_name.size()) {
+    /* check if openstack mapping exists */
+    string os_uid;
+    int r = rgw_get_uid_by_openstack(info.openstack_name, os_uid);
+    if (r >= 0 && os_uid.compare(info.user_id) != 0) {
+      RGW_LOG(0) << "can't store user info, openstack id already mapped to another user" << std::endl;
+      return -EEXIST;
+    }
+  }
+
   ret = rgwstore->put_obj(info.user_id, ui_bucket, info.user_id, data, bl.length(), NULL, attrs);
 
   if (ret == -ENOENT) {