]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: swift: fix anonymous user's error code of getting object 13242/head
authorJing Wenjun <jingwenjun@cmss.chinamobile.com>
Fri, 3 Feb 2017 11:06:31 +0000 (19:06 +0800)
committerJing Wenjun <jingwenjun@cmss.chinamobile.com>
Mon, 6 Feb 2017 10:50:34 +0000 (18:50 +0800)
The openstack swift will return 401 rather than 403 when
the anon user has no permission to get objects.

Fixes: http://tracker.ceph.com/issues/18806
Signed-off-by: Jing Wenjun <jingwenjun@cmss.chinamobile.com>
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_rest_swift.h

index 5bc9b920e78f4330e743adaa7549de4f7d35b2e2..f96a0888383649d7b47d5387d6a3d27e6c65ef3d 100644 (file)
@@ -1222,6 +1222,20 @@ void RGWCopyObj_ObjStore_SWIFT::send_response()
   }
 }
 
+int RGWGetObj_ObjStore_SWIFT::verify_permission()
+{
+  op_ret = RGWGetObj_ObjStore::verify_permission();
+
+  /* We have to differentiate error codes depending on whether user is
+   * anonymous (401 Unauthorized) or he doesn't have necessary permissions
+   * (403 Forbidden). */
+  if (s->auth_identity->is_anonymous() && op_ret == -EACCES) {
+    return -EPERM;
+  } else {
+    return op_ret;
+  }
+}
+
 int RGWGetObj_ObjStore_SWIFT::get_params()
 {
   const string& mm = s->info.args.get("multipart-manifest");
index d4a3f03841659af11f3264d23e82401aae224afd..a72f7c0d5d683e0b6a10bcdb30db6e4fd7f833b8 100644 (file)
@@ -17,6 +17,7 @@ public:
   RGWGetObj_ObjStore_SWIFT() {}
   ~RGWGetObj_ObjStore_SWIFT() {}
 
+  int verify_permission() override;
   int get_params();
   int send_response_data_error();
   int send_response_data(bufferlist& bl, off_t ofs, off_t len);