Permalink
Browse files

* s3cmd, S3/ACL.py, S3/Config.py: Support for --acl-grant

  and --acl-revoke (contributed by Timothee Linden)



git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@407 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information...
1 parent b0b9791 commit 0a25a9f408a784a3a4f226fe82e6e7d43c5026c6 ludvigm committed May 20, 2010
Showing with 59 additions and 1 deletion.
  1. +5 −0 ChangeLog
  2. +1 −0 NEWS
  3. +50 −0 S3/ACL.py
  4. +3 −1 S3/Config.py
View
@@ -1,5 +1,10 @@
2010-05-20 Michal Ludvig <mludvig@logix.net.nz>
+ * s3cmd, S3/ACL.py, S3/Config.py: Support for --acl-grant
+ and --acl-revoke (contributed by Timothee Linden)
+
+2010-05-20 Michal Ludvig <mludvig@logix.net.nz>
+
* S3/Exceptions.py, S3/S3.py: Some HTTP_400 exceptions
are retriable.
View
1 NEWS
@@ -1,6 +1,7 @@
s3cmd 0.9.9.92 - ???
==============
* Added [accesslog] command. (needs manpage!)
+* Added --acl-grant and --acl-revoke (by Timothee Linden).
s3cmd 0.9.9.91 - 2009-10-08
==============
View
@@ -129,6 +129,56 @@ def revokeAnonRead(self):
def appendGrantee(self, grantee):
self.grantees.append(grantee)
+ def hasGrant(self, name, permission):
+ name = name.lower()
+ permission = permission.upper()
+
+ for grantee in self.grantees:
+ if grantee.name.lower() == name:
+ if grantee.permission == "FULL_CONTROL":
+ return True
+ elif grantee.permission.upper() == permission:
+ return True
+
+ return False;
+
+ def grant(self, name, permission):
+ if self.hasGrant(name, permission):
+ return
+
+ name = name.lower()
+ permission = permission.upper()
+
+ if "ALL" == permission:
+ permission = "FULL_CONTROL"
+
+ if "FULL_CONTROL" == permission:
+ self.revoke(name, "ALL")
+
+ grantee = Grantee()
+ grantee.name = name
+ grantee.permission = permission
+
+ if name.find('@') <= -1: # ultra lame attempt to differenciate emails id from canonical ids
+ grantee.xsi_type = "CanonicalUser"
+ grantee.tag = "ID"
+ else:
+ grantee.xsi_type = "AmazonCustomerByEmail"
+ grantee.tag = "EmailAddress"
+
+ self.appendGrantee(grantee)
+
+
+ def revoke(self, name, permission):
+ name = name.lower()
+ permission = permission.upper()
+
+ if "ALL" == permission:
+ self.grantees = [g for g in self.grantees if not g.name.lower() == name]
+ else:
+ self.grantees = [g for g in self.grantees if not (g.name.lower() == name and g.permission.upper() == permission)]
+
+
def __str__(self):
tree = getTreeFromXml(ACL.EMPTY_ACL)
tree.attrib['xmlns'] = "http://s3.amazonaws.com/doc/2006-03-01/"
View
@@ -33,7 +33,9 @@ class Config(object):
get_continue = False
skip_existing = False
recursive = False
- acl_public = False
+ acl_public = None
+ acl_grants = []
+ acl_revokes = []
proxy_host = ""
proxy_port = 3128
encrypt = False

0 comments on commit 0a25a9f

Please sign in to comment.