]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: return default policy if policy attr is broken
authorYehuda Sadeh <yehuda@inktank.com>
Wed, 30 May 2012 22:28:19 +0000 (15:28 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 30 May 2012 23:22:51 +0000 (16:22 -0700)
In case the policy attr on object/bucket is broken
return a default policy, in which the owner is set
as the bucket owner.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_op.cc

index d88438c5d8ef6710d029d1174434f435841c4f4c..022fcd90c471f58755c4e11ef0615e3245712a71 100644 (file)
@@ -186,9 +186,23 @@ static int get_policy_from_attr(CephContext *cct, void *ctx, RGWAccessControlPol
         s3policy->to_xml(*_dout);
         *_dout << dendl;
       }
+    } else if (ret == -ENODATA) {
+      /* object exists, but policy is broken */
+      RGWBucketInfo info;
+      RGWUserInfo uinfo;
+      string name;
+      int r = rgwstore->get_bucket_info(ctx, obj.bucket.name, info);
+      if (r < 0)
+        goto done;
+      r = rgw_get_user_info_by_uid(info.owner, uinfo);
+      if (r < 0)
+        goto done;
+
+      policy->create_default(info.owner, uinfo.display_name);
+      ret = 0;
     }
   }
-
+done:
   return ret;
 }