Feature #313 » support_log_level.patch
src/rgw/rgw_acl.cc | ||
---|---|---|
acl_id = (ACLID *)acl_grantee->find_first("ID");
|
||
if (acl_id) {
|
||
id = acl_id->to_str();
|
||
cout << "[" << *acl_grantee << ", " << permission << ", " << id << ", " << "]" << std::endl;
|
||
RGW_LOG(15) << "[" << *acl_grantee << ", " << permission << ", " << id << ", " << "]" << endl;
|
||
}
|
||
break;
|
||
case ACL_TYPE_GROUP:
|
||
acl_uri = (ACLURI *)acl_grantee->find_first("URI");
|
||
if (acl_uri) {
|
||
uri = acl_uri->get_data();
|
||
cout << "[" << *acl_grantee << ", " << permission << ", " << uri << "]" << std::endl;
|
||
RGW_LOG(15) << "[" << *acl_grantee << ", " << permission << ", " << uri << "]" << endl;
|
||
}
|
||
break;
|
||
case ACL_TYPE_EMAIL_USER:
|
||
acl_email = (ACLEmail *)acl_grantee->find_first("EmailAddress");
|
||
if (acl_email) {
|
||
email = acl_email->get_data();
|
||
cout << "[" << *acl_grantee << ", " << permission << ", " << email << "]" << std::endl;
|
||
RGW_LOG(15) << "[" << *acl_grantee << ", " << permission << ", " << email << "]" << endl;
|
||
}
|
||
break;
|
||
default:
|
||
... | ... | |
}
|
||
int RGWAccessControlList::get_perm(string& id, int perm_mask) {
|
||
cerr << "searching permissions for uid=" << id << " mask=" << perm_mask << std::endl;
|
||
RGW_LOG(5) << "Searching permissions for uid=" << id << " mask=" << perm_mask << endl;
|
||
if (!user_map_initialized)
|
||
init_user_map();
|
||
map<string, int>::iterator iter = acl_user_map.find(id);
|
||
if (iter != acl_user_map.end()) {
|
||
cerr << "found permission: " << iter->second << std::endl;
|
||
RGW_LOG(5) << "Found permission: " << iter->second << endl;
|
||
return iter->second & perm_mask;
|
||
}
|
||
cerr << "permissions for user not found" << std::endl;
|
||
RGW_LOG(5) << "Permissions for user not found" << endl;
|
||
return 0;
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
cerr << "id=" << id << " owner=" << owner << std::endl;
|
||
RGW_LOG(5) << "Getting permissions id=" << id << " owner=" << owner << endl;
|
||
return perm;
|
||
}
|
||
... | ... | |
{
|
||
p = XML_ParserCreate(NULL);
|
||
if (!p) {
|
||
cerr << "RGWXMLParser::init(): ERROR allocating memory" << std::endl;
|
||
RGW_LOG(10) << "RGWXMLParser::init(): ERROR allocating memory" << endl;
|
||
return false;
|
||
}
|
||
XML_SetElementHandler(p, ::xml_start, ::xml_end);
|
src/rgw/rgw_common.cc | ||
---|---|---|
val = str.substr(delim_pos + 1);
|
||
}
|
||
cout << "parsed: name=" << name << " val=" << val << std::endl;
|
||
RGW_LOG(10) << "parsed: name=" << name << " val=" << val << endl;
|
||
return ret;
|
||
}
|
||
... | ... | |
bool url_decode(string& src_str, string& dest_str)
|
||
{
|
||
cerr << "in url_decode with " << src_str << std::endl;
|
||
RGW_LOG(10) << "in url_decode with " << src_str << endl;
|
||
const char *src = src_str.c_str();
|
||
char dest[src_str.size()];
|
||
int pos = 0;
|
src/rgw/rgw_common.h | ||
---|---|---|
#define RGW_MAX_CHUNK_SIZE (4*1024*1024)
|
||
#define RGW_LOG_BEGIN "RADOS S3 Gateway:"
|
||
#define RGW_LOG(x) if ((x) <= rgw_log_level) cout << RGW_LOG_BEGIN << " "
|
||
typedef void *RGWAccessHandle;
|
||
/** Store error returns for output at a different point in the program */
|
||
... | ... | |
* by converting %-escaped strings into characters, etc*/
|
||
extern bool url_decode(string& src_str, string& dest_str);
|
||
/* loglevel of the gateway */
|
||
extern int rgw_log_level;
|
||
#endif
|
src/rgw/rgw_fs.cc | ||
---|---|---|
case ERANGE:
|
||
break;
|
||
default:
|
||
cerr << "getxattr on " << path << " returned" << -errno << std::endl;
|
||
RGW_LOG(20) << "getxattr on " << path << " returned" << -errno << endl;
|
||
return -errno;
|
||
}
|
||
len *= 2;
|
||
... | ... | |
r = setxattr(buf, name, bl.c_str(), bl.length(), 0);
|
||
int ret = (r < 0 ? -errno : 0);
|
||
cerr << "setxattr: path=" << buf << " ret=" << ret << std::endl;
|
||
RGW_LOG(20) << "setxattr: path=" << buf << " ret=" << ret << endl;
|
||
return ret;
|
||
}
|
||
... | ... | |
}
|
||
if (unmod_ptr) {
|
||
if (st.st_mtime >= *mod_ptr) {
|
||
if (st.st_mtime >= *unmod_ptr) {
|
||
err->num = "412";
|
||
err->code = "PreconditionFailed";
|
||
goto done_err;
|
||
... | ... | |
|
||
r = -ECANCELED;
|
||
if (if_match) {
|
||
cerr << "etag=" << etag << " " << " if_match=" << if_match << endl;
|
||
RGW_LOG(10) << "ETag: " << etag << " " << " If-Match: " << if_match << endl;
|
||
if (strcmp(if_match, etag)) {
|
||
err->num = "412";
|
||
err->code = "PreconditionFailed";
|
||
... | ... | |
}
|
||
if (if_nomatch) {
|
||
cerr << "etag=" << etag << " " << " if_nomatch=" << if_nomatch << endl;
|
||
RGW_LOG(10) << "ETag: " << etag << " " << " If_NoMatch: " << if_nomatch << endl;
|
||
if (strcmp(if_nomatch, etag) == 0) {
|
||
err->num = "412";
|
||
err->code = "PreconditionFailed";
|
||
... | ... | |
pos += r;
|
||
} else {
|
||
if (!r) {
|
||
cerr << "pos=" << pos << " r=" << r << " len=" << len << endl;
|
||
RGW_LOG(20) << "pos=" << pos << " r=" << r << " len=" << len << endl;
|
||
r = -EIO; /* should not happen as we validated file size earlier */
|
||
break;
|
||
}
|
src/rgw/rgw_main.cc | ||
---|---|---|
using namespace std;
|
||
#define CGI_PRINTF(stream, format, ...) do { \
|
||
fprintf(stderr, format, __VA_ARGS__); \
|
||
FCGX_FPrintF(stream, format, __VA_ARGS__); \
|
||
} while (0)
|
||
/* Loglevel of the gateway */
|
||
int rgw_log_level = 0;
|
||
/*
|
||
* ?get the canonical amazon-style header for something?
|
||
*/
|
||
static void get_canon_amz_hdr(struct req_state *s, string& dest)
|
||
{
|
||
dest = "";
|
||
... | ... | |
buf_to_hex(result, *len, hex_str);
|
||
cerr << "hmac=" << hex_str << std::endl;
|
||
RGW_LOG(15) << "hmac=" << hex_str << endl;
|
||
}
|
||
/*
|
||
... | ... | |
/* first get the user info */
|
||
if (rgw_get_user_info(auth_id, s->user) < 0) {
|
||
cerr << "error reading user info, uid=" << auth_id << " can't authenticate" << std::endl;
|
||
RGW_LOG(5) << "error reading user info, uid=" << auth_id << " can't authenticate" << endl;
|
||
return false;
|
||
}
|
||
... | ... | |
|
||
string auth_hdr;
|
||
get_auth_header(s, auth_hdr, qsr);
|
||
cerr << "auth_hdr:" << std::endl << auth_hdr << std::endl;
|
||
RGW_LOG(10) << "auth_hdr:" << endl << auth_hdr << endl;
|
||
const char *key = s->user.secret_key.c_str();
|
||
int key_len = strlen(key);
|
||
... | ... | |
char b64[64]; /* 64 is really enough */
|
||
int ret = encode_base64(hmac_sha1, len, b64, sizeof(b64));
|
||
if (ret < 0) {
|
||
cerr << "encode_base64 failed" << std::endl;
|
||
RGW_LOG(10) << "encode_base64 failed" << endl;
|
||
return false;
|
||
}
|
||
cerr << "b64=" << b64 << std::endl;
|
||
cerr << "auth_sign=" << auth_sign << std::endl;
|
||
cerr << "compare=" << auth_sign.compare(b64) << std::endl;
|
||
RGW_LOG(15) << "b64=" << b64 << endl;
|
||
RGW_LOG(15) << "auth_sign=" << auth_sign << endl;
|
||
RGW_LOG(15) << "compare=" << auth_sign.compare(b64) << endl;
|
||
return (auth_sign.compare(b64) == 0);
|
||
}
|
||
... | ... | |
RGWHandler_REST rgwhandler;
|
||
if (!RGWAccess::init_storage_provider("rados", argc, argv)) {
|
||
cerr << "couldn't init storage provider" << std::endl;
|
||
cerr << "Couldn't init storage provider (RADOS)" << endl;
|
||
return 5; //EIO
|
||
}
|
||
... | ... | |
case -ENOENT:
|
||
break;
|
||
default:
|
||
cerr << "could not read acls" << " ret=" << ret << std::endl;
|
||
RGW_LOG(10) << "could not read acls" << " ret=" << ret << endl;
|
||
abort_early(&s, -EPERM);
|
||
continue;
|
||
}
|
||
}
|
||
ret = verify_signature(&s);
|
||
if (!ret) {
|
||
cerr << "signature DOESN'T match" << std::endl;
|
||
RGW_LOG(10) << "signature DOESN'T match" << endl;
|
||
abort_early(&s, -EPERM);
|
||
continue;
|
||
}
|
src/rgw/rgw_op.cc | ||
---|---|---|
if (ofs_str.length())
|
||
ofs = atoll(ofs_str.c_str());
|
||
if (end_str.length())
|
||
if (end_str.length())
|
||
end = atoll(end_str.c_str());
|
||
cout << "parse_range ofs=" << ofs << " end=" << end << std::endl;
|
||
RGW_LOG(10) << "parse_range ofs=" << ofs << " end=" << end << endl;
|
||
if (end < ofs)
|
||
goto done;
|
||
... | ... | |
string name = iter->first;
|
||
#define X_AMZ_META "x-amz-meta"
|
||
if (name.find(X_AMZ_META) == 0) {
|
||
cerr << "x>> " << iter->first << ":" << iter->second << std::endl;
|
||
RGW_LOG(10) << "x>> " << iter->first << ":" << iter->second << endl;
|
||
string& val = iter->second;
|
||
bufferlist bl;
|
||
bl.append(val.c_str(), val.size() + 1);
|
||
... | ... | |
if (ret >= 0) {
|
||
bufferlist::iterator iter = bl.begin();
|
||
policy->decode(iter);
|
||
policy->to_xml(cerr);
|
||
if (rgw_log_level >= 15) {
|
||
RGW_LOG(15) << "Read AccessControlPolicy" << endl;
|
||
policy->to_xml(cerr);
|
||
RGW_LOG(15) << endl;
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
if (ret < 0) {
|
||
/* hmm.. something wrong here.. the user was authenticated, so it
|
||
should exist, just try to recreate */
|
||
cerr << "WARNING: failed on rgw_get_user_buckets uid=" << s->user.user_id << std::endl;
|
||
RGW_LOG(10) << "WARNING: failed on rgw_get_user_buckets uid=" << s->user.user_id << endl;
|
||
rgw_put_user_buckets(s->user.user_id, buckets);
|
||
ret = 0;
|
||
}
|
||
... | ... | |
ret = rgw_put_user_buckets(s->user.user_id, buckets);
|
||
break;
|
||
default:
|
||
cerr << "rgw_get_user_buckets returned " << ret << std::endl;
|
||
RGW_LOG(10) << "rgw_get_user_buckets returned " << ret << endl;
|
||
break;
|
||
}
|
||
}
|
||
... | ... | |
unsigned char m[MD5_DIGEST_LENGTH];
|
||
if (supplied_md5_b64) {
|
||
cerr << "supplied_md5_b64=" << supplied_md5_b64 << std::endl;
|
||
RGW_LOG(15) << "supplied_md5_b64=" << supplied_md5_b64 << endl;
|
||
int ret = decode_base64(supplied_md5_b64, strlen(supplied_md5_b64),
|
||
supplied_md5_bin, sizeof(supplied_md5_bin));
|
||
cerr << "decode_base64 ret=" << ret << std::endl;
|
||
RGW_LOG(15) << "decode_base64 ret=" << ret << endl;
|
||
if (ret != MD5_DIGEST_LENGTH) {
|
||
err.code = "InvalidDigest";
|
||
ret = -EINVAL;
|
||
... | ... | |
}
|
||
buf_to_hex((const unsigned char *)supplied_md5_bin, MD5_DIGEST_LENGTH, supplied_md5);
|
||
cerr << "supplied_md5=" << supplied_md5 << std::endl;
|
||
RGW_LOG(15) << "supplied_md5=" << supplied_md5 << endl;
|
||
}
|
||
MD5_Init(&c);
|
||
... | ... | |
url_decode(url_src, dec_src);
|
||
src = dec_src.c_str();
|
||
cerr << "decoded src=" << src << std::endl;
|
||
RGW_LOG(15) << "decoded src=" << src << endl;
|
||
if (*src == '/') ++src;
|
||
... | ... | |
RGWUserInfo owner_info;
|
||
if (rgw_get_user_info(owner->get_id(), owner_info) < 0) {
|
||
cerr << "owner info does not exist" << std::endl;
|
||
RGW_LOG(10) << "owner info does not exist" << endl;
|
||
return -EINVAL;
|
||
}
|
||
ACLOwner& new_owner = dest.get_owner();
|
||
... | ... | |
case ACL_TYPE_EMAIL_USER:
|
||
{
|
||
string email = src_grant->get_id();
|
||
cerr << "grant user email=" << email << std::endl;
|
||
RGW_LOG(10) << "grant user email=" << email << endl;
|
||
if (rgw_get_uid_by_email(email, id) < 0) {
|
||
cerr << "grant user email not found or other error" << std::endl;
|
||
RGW_LOG(10) << "grant user email not found or other error" << endl;
|
||
break;
|
||
}
|
||
}
|
||
... | ... | |
|
||
RGWUserInfo grant_user;
|
||
if (rgw_get_user_info(id, grant_user) < 0) {
|
||
cerr << "grant user does not exist:" << id << std::endl;
|
||
RGW_LOG(10) << "grant user does not exist:" << id << endl;
|
||
} else {
|
||
ACLPermission& perm = src_grant->get_permission();
|
||
new_grant.set_canon(id, grant_user.display_name, perm.get_permissions());
|
||
grant_ok = true;
|
||
cerr << "new grant: " << new_grant.get_id() << ":" << grant_user.display_name << std::endl;
|
||
RGW_LOG(10) << "new grant: " << new_grant.get_id() << ":" << grant_user.display_name << endl;
|
||
}
|
||
}
|
||
break;
|
||
... | ... | |
group.compare(RGW_URI_AUTH_USERS) == 0) {
|
||
new_grant = *src_grant;
|
||
grant_ok = true;
|
||
cerr << "new grant: " << new_grant.get_id() << std::endl;
|
||
RGW_LOG(10) << "new grant: " << new_grant.get_id() << endl;
|
||
}
|
||
}
|
||
default:
|
||
... | ... | |
if (get_params() < 0)
|
||
goto done;
|
||
cerr << "read data=" << data << " len=" << len << std::endl;
|
||
RGW_LOG(15) << "read data=" << data << " len=" << len << endl;
|
||
if (!parser.parse(data, len, 1)) {
|
||
ret = -EACCES;
|
||
... | ... | |
ret = -EINVAL;
|
||
goto done;
|
||
}
|
||
policy->to_xml(cerr);
|
||
cerr << std::endl;
|
||
if (rgw_log_level >= 15) {
|
||
RGW_LOG(15) << "Old AccessControlPolicy" << endl;
|
||
policy->to_xml(cerr);
|
||
RGW_LOG(15) << endl;
|
||
}
|
||
ret = rebuild_policy(*policy, new_policy);
|
||
if (ret < 0)
|
||
goto done;
|
||
cerr << "new_policy: ";
|
||
new_policy.to_xml(cerr);
|
||
cerr << std::endl;
|
||
if (rgw_log_level >= 15) {
|
||
RGW_LOG(15) << "New AccessControlPolicy" << endl;
|
||
new_policy.to_xml(cerr);
|
||
RGW_LOG(15) << endl;
|
||
}
|
||
new_policy.encode(bl);
|
||
ret = rgwstore->set_attr(s->bucket_str, s->object_str,
|
||
... | ... | |
{
|
||
this->s = s;
|
||
char *p;
|
||
for (int i=0; (p = fcgx->envp[i]); ++i) {
|
||
cerr << p << std::endl;
|
||
/* Retrieve the loglevel from the CGI envirioment (if set) */
|
||
const char *cgi_env_level = FCGX_GetParam("RGW_LOG_LEVEL", fcgx->envp);
|
||
if (cgi_env_level != NULL) {
|
||
int level = atoi(cgi_env_level);
|
||
if (level > 0) {
|
||
rgw_log_level = level;
|
||
}
|
||
}
|
||
if (rgw_log_level >= 20) {
|
||
char *p;
|
||
for (int i=0; (p = fcgx->envp[i]); ++i) {
|
||
RGW_LOG(20) << p << endl;
|
||
}
|
||
}
|
||
s->fcgx = fcgx;
|
||
s->content_started = false;
|
||
... | ... | |
int ret = read_acls(s, only_bucket);
|
||
if (ret < 0)
|
||
cerr << "read_permissions on " << s->bucket_str << ":" <<s->object_str << " only_bucket=" << only_bucket << " ret=" << ret << std::endl;
|
||
RGW_LOG(10) << "read_permissions on " << s->bucket_str << ":" <<s->object_str << " only_bucket=" << only_bucket << " ret=" << ret << endl;
|
||
return ret;
|
||
}
|
src/rgw/rgw_rados.cc | ||
---|---|---|
time_t lastmod;
|
||
map<string, bufferlist>::iterator iter;
|
||
cerr << "copy " << src_bucket << ":" << src_obj << " => " << dest_bucket << ":" << dest_obj << std::endl;
|
||
RGW_LOG(5) << "Copy object " << src_bucket << ":" << src_obj << " => " << dest_bucket << ":" << dest_obj << endl;
|
||
void *handle = NULL;
|
||
... | ... | |
if (attrs) {
|
||
r = rados->getxattrs(state->pool, oid, *attrs);
|
||
for (iter = attrs->begin(); iter != attrs->end(); ++iter) {
|
||
cerr << "xattr: " << iter->first << std::endl;
|
||
if (rgw_log_level >= 20) {
|
||
for (iter = attrs->begin(); iter != attrs->end(); ++iter) {
|
||
RGW_LOG(20) << "Read xattr: " << iter->first << endl;
|
||
}
|
||
}
|
||
if (r < 0)
|
||
goto done_err;
|
||
... | ... | |
r = -ECANCELED;
|
||
if (mod_ptr) {
|
||
cout << "mod_ptr: " << *mod_ptr << " ctime: " << ctime << endl;
|
||
RGW_LOG(10) << "If-Modified-Since: " << *mod_ptr << " Last-Modified: " << ctime << endl;
|
||
if (ctime < *mod_ptr) {
|
||
err->num = "304";
|
||
err->code = "NotModified";
|
||
... | ... | |
}
|
||
if (unmod_ptr) {
|
||
if (ctime > *mod_ptr) {
|
||
RGW_LOG(10) << "If-UnModified-Since: " << *unmod_ptr << " Last-Modified: " << ctime << endl;
|
||
if (ctime > *unmod_ptr) {
|
||
err->num = "412";
|
||
err->code = "PreconditionFailed";
|
||
goto done_err;
|
||
... | ... | |
r = -ECANCELED;
|
||
if (if_match) {
|
||
cerr << "etag=" << etag << " " << " if_match=" << if_match << endl;
|
||
RGW_LOG(10) << "ETag: " << etag.c_str() << " " << " If-Match: " << if_match << endl;
|
||
if (strcmp(if_match, etag.c_str())) {
|
||
err->num = "412";
|
||
err->code = "PreconditionFailed";
|
||
... | ... | |
}
|
||
if (if_nomatch) {
|
||
cerr << "etag=" << etag << " " << " if_nomatch=" << if_nomatch << endl;
|
||
RGW_LOG(10) << "ETag: " << etag.c_str() << " " << " If-NoMatch: " << if_nomatch << endl;
|
||
if (strcmp(if_nomatch, etag.c_str()) == 0) {
|
||
err->num = "304";
|
||
err->code = "NotModified";
|
||
... | ... | |
if (len > RGW_MAX_CHUNK_SIZE)
|
||
len = RGW_MAX_CHUNK_SIZE;
|
||
cout << "rados->read ofs=" << ofs << " len=" << len << std::endl;
|
||
RGW_LOG(20) << "rados->read ofs=" << ofs << " len=" << len << endl;
|
||
int r = rados->read(state->pool, oid, ofs, bl, len);
|
||
cout << "rados->read r=" << r << std::endl;
|
||
RGW_LOG(20) << "rados->read r=" << r << endl;
|
||
if (r > 0) {
|
||
*data = (char *)malloc(r);
|
src/rgw/rgw_rados.h | ||
---|---|---|
#include "include/librados.h"
|
||
#include "rgw_access.h"
|
||
#include "rgw_common.h"
|
||
class RGWRados : public RGWAccess
|
||
{
|
src/rgw/rgw_rest.cc | ||
---|---|---|
#include "rgw_rest.h"
|
||
#define CGI_PRINTF(stream, format, ...) do { \
|
||
fprintf(stderr, format, __VA_ARGS__); \
|
||
FCGX_FPrintF(stream, format, __VA_ARGS__); \
|
||
} while (0)
|
||
... | ... | |
int pos;
|
||
if (s->host) {
|
||
string h(s->host);
|
||
|
||
cerr << "host=" << s->host << std::endl;
|
||
RGW_LOG(10) << "host=" << s->host << endl;
|
||
pos = h.find("s3.");
|
||
|
||
if (pos > 0) {
|
||
... | ... | |
for (int i=0; (p = s->fcgx->envp[i]); ++i) {
|
||
#define HTTP_X_AMZ "HTTP_X_AMZ"
|
||
if (strncmp(p, HTTP_X_AMZ, sizeof(HTTP_X_AMZ) - 1) == 0) {
|
||
cerr << "amz>> " << p << std::endl;
|
||
RGW_LOG(10) << "amz>> " << p << endl;
|
||
const char *amz = p+5; /* skip the HTTP_ part */
|
||
const char *eq = strchr(amz, '=');
|
||
if (!eq) /* shouldn't happen! */
|
||
... | ... | |
}
|
||
map<string, string>::iterator iter;
|
||
for (iter = s->x_amz_map.begin(); iter != s->x_amz_map.end(); ++iter) {
|
||
cerr << "x>> " << iter->first << ":" << iter->second << std::endl;
|
||
RGW_LOG(10) << "x>> " << iter->first << ":" << iter->second << endl;
|
||
}
|
||
}
|
||
... | ... | |
s->op = OP_UNKNOWN;
|
||
init_entities_from_header(s);
|
||
cerr << "s->object=" << (s->object ? s->object : "<NULL>") << " s->bucket=" << (s->bucket ? s->bucket : "<NULL>") << std::endl;
|
||
RGW_LOG(10) << "s->object=" << (s->object ? s->object : "<NULL>") << " s->bucket=" << (s->bucket ? s->bucket : "<NULL>") << endl;
|
||
init_auth_info(s);
|
||