summaryrefslogtreecommitdiff
path: root/src/obsync
diff options
context:
space:
mode:
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>2011-05-25 10:50:15 -0700
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>2011-05-25 10:50:15 -0700
commit7de7ba001240cb6a1fe0e5f09cf79cafd7e2f4e6 (patch)
treed5bfe5d0a839983b89716eab715aec8527454d4e /src/obsync
parent3f5f5620731fa2416b025a41c72c31ac1f3b082f (diff)
downloadceph-7de7ba001240cb6a1fe0e5f09cf79cafd7e2f4e6.tar.gz
RgwStore: fix some ACL issues
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
Diffstat (limited to 'src/obsync')
-rwxr-xr-xsrc/obsync/obsync34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/obsync/obsync b/src/obsync/obsync
index 09d79fa1a55..7eed1bb9307 100755
--- a/src/obsync/obsync
+++ b/src/obsync/obsync
@@ -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: