Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw: add support for system requests over Swift API #7666

Merged
merged 3 commits into from Feb 18, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/rgw/rgw_common.cc
Expand Up @@ -704,6 +704,23 @@ void RGWHTTPArgs::get_bool(const char *name, bool *val, bool def_val)
}
}

string RGWHTTPArgs::sys_get(const string& name, bool * const exists)
{
const auto iter = sys_val_map.find(name);
const bool e = (iter != val_map.end());

if (exists) {
*exists = e;
}

return e ? iter->second : string();
}

string RGWHTTPArgs::sys_get(const char * const name, bool * const exists)
{
return sys_get(string(name), exists);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this overload necessary? you should be able to pass const char* to a function that takes const string& already

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Removed the overload as well as RGWHTTPArgs::get(const char *name, bool *exists).


bool verify_requester_payer_permission(struct req_state *s)
{
if (!s->bucket_info.requester_pays)
Expand Down
4 changes: 4 additions & 0 deletions src/rgw/rgw_common.h
Expand Up @@ -297,6 +297,10 @@ class RGWHTTPArgs
int get_bool(const char *name, bool *val, bool *exists);
void get_bool(const char *name, bool *val, bool def_val);

/** Get the value for specific system argument parameter */
string sys_get(const string& name, bool *exists = nullptr);
string sys_get(const char *name, bool *exists = nullptr);

/** see if a parameter is contained in this RGWHTTPArgs */
bool exists(const char *name) {
map<string, string>::iterator iter = val_map.find(name);
Expand Down
19 changes: 19 additions & 0 deletions src/rgw/rgw_rest_swift.cc
Expand Up @@ -1298,6 +1298,25 @@ int RGWHandler_REST_SWIFT::authorize()
if (!authorized)
return -EPERM;

if (s->user->system) {
s->system_request = true;
ldout(s->cct, 20) << "system request over Swift API" << dendl;

rgw_user euid(s->info.args.sys_get(RGW_SYS_PARAM_PREFIX "uid"));
if (!euid.empty()) {
RGWUserInfo einfo;

const int ret = rgw_get_user_info_by_uid(store, euid, einfo);
if (ret < 0) {
ldout(s->cct, 0) << "User lookup failed, euid=" << euid
<< " ret=" << ret << dendl;
return -ENOENT;
}

*(s->user) = einfo;
}
}

return 0;
}

Expand Down