]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
RgwStore: fix some ACL issues
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 25 May 2011 17:50:15 +0000 (10:50 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 25 May 2011 17:50:15 +0000 (10:50 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/obsync/obsync

index 09d79fa1a558e1aac303da6f32b1cc270cb633ed..7eed1bb93078bdb44a3179c3cb9e06c9b112e831 100755 (executable)
@@ -58,6 +58,7 @@ RGW_META_BUCKET_NAME = ".rgw"
 RGW_META_ETAG = "user.rgw.etag"
 RGW_META_PREFIX = "user.x-amz-meta-"
 RGW_META_CONTENT_TYPE = "user.content_type"
+RGW_META_ACL = "user.rgw.acl"
 
 ###### Exception classes #######
 class InvalidLocalName(Exception):
@@ -813,12 +814,19 @@ rgw:/path/to/ceph/conf:pool:key_prefix. Failed to find the bucket.")
         else:
             # Figure out what owner we should use when creating objects.
             # We use the owner of the destination bucket
-            bin_ = meta_ctx.get_xattr(self.rgw_bucket_name, "user.rgw.acl")
-            xml = lrgw.acl_bin2xml(bin_)
-            acl = AclPolicy.from_xml(obj.name, xml)
-            self.bucket_owner = acl.owner_id
-            if (self.more_verbose):
-                print "using owner \"%s\"" % self.bucket_owner
+            ioctx = self.rados.open_ioctx(RGW_META_BUCKET_NAME)
+            try:
+                bin_ = ioctx.get_xattr(self.rgw_bucket_name, RGW_META_ACL)
+                print "bin_ = %s" % type(bin_)
+                print "self.rgw_bucket_name=%s, len(bin_) = %d" % \
+                    (self.rgw_bucket_name, len(bin_))
+                xml = lrgw.acl_bin2xml(bin_)
+                acl = AclPolicy.from_xml(obj.name, xml)
+                self.bucket_owner = acl.owner_id
+                if (self.more_verbose):
+                    print "using owner \"%s\"" % self.bucket_owner
+            finally:
+               ioctx.close()
         self.ioctx = self.rados.open_ioctx(self.rgw_bucket_name)
         Store.__init__(self, "rgw:" + url)
     def create_rgw_bucket(self, rgw_bucket_name):
@@ -828,11 +836,11 @@ rgw:/path/to/ceph/conf:pool:key_prefix. Failed to find the bucket.")
             raise Exception("Can't create a bucket without knowing who " +
                     "should own it. Please set DST_OWNER")
         self.rados.create_pool(self.rgw_bucket_name)
-        meta_ctx = None
+        ioctx = None
         try:
-            meta_ctx = self.rados.open_ioctx(RGW_META_BUCKET_NAME)
-            meta_ctx.write(rgw_bucket_name, "", 0)
-            print "meta_ctx.set_xattr(rgw_bucket_name=" + rgw_bucket_name + ", " + \
+            ioctx = self.rados.open_ioctx(RGW_META_BUCKET_NAME)
+            ioctx.write(rgw_bucket_name, "", 0)
+            print "ioctx.set_xattr(rgw_bucket_name=" + rgw_bucket_name + ", " + \
                     "user.rgw.acl=" + self.dst_owner + ")"
             new_bucket_acl = "\
 <AccessControlPolicy xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"> \
@@ -843,10 +851,10 @@ xsi:type=\"CanonicalUser\"><ID>%s</ID> \
 <Permission>FULL_CONTROL</Permission></Grant>\
 </AccessControlList></AccessControlPolicy>" % (self.dst_owner, self.dst_owner)
             new_bucket_acl_bin = lrgw.acl_xml2bin(new_bucket_acl)
-            meta_ctx.set_xattr(rgw_bucket_name, "user.rgw.acl", new_bucket_acl_bin)
+            ioctx.set_xattr(rgw_bucket_name, "user.rgw.acl", new_bucket_acl_bin)
         finally:
-            if (meta_ctx):
-               meta_ctx.close()
+            if (ioctx):
+               ioctx.close()
     def obsync_obj_from_rgw(self, obj):
         """Create an obsync object from a Rados object"""
         try: