Hi,

I found a new feature for s3cmd to support the IAM role. For this, I add
the "Security Token" parameter to the config file and add the field
"x-amz-security-token" in the HTTP Header. 

In attachement the patch for the version 1.1.0-beta3 of s3cmd.

Best regards,

-- 
Florent Kaisser.

TASKER S.A.S. - EuraTechnologies - 165 avenue de Bretagne - 59000 LILLE - 
France.
www.tasker.fr


diff -crB S3/Config.py ../s3cmd-1.1.0-fix/S3/Config.py
*** S3/Config.py	2012-01-06 10:02:15.000000000 +0100
--- ../s3cmd-1.1.0-fix/S3/Config.py	2012-11-08 18:37:05.717326868 +0100
***************
*** 16,21 ****
--- 16,22 ----
      _doc = {}
      access_key = ""
      secret_key = ""
+     security_token = ""
      host_base = "s3.amazonaws.com"
      host_bucket = "%(bucket)s.s3.amazonaws.com"
      simpledb_host = "sdb.amazonaws.com"
***************
*** 176,182 ****
                  if r_quotes.match(data["value"]):
                      data["value"] = data["value"][1:-1]
                  self.__setitem__(data["key"], data["value"])
!                 if data["key"] in ("access_key", "secret_key", "gpg_passphrase"):
                      print_value = (data["value"][:2]+"...%d_chars..."+data["value"][-1:]) % (len(data["value"]) - 3)
                  else:
                      print_value = data["value"]
--- 177,183 ----
                  if r_quotes.match(data["value"]):
                      data["value"] = data["value"][1:-1]
                  self.__setitem__(data["key"], data["value"])
!                 if data["key"] in ("access_key", "secret_key","security_token", "gpg_passphrase"):
                      print_value = (data["value"][:2]+"...%d_chars..."+data["value"][-1:]) % (len(data["value"]) - 3)
                  else:
                      print_value = data["value"]
diff -crB S3/S3.py ../s3cmd-1.1.0-fix/S3/S3.py
*** S3/S3.py	2012-01-12 03:12:37.000000000 +0100
--- ../s3cmd-1.1.0-fix/S3/S3.py	2012-11-08 19:17:18.377255582 +0100
***************
*** 64,69 ****
--- 64,70 ----
          self.method_string = method_string
          self.params = params
  
+         self.add_security_token()
          self.update_timestamp()
          self.sign()
  
***************
*** 72,77 ****
--- 73,82 ----
              del(self.headers["date"])
          self.headers["x-amz-date"] = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
  
+     def add_security_token(self):
+         if self.s3.config.security_token:
+             self.headers["x-amz-security-token"] = self.s3.config.security_token
+ 
      def format_param_str(self):
          """
          Format URL parameters from self.params and returns
Seulement dans ../s3cmd-1.1.0-fix/S3: S3.py~
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
S3tools-general mailing list
S3tools-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/s3tools-general

Reply via email to