@@ -2179,23 +2179,22 @@ def cmd_getacl(args):
21792179 if uri .type != "s3" or not uri .has_bucket ():
21802180 raise ParameterError ("Expecting S3 URI instead of '%s'" % args [0 ])
21812181
2182- try :
2183- acl = s3 .get_acl (uri )
2184- acl_grant_list = acl .getGrantList ()
2185- owner = acl .getOwner ()
2186- output (u"%s (bucket):" % uri .uri ())
2187- if owner ['nick' ] is None or owner ['nick' ] == "" :
2188- output (u" Owner: %s" % (owner ['id' ]))
2189- else :
2190- output (u" Owner: %s (Nick: %s)" % (owner ['id' ], owner ['nick' ]))
2191- for grant in acl_grant_list :
2192- output (u" ACL: %s: %s" % (grant ['grantee' ], grant ['permission' ]))
2193- if acl .isAnonRead ():
2194- output (u" URL: %s" % uri .public_url ())
2195- except S3Error as exc :
2196- # Ignore the exception and don't fail the info
2197- # if the server doesn't support setting ACLs
2198- output (u" ACL: none" )
2182+ acl = s3 .get_acl (uri )
2183+ acl_grant_list = acl .getGrantList ()
2184+ owner = acl .getOwner ()
2185+ if uri .has_object ():
2186+ uri_type = "(object)"
2187+ else :
2188+ uri_type = "(bucket)"
2189+ output (u"%s %s:" % (uri , uri_type ))
2190+ if not owner ['nick' ]:
2191+ output (u" Owner: %s" % (owner ['id' ]))
2192+ else :
2193+ output (u" Owner: %s (Nick: %s)" % (owner ['id' ], owner ['nick' ]))
2194+ for grant in acl_grant_list :
2195+ output (u" ACL: %s: %s" % (grant ['grantee' ], grant ['permission' ]))
2196+ if acl .isAnonRead ():
2197+ output (u" URL: %s" % uri .public_url ())
21992198 return EX_OK
22002199
22012200def cmd_setacl (args ):
@@ -2389,8 +2388,10 @@ def cmd_getpolicy(args):
23892388 # if the server doesn't support setting ACLs
23902389 if exc .status == 403 :
23912390 output (u" Policy: Not available: GetPolicy permission is needed to read the policy" )
2391+ return EX_ACCESSDENIED
23922392 elif exc .status == 405 :
23932393 output (u" Policy: Not available: Only the bucket owner can read the policy" )
2394+ return EX_ACCESSDENIED
23942395 elif exc .status not in [404 , 501 ]:
23952396 raise exc
23962397 else :
0 commit comments