]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_rest_admin: return -EINVAL for improper user info requests
authorAbhishek Lekshmanan <abhishek@suse.com>
Mon, 11 Apr 2016 13:05:55 +0000 (15:05 +0200)
committerAbhishek Lekshmanan <abhishek@suse.com>
Mon, 11 Apr 2016 13:17:06 +0000 (15:17 +0200)
for /admin/user GET requests, if a uid is not given, we ultimately
return an AccessDenied error, as we initialize an anon user by default
where operations like key initialization will throw an -EACCESS. Since
the actual failure here is that uid was not specified, return an
-EINVAL, HTTP 400 error instead which is more clearer.

Fixes: http://tracker.ceph.com/issues/15455
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
src/rgw/rgw_rest_user.cc

index 587e6d00db202759fd116a25c3e16e7be468c9a4..995ea61b3106dcb3222b1bd7c72004bb1e29b703 100644 (file)
@@ -34,6 +34,15 @@ void RGWOp_User_Info::execute()
   bool fetch_stats;
 
   RESTArgs::get_string(s, "uid", uid_str, &uid_str);
+
+  // if uid was not supplied in rest argument, error out now, otherwise we'll
+  // end up initializing anonymous user, for which keys.init will eventually
+  // return -EACESS
+  if (uid_str.empty()){
+    http_ret=-EINVAL;
+    return;
+  }
+
   rgw_user uid(uid_str);
 
   RESTArgs::get_bool(s, "stats", false, &fetch_stats);