Skip to content

Commit 301f11f

Browse files
committed
Fixes #894 - Detect and report error 403 in getpolicy for info command
+ Cosmetic fixes for "info".
1 parent f351b36 commit 301f11f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

s3cmd

+10-6
Original file line numberDiff line numberDiff line change
@@ -930,26 +930,28 @@ def cmd_info(args):
930930

931931
try:
932932
policy = s3.get_policy(uri)
933-
output(u" policy: %s" % policy)
933+
output(u" Policy: %s" % policy)
934934
except S3Error as exc:
935935
# Ignore the exception and don't fail the info
936936
# if the server doesn't support setting ACLs
937-
if exc.status == 405:
938-
output(u" policy: Not available: Only the bucket owner can read the policy")
937+
if exc.status == 403:
938+
output(u" Policy: Not available: GetPolicy permission is needed to read the policy")
939+
elif exc.status == 405:
940+
output(u" Policy: Not available: Only the bucket owner can read the policy")
939941
elif exc.status not in [404, 501]:
940942
raise exc
941943
else:
942-
output(u" policy: none")
944+
output(u" Policy: none")
943945

944946
try:
945947
cors = s3.get_cors(uri)
946-
output(u" cors: %s" % cors)
948+
output(u" CORS: %s" % cors)
947949
except S3Error as exc:
948950
# Ignore the exception and don't fail the info
949951
# if the server doesn't support setting ACLs
950952
if exc.status not in [404, 501]:
951953
raise exc
952-
output(u" cors: none")
954+
output(u" CORS: none")
953955

954956
try:
955957
acl = s3.get_acl(uri)
@@ -963,6 +965,8 @@ def cmd_info(args):
963965
# if the server doesn't support setting ACLs
964966
if exc.status not in [404, 501]:
965967
raise exc
968+
else:
969+
output(u" ACL: none")
966970

967971
if uri.has_object():
968972
# Temporary hack for performance + python3 compatibility

0 commit comments

Comments
 (0)