Browse code

2007-09-25 Michal Ludvig <michal@logix.cz>

* S3/S3.py: Don't fail if bucket listing doesn't have
<IsTruncated> node.
* s3cmd: Create ~/.s3cfg with 0600 permissions.



git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@149 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2007/09/25 20:19:33
Showing 4 changed files
... ...
@@ -1,3 +1,9 @@
1
+2007-09-25  Michal Ludvig  <michal@logix.cz>
2
+
3
+	* S3/S3.py: Don't fail if bucket listing doesn't have
4
+	  <IsTruncated> node.
5
+	* s3cmd: Create ~/.s3cfg with 0600 permissions.
6
+
1 7
 2007-09-13  Michal Ludvig  <michal@logix.cz>
2 8
 
3 9
 	* s3cmd: Improved 'sync'
... ...
@@ -106,7 +106,9 @@ class S3(object):
106 106
 	
107 107
 	def bucket_list(self, bucket, prefix = None):
108 108
 		def _list_truncated(data):
109
-			return getTextFromXml(data, ".//IsTruncated").lower() != "false"
109
+			## <IsTruncated> can either be "true" or "false" or be missing completely
110
+			is_truncated = getTextFromXml(data, ".//IsTruncated") or "false"
111
+			return is_truncated.lower() != "false"
110 112
 
111 113
 		def _get_contents(data):
112 114
 			return getListFromXml(data, "Contents")
... ...
@@ -9,6 +9,7 @@ import re
9 9
 import string
10 10
 import random
11 11
 import md5
12
+import errno
12 13
 
13 14
 try:
14 15
 	import xml.etree.ElementTree as ET
... ...
@@ -10,6 +10,7 @@ import logging
10 10
 import time
11 11
 import os
12 12
 import re
13
+import errno
13 14
 
14 15
 from copy import copy
15 16
 from optparse import OptionParser, Option, OptionValueError, IndentedHelpFormatter
... ...
@@ -516,7 +517,16 @@ def run_configure(config_file):
516 516
 			val = raw_input("Retry configuration? [Y/n] ")
517 517
 			if val.lower().startswith("n"):
518 518
 				raise EOFError()
519
+
520
+		## Overwrite existing config file, make it user-readable only
521
+		old_mask = os.umask(0077)
522
+		try:
523
+			os.remove(config_file)
524
+		except OSError, e:
525
+			if e.errno != errno.ENOENT:
526
+				raise
519 527
 		f = open(config_file, "w")
528
+		os.umask(old_mask)
520 529
 		cfg.dump_config(f)
521 530
 		f.close()
522 531
 		output("Configuration saved to '%s'" % config_file)