From 6fbd00a778ee2ecc9ae639d67bef953d107069a2 Mon Sep 17 00:00:00 2001 From: Abhishek Lekshmanan Date: Mon, 11 Apr 2016 15:05:55 +0200 Subject: [PATCH] rgw_rest_admin: return -EINVAL for improper user info requests 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 --- src/rgw/rgw_rest_user.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/rgw/rgw_rest_user.cc b/src/rgw/rgw_rest_user.cc index 587e6d00db2..995ea61b310 100644 --- a/src/rgw/rgw_rest_user.cc +++ b/src/rgw/rgw_rest_user.cc @@ -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); -- 2.47.3