radosgw: rename symbols, use generic name for rgw

This commit is contained in:
Yehuda Sadeh 2009-08-07 10:46:29 -07:00
parent a7995b79d2
commit d0f58ad8b2
20 changed files with 471 additions and 471 deletions

View File

@ -131,7 +131,7 @@ librados_la_LDFLAGS = -version-info 1:0:0 -export-symbols-regex 'rados_.*'
lib_LTLIBRARIES += librados.la
if WITH_RADOSGW
libradosgw_la_SOURCES = \
libradosgw_a_SOURCES = \
radosgw/rgw_fs.cc \
radosgw/rgw_rados.cc \
radosgw/rgw_acl.cc \
@ -140,8 +140,8 @@ libradosgw_la_SOURCES = \
radosgw/rgw_op.cc \
radosgw/rgw_rest.cc \
radosgw/rgw_common.cc
libradosgw_la_CFLAGS = ${AM_CFLAGS}
lib_LTLIBRARIES += libradosgw.la
libradosgw_a_CFLAGS = ${AM_CFLAGS}
# lib_LTLIBRARIES += libradosgw.a
endif
rados_SOURCES = rados.cc
@ -158,11 +158,11 @@ bin_PROGRAMS += testrados testradospp radosacl
if WITH_RADOSGW
rgw_SOURCES = radosgw/rgw_main.cc
rgw_LDADD = libradosgw.la librados.la libcrush.la -lfcgi -lcrypto -lexpat
rgw_LDADD = libradosgw.a librados.la libcrush.la -lfcgi -lcrypto -lexpat
rgw_admin_SOURCES = radosgw/rgw_admin.cc
rgw_admin_LDADD = libradosgw.la librados.la libcrush.la -lfcgi -lcrypto -lexpat
rgw_admin_LDADD = libradosgw.a librados.la libcrush.la -lfcgi -lcrypto -lexpat
rgw_aclparser_SOURCES = radosgw/rgw_aclparser.cc
rgw_aclparser_LDADD = libradosgw.la librados.la libcrush.la -lfcgi -lcrypto -lexpat
rgw_aclparser_LDADD = libradosgw.a librados.la libcrush.la -lfcgi -lcrypto -lexpat
bin_PROGRAMS += rgw rgw_admin rgw_aclparser
endif
@ -226,7 +226,7 @@ AM_LDFLAGS =
noinst_LIBRARIES = \
libcommon.a libcrush.a \
libmon.a libmds.a libosdc.a libosd.a libclient.a \
libos.a
libos.a libradosgw.a
noinst_LIBRARIES += #libcephclient_so.a

View File

@ -3,12 +3,12 @@
#include "rgw_fs.h"
#include "rgw_rados.h"
static S3FS fs_provider;
static S3Rados rados_provider;
static RGWFS fs_provider;
static RGWRados rados_provider;
S3Access* S3Access::store;
RGWAccess* RGWAccess::store;
S3Access *S3Access::init_storage_provider(const char *type, int argc, char *argv[])
RGWAccess *RGWAccess::init_storage_provider(const char *type, int argc, char *argv[])
{
if (strcmp(type, "rados") == 0) {
store = &rados_provider;

View File

@ -1,5 +1,5 @@
#ifndef __S3ACCESS_H
#define __S3ACCESS_H
#ifndef __RGWACCESS_H
#define __RGWACCESS_H
#include <time.h>
#include <string>
@ -11,14 +11,14 @@
#include "rgw_common.h"
class S3Access {
class RGWAccess {
public:
virtual int initialize(int argc, char *argv[]) { return 0; }
virtual int list_buckets_init(std::string& id, S3AccessHandle *handle) = 0;
virtual int list_buckets_next(std::string& id, S3ObjEnt& obj, S3AccessHandle *handle) = 0;
virtual int list_buckets_init(std::string& id, RGWAccessHandle *handle) = 0;
virtual int list_buckets_next(std::string& id, RGWObjEnt& obj, RGWAccessHandle *handle) = 0;
virtual int list_objects(std::string& id, std::string& bucket, int max, std::string& prefix, std::string& delim,
std::string& marker, std::vector<S3ObjEnt>& result, map<string, bool>& common_prefixes) = 0;
std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes) = 0;
virtual int create_bucket(std::string& id, std::string& bucket, map<nstring, bufferlist>& attrs) = 0;
virtual int put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
@ -33,7 +33,7 @@ public:
const char *if_match,
const char *if_nomatch,
map<nstring, bufferlist>& attrs,
struct s3_err *err) = 0;
struct rgw_err *err) = 0;
virtual int delete_bucket(std::string& id, std::string& bucket) = 0;
virtual int delete_obj(std::string& id, std::string& bucket, std::string& obj) = 0;
@ -45,18 +45,18 @@ public:
const char *if_match,
const char *if_nomatch,
bool get_data,
struct s3_err *err) = 0;
struct rgw_err *err) = 0;
virtual int get_attr(std::string& bucket, std::string& obj,
const char *name, bufferlist& dest) = 0;
virtual int set_attr(std::string& bucket, std::string& obj,
const char *name, bufferlist& bl) = 0;
static S3Access *init_storage_provider(const char *type, int argc, char *argv[]);
static S3Access *store;
static RGWAccess *init_storage_provider(const char *type, int argc, char *argv[]);
static RGWAccess *store;
};
#define s3store S3Access::store
#define rgwstore RGWAccess::store

View File

@ -10,8 +10,8 @@
using namespace std;
static string s3_uri_all_users = S3_URI_ALL_USERS;
static string s3_uri_auth_users = S3_URI_AUTH_USERS;
static string rgw_uri_all_users = RGW_URI_ALL_USERS;
static string rgw_uri_auth_users = RGW_URI_AUTH_USERS;
ostream& operator<<(ostream& out, XMLObj& obj) {
out << obj.type << ": " << obj.data;
@ -22,15 +22,15 @@ ostream& operator<<(ostream& out, XMLObj& obj) {
void ACLPermission::xml_end(const char *el) {
const char *s = data.c_str();
if (strcasecmp(s, "READ") == 0) {
flags |= S3_PERM_READ;
flags |= RGW_PERM_READ;
} else if (strcasecmp(s, "WRITE") == 0) {
flags |= S3_PERM_WRITE;
flags |= RGW_PERM_WRITE;
} else if (strcasecmp(s, "READ_ACP") == 0) {
flags |= S3_PERM_READ_ACP;
flags |= RGW_PERM_READ_ACP;
} else if (strcasecmp(s, "WRITE_ACP") == 0) {
flags |= S3_PERM_WRITE_ACP;
flags |= RGW_PERM_WRITE_ACP;
} else if (strcasecmp(s, "FULL_CONTROL") == 0) {
flags |= S3_PERM_FULL_CONTROL;
flags |= RGW_PERM_FULL_CONTROL;
}
}
@ -123,7 +123,7 @@ void ACLGrant::xml_end(const char *el) {
};
}
void S3AccessControlList::init_user_map()
void RGWAccessControlList::init_user_map()
{
multimap<string, ACLGrant>::iterator iter;
acl_user_map.clear();
@ -135,7 +135,7 @@ void S3AccessControlList::init_user_map()
user_map_initialized = true;
}
void S3AccessControlList::add_grant(ACLGrant *grant)
void RGWAccessControlList::add_grant(ACLGrant *grant)
{
string id = grant->get_id();
if (id.size() > 0) {
@ -143,7 +143,7 @@ void S3AccessControlList::add_grant(ACLGrant *grant)
}
}
void S3AccessControlList::xml_end(const char *el) {
void RGWAccessControlList::xml_end(const char *el) {
XMLObjIter iter = find("Grant");
ACLGrant *grant = (ACLGrant *)iter.get_next();
while (grant) {
@ -153,7 +153,7 @@ void S3AccessControlList::xml_end(const char *el) {
init_user_map();
}
int S3AccessControlList::get_perm(string& id, int perm_mask) {
int RGWAccessControlList::get_perm(string& id, int perm_mask) {
cerr << "searching permissions for uid=" << id << " mask=" << perm_mask << std::endl;
if (!user_map_initialized)
init_user_map();
@ -166,14 +166,14 @@ int S3AccessControlList::get_perm(string& id, int perm_mask) {
return 0;
}
bool S3AccessControlList::create_canned(string id, string name, string canned_acl)
bool RGWAccessControlList::create_canned(string id, string name, string canned_acl)
{
acl_user_map.clear();
grant_map.clear();
/* owner gets full control */
ACLGrant grant;
grant.set_canon(id, name, S3_PERM_FULL_CONTROL);
grant.set_canon(id, name, RGW_PERM_FULL_CONTROL);
add_grant(&grant);
if (canned_acl.size() == 0 || canned_acl.compare("private") == 0) {
@ -182,15 +182,15 @@ bool S3AccessControlList::create_canned(string id, string name, string canned_ac
ACLGrant group_grant;
if (canned_acl.compare("public-read") == 0) {
group_grant.set_group(s3_uri_all_users, S3_PERM_READ);
group_grant.set_group(rgw_uri_all_users, RGW_PERM_READ);
add_grant(&group_grant);
} else if (canned_acl.compare("public-read-write") == 0) {
group_grant.set_group(s3_uri_all_users, S3_PERM_READ);
group_grant.set_group(rgw_uri_all_users, RGW_PERM_READ);
add_grant(&group_grant);
group_grant.set_group(s3_uri_all_users, S3_PERM_WRITE);
group_grant.set_group(rgw_uri_all_users, RGW_PERM_WRITE);
add_grant(&group_grant);
} else if (canned_acl.compare("authenticated-read") == 0) {
group_grant.set_group(s3_uri_auth_users, S3_PERM_READ);
group_grant.set_group(rgw_uri_auth_users, RGW_PERM_READ);
add_grant(&group_grant);
} else {
return false;
@ -200,32 +200,32 @@ bool S3AccessControlList::create_canned(string id, string name, string canned_ac
}
void S3AccessControlPolicy::xml_end(const char *el) {
acl = *(S3AccessControlList *)find_first("AccessControlList");
void RGWAccessControlPolicy::xml_end(const char *el) {
acl = *(RGWAccessControlList *)find_first("AccessControlList");
owner = *(ACLOwner *)find_first("Owner");
}
int S3AccessControlPolicy::get_perm(string& id, int perm_mask) {
int RGWAccessControlPolicy::get_perm(string& id, int perm_mask) {
int perm = acl.get_perm(id, perm_mask);
if (perm == perm_mask)
return perm;
if (perm_mask & (S3_PERM_READ_ACP | S3_PERM_WRITE_ACP)) {
if (perm_mask & (RGW_PERM_READ_ACP | RGW_PERM_WRITE_ACP)) {
/* this is the owner, it has implicit permissions */
if (id.compare(owner.get_id()) == 0) {
perm |= S3_PERM_READ_ACP | S3_PERM_WRITE_ACP;
perm |= RGW_PERM_READ_ACP | RGW_PERM_WRITE_ACP;
perm &= perm_mask;
}
}
/* should we continue looking up? */
if ((perm & perm_mask) != perm_mask) {
perm |= acl.get_perm(s3_uri_all_users, perm_mask);
perm |= acl.get_perm(rgw_uri_all_users, perm_mask);
if (id.compare(S3_USER_ANON_ID)) {
if (id.compare(RGW_USER_ANON_ID)) {
/* this is not the anonymous user */
perm |= acl.get_perm(s3_uri_auth_users, perm_mask);
perm |= acl.get_perm(rgw_uri_auth_users, perm_mask);
}
}
@ -235,19 +235,19 @@ int S3AccessControlPolicy::get_perm(string& id, int perm_mask) {
}
void xml_start(void *data, const char *el, const char **attr) {
S3XMLParser *handler = (S3XMLParser *)data;
RGWXMLParser *handler = (RGWXMLParser *)data;
handler->xml_start(el, attr);
}
void S3XMLParser::xml_start(const char *el, const char **attr) {
void RGWXMLParser::xml_start(const char *el, const char **attr) {
XMLObj * obj;
if (strcmp(el, "AccessControlPolicy") == 0) {
obj = new S3AccessControlPolicy();
obj = new RGWAccessControlPolicy();
} else if (strcmp(el, "Owner") == 0) {
obj = new ACLOwner();
} else if (strcmp(el, "AccessControlList") == 0) {
obj = new S3AccessControlList();
obj = new RGWAccessControlList();
} else if (strcmp(el, "ID") == 0) {
obj = new ACLID();
} else if (strcmp(el, "DisplayName") == 0) {
@ -277,12 +277,12 @@ void S3XMLParser::xml_start(const char *el, const char **attr) {
}
void xml_end(void *data, const char *el) {
S3XMLParser *handler = (S3XMLParser *)data;
RGWXMLParser *handler = (RGWXMLParser *)data;
handler->xml_end(el);
}
void S3XMLParser::xml_end(const char *el) {
void RGWXMLParser::xml_end(const char *el) {
XMLObj *parent_obj = cur_obj->get_parent();
cur_obj->xml_end(el);
cur_obj = parent_obj;
@ -290,22 +290,22 @@ void S3XMLParser::xml_end(const char *el) {
void handle_data(void *data, const char *s, int len)
{
S3XMLParser *handler = (S3XMLParser *)data;
RGWXMLParser *handler = (RGWXMLParser *)data;
handler->handle_data(s, len);
}
void S3XMLParser::handle_data(const char *s, int len)
void RGWXMLParser::handle_data(const char *s, int len)
{
cur_obj->xml_handle_data(s, len);
}
bool S3XMLParser::init()
bool RGWXMLParser::init()
{
p = XML_ParserCreate(NULL);
if (!p) {
cerr << "S3XMLParser::init(): ERROR allocating memory" << std::endl;
cerr << "RGWXMLParser::init(): ERROR allocating memory" << std::endl;
return false;
}
XML_SetElementHandler(p, ::xml_start, ::xml_end);
@ -315,7 +315,7 @@ bool S3XMLParser::init()
return true;
}
bool S3XMLParser::parse(const char *_buf, int len, int done)
bool RGWXMLParser::parse(const char *_buf, int len, int done)
{
int pos = buf_len;
buf = (char *)realloc(buf, buf_len + len);
@ -334,7 +334,7 @@ bool S3XMLParser::parse(const char *_buf, int len, int done)
#if 0
int main(int argc, char **argv) {
S3XMLParser parser;
RGWXMLParser parser;
if (!parser.init())
exit(1);
@ -358,17 +358,17 @@ int main(int argc, char **argv) {
break;
}
S3AccessControlPolicy *policy = (S3AccessControlPolicy *)parser.find_first("AccessControlPolicy");
RGWAccessControlPolicy *policy = (RGWAccessControlPolicy *)parser.find_first("AccessControlPolicy");
if (policy) {
string id="79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be";
cout << hex << policy->get_perm(id, S3_PERM_ALL) << dec << endl;
cout << hex << policy->get_perm(id, RGW_PERM_ALL) << dec << endl;
policy->to_xml(cout);
}
cout << parser.get_xml() << endl;
S3AccessControlPolicy def;
RGWAccessControlPolicy def;
string id="thisistheid!";
string name="foobar";
def.create_default(id, name);

View File

@ -1,5 +1,5 @@
#ifndef __S3_ACL_H
#define __S3_ACL_H
#ifndef __RGW_ACL_H
#define __RGW_ACL_H
#include <map>
#include <string>
@ -11,16 +11,16 @@
using namespace std;
#define S3_URI_ALL_USERS "http://acs.amazonaws.com/groups/global/AllUsers"
#define S3_URI_AUTH_USERS "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"
#define RGW_URI_ALL_USERS "http://acs.amazonaws.com/groups/global/AllUsers"
#define RGW_URI_AUTH_USERS "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"
#define S3_PERM_READ 0x01
#define S3_PERM_WRITE 0x02
#define S3_PERM_READ_ACP 0x04
#define S3_PERM_WRITE_ACP 0x08
#define S3_PERM_FULL_CONTROL ( S3_PERM_READ | S3_PERM_WRITE | \
S3_PERM_READ_ACP | S3_PERM_WRITE_ACP )
#define S3_PERM_ALL S3_PERM_FULL_CONTROL
#define RGW_PERM_READ 0x01
#define RGW_PERM_WRITE 0x02
#define RGW_PERM_READ_ACP 0x04
#define RGW_PERM_WRITE_ACP 0x08
#define RGW_PERM_FULL_CONTROL ( RGW_PERM_READ | RGW_PERM_WRITE | \
RGW_PERM_READ_ACP | RGW_PERM_WRITE_ACP )
#define RGW_PERM_ALL RGW_PERM_FULL_CONTROL
class XMLObj;
@ -114,16 +114,16 @@ public:
::decode(flags, bl);
}
void to_xml(ostream& out) {
if ((flags & S3_PERM_FULL_CONTROL) == S3_PERM_FULL_CONTROL) {
if ((flags & RGW_PERM_FULL_CONTROL) == RGW_PERM_FULL_CONTROL) {
out << "<Permission>FULL_CONTROL</Permission>";
} else {
if (flags & S3_PERM_READ)
if (flags & RGW_PERM_READ)
out << "<Permission>READ</Permission>";
if (flags & S3_PERM_WRITE)
if (flags & RGW_PERM_WRITE)
out << "<Permission>WRITE</Permission>";
if (flags & S3_PERM_READ_ACP)
if (flags & RGW_PERM_READ_ACP)
out << "<Permission>READ_ACP</Permission>";
if (flags & S3_PERM_WRITE_ACP)
if (flags & RGW_PERM_WRITE_ACP)
out << "<Permission>WRITE_ACP</Permission>";
}
}
@ -275,7 +275,7 @@ public:
};
WRITE_CLASS_ENCODER(ACLGrant)
class S3AccessControlList : public XMLObj
class RGWAccessControlList : public XMLObj
{
map<string, int> acl_user_map;
multimap<string, ACLGrant> grant_map;
@ -283,8 +283,8 @@ class S3AccessControlList : public XMLObj
void init_user_map();
public:
S3AccessControlList() : user_map_initialized(false) {}
~S3AccessControlList() {}
RGWAccessControlList() : user_map_initialized(false) {}
~RGWAccessControlList() {}
void xml_end(const char *el);
int get_perm(string& id, int perm_mask);
@ -314,12 +314,12 @@ public:
grant_map.clear();
ACLGrant grant;
grant.set_canon(id, name, S3_PERM_FULL_CONTROL);
grant.set_canon(id, name, RGW_PERM_FULL_CONTROL);
add_grant(&grant);
}
bool create_canned(string id, string name, string canned_acl);
};
WRITE_CLASS_ENCODER(S3AccessControlList)
WRITE_CLASS_ENCODER(RGWAccessControlList)
class ACLOwner : public XMLObj
{
@ -351,14 +351,14 @@ public:
};
WRITE_CLASS_ENCODER(ACLOwner)
class S3AccessControlPolicy : public XMLObj
class RGWAccessControlPolicy : public XMLObj
{
S3AccessControlList acl;
RGWAccessControlList acl;
ACLOwner owner;
public:
S3AccessControlPolicy() {}
~S3AccessControlPolicy() {}
RGWAccessControlPolicy() {}
~RGWAccessControlPolicy() {}
void xml_end(const char *el);
@ -396,13 +396,13 @@ public:
return ret;
}
S3AccessControlList& get_acl() {
RGWAccessControlList& get_acl() {
return acl;
}
};
WRITE_CLASS_ENCODER(S3AccessControlPolicy)
WRITE_CLASS_ENCODER(RGWAccessControlPolicy)
class S3XMLParser : public XMLObj
class RGWXMLParser : public XMLObj
{
XML_Parser p;
char *buf;
@ -410,8 +410,8 @@ class S3XMLParser : public XMLObj
XMLObj *cur_obj;
vector<XMLObj *> objs;
public:
S3XMLParser() : buf(NULL), buf_len(0), cur_obj(NULL) {}
~S3XMLParser() {
RGWXMLParser() : buf(NULL), buf_len(0), cur_obj(NULL) {}
~RGWXMLParser() {
free(buf);
vector<XMLObj *>::iterator iter;
for (iter = objs.begin(); iter != objs.end(); ++iter) {

View File

@ -10,7 +10,7 @@
using namespace std;
int main(int argc, char **argv) {
S3XMLParser parser;
RGWXMLParser parser;
if (!parser.init())
exit(1);
@ -34,11 +34,11 @@ int main(int argc, char **argv) {
break;
}
S3AccessControlPolicy *policy = (S3AccessControlPolicy *)parser.find_first("AccessControlPolicy");
RGWAccessControlPolicy *policy = (RGWAccessControlPolicy *)parser.find_first("AccessControlPolicy");
if (policy) {
string id="79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be";
cout << hex << policy->get_perm(id, S3_PERM_ALL) << dec << endl;
cout << hex << policy->get_perm(id, RGW_PERM_ALL) << dec << endl;
policy->to_xml(cout);
}
@ -47,7 +47,7 @@ int main(int argc, char **argv) {
bufferlist bl;
policy->encode(bl);
S3AccessControlPolicy newpol;
RGWAccessControlPolicy newpol;
bufferlist::iterator iter = bl.begin();
newpol.decode(iter);

View File

@ -21,7 +21,7 @@ using namespace std;
void usage()
{
cerr << "usage: s3admin <--user-gen | --user-modify | --read-policy | --list-buckets > [options...]" << std::endl;
cerr << "usage: rgw_admin <--user-gen | --user-modify | --read-policy | --list-buckets > [options...]" << std::endl;
cerr << "options:" << std::endl;
cerr << " --uid=<id>" << std::endl;
cerr << " --key=<key>" << std::endl;
@ -74,14 +74,14 @@ int gen_rand_alphanumeric(char *dest, int size) /* size should be the required s
return 0;
}
static int rebuild_policy(S3AccessControlPolicy& src, S3AccessControlPolicy& dest)
static int rebuild_policy(RGWAccessControlPolicy& src, RGWAccessControlPolicy& dest)
{
ACLOwner *owner = (ACLOwner *)src.find_first("Owner");
if (!owner)
return -EINVAL;
S3UserInfo owner_info;
if (s3_get_user_info(owner->get_id(), owner_info) < 0) {
RGWUserInfo owner_info;
if (rgw_get_user_info(owner->get_id(), owner_info) < 0) {
cerr << "owner info does not exist" << std::endl;
return -EINVAL;
}
@ -89,16 +89,16 @@ static int rebuild_policy(S3AccessControlPolicy& src, S3AccessControlPolicy& des
new_owner.set_id(owner->get_id());
new_owner.set_name(owner_info.display_name);
S3AccessControlList& src_acl = src.get_acl();
S3AccessControlList& acl = dest.get_acl();
RGWAccessControlList& src_acl = src.get_acl();
RGWAccessControlList& acl = dest.get_acl();
XMLObjIter iter = src_acl.find("Grant");
ACLGrant *src_grant = (ACLGrant *)iter.get_next();
while (src_grant) {
string id = src_grant->get_id();
S3UserInfo grant_user;
if (s3_get_user_info(id, grant_user) < 0) {
RGWUserInfo grant_user;
if (rgw_get_user_info(id, grant_user) < 0) {
cerr << "grant user does not exist:" << id << std::endl;
} else {
ACLGrant new_grant;
@ -120,7 +120,7 @@ int main(int argc, char **argv)
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
env_to_vec(args);
common_init(args, "s3a", true);
common_init(args, "rgw", true);
const char *user_id = 0;
const char *secret_key = 0;
@ -133,8 +133,8 @@ int main(int argc, char **argv)
bool read_policy = false;
bool list_buckets = false;
int actions = 0 ;
S3UserInfo info;
S3Access *store;
RGWUserInfo info;
RGWAccess *store;
if (g_conf.clock_tare) g_clock.tare();
@ -165,7 +165,7 @@ int main(int argc, char **argv)
}
}
store = S3Access::init_storage_provider("rados", argc, argv);
store = RGWAccess::init_storage_provider("rados", argc, argv);
if (!store) {
cerr << "couldn't init storage provider" << std::endl;
}
@ -181,7 +181,7 @@ int main(int argc, char **argv)
string user_id_str = user_id;
if (s3_get_user_info(user_id_str, info) < 0) {
if (rgw_get_user_info(user_id_str, info) < 0) {
cerr << "error reading user info, aborting" << std::endl;
exit(1);
}
@ -226,7 +226,7 @@ int main(int argc, char **argv)
if (user_email)
info.user_email = user_email;
if (s3_store_user_info(info) < 0) {
if (rgw_store_user_info(info) < 0) {
cerr << "error storing user info" << std::endl;
} else {
cout << "User ID: " << info.user_id << std::endl;
@ -245,9 +245,9 @@ int main(int argc, char **argv)
string bucket_str(bucket);
string object_str(object);
int ret = store->get_attr(bucket_str, object_str,
S3_ATTR_ACL, bl);
RGW_ATTR_ACL, bl);
S3AccessControlPolicy policy;
RGWAccessControlPolicy policy;
if (ret >= 0) {
bufferlist::iterator iter = bl.begin();
policy.decode(iter);
@ -259,19 +259,19 @@ int main(int argc, char **argv)
if (list_buckets) {
actions++;
string id;
S3AccessHandle handle;
RGWAccessHandle handle;
if (user_id) {
S3UserBuckets buckets;
if (s3_get_user_buckets(user_id, buckets) < 0) {
RGWUserBuckets buckets;
if (rgw_get_user_buckets(user_id, buckets) < 0) {
cout << "could not get buckets for uid " << user_id << std::endl;
} else {
cout << "listing buckets for uid " << user_id << std::endl;
map<string, S3ObjEnt>& m = buckets.get_buckets();
map<string, S3ObjEnt>::iterator iter;
map<string, RGWObjEnt>& m = buckets.get_buckets();
map<string, RGWObjEnt>::iterator iter;
for (iter = m.begin(); iter != m.end(); ++iter) {
S3ObjEnt obj = iter->second;
RGWObjEnt obj = iter->second;
cout << obj.name << std::endl;
}
}
@ -279,7 +279,7 @@ int main(int argc, char **argv)
if (store->list_buckets_init(id, &handle) < 0) {
cout << "list-buckets: no entries found" << std::endl;
} else {
S3ObjEnt obj;
RGWObjEnt obj;
cout << "listing all buckets" << std::endl;
while (store->list_buckets_next(id, obj, &handle) >= 0) {
cout << obj.name << std::endl;

View File

@ -79,7 +79,7 @@ string& XMLArgs::get(const char *name)
return get(s);
}
bool verify_permission(S3AccessControlPolicy *policy, string& uid, int perm)
bool verify_permission(RGWAccessControlPolicy *policy, string& uid, int perm)
{
if (!policy)
return false;

View File

@ -1,5 +1,5 @@
#ifndef __S3COMMON_H
#define __S3COMMON_H
#ifndef __RGWCOMMON_H
#define __RGWCOMMON_H
#include "fcgiapp.h"
@ -10,26 +10,26 @@
using namespace std;
#define SERVER_NAME "S3FS"
#define SERVER_NAME "RGWFS"
#define S3_ATTR_PREFIX "user.s3."
#define RGW_ATTR_PREFIX "user.rgw."
#define S3_ATTR_ACL S3_ATTR_PREFIX "acl"
#define S3_ATTR_ETAG S3_ATTR_PREFIX "etag"
#define S3_ATTR_BUCKETS S3_ATTR_PREFIX "buckets"
#define S3_ATTR_META_PREFIX S3_ATTR_PREFIX "x-amz-meta-"
#define S3_ATTR_CONTENT_TYPE S3_ATTR_PREFIX "content_type"
#define RGW_ATTR_ACL RGW_ATTR_PREFIX "acl"
#define RGW_ATTR_ETAG RGW_ATTR_PREFIX "etag"
#define RGW_ATTR_BUCKETS RGW_ATTR_PREFIX "buckets"
#define RGW_ATTR_META_PREFIX RGW_ATTR_PREFIX "x-amz-meta-"
#define RGW_ATTR_CONTENT_TYPE RGW_ATTR_PREFIX "content_type"
#define USER_INFO_VER 1
typedef void *S3AccessHandle;
typedef void *RGWAccessHandle;
struct s3_err {
struct rgw_err {
const char *num;
const char *code;
const char *message;
s3_err() : num(NULL), code(NULL), message(NULL) {}
rgw_err() : num(NULL), code(NULL), message(NULL) {}
};
class NameVal
@ -80,10 +80,10 @@ struct fcgx_state {
FCGX_Stream *err;
};
class S3AccessControlPolicy;
class RGWAccessControlPolicy;
struct S3UserInfo
struct RGWUserInfo
{
string user_id;
string secret_key;
@ -114,7 +114,7 @@ struct S3UserInfo
user_email.clear();
}
};
WRITE_CLASS_ENCODER(S3UserInfo)
WRITE_CLASS_ENCODER(RGWUserInfo)
struct req_state {
@ -130,7 +130,7 @@ struct req_state {
const char *length;
const char *content_type;
bool err_exist;
struct s3_err err;
struct rgw_err err;
XMLArgs args;
@ -146,8 +146,8 @@ struct req_state {
vector<pair<string, string> > x_amz_meta;
S3UserInfo user;
S3AccessControlPolicy *acl;
RGWUserInfo user;
RGWAccessControlPolicy *acl;
string canned_acl;
const char *copy_source;
@ -156,7 +156,7 @@ struct req_state {
req_state() : acl(NULL) {}
};
struct S3ObjEnt {
struct RGWObjEnt {
std::string name;
size_t size;
time_t mtime;
@ -173,7 +173,7 @@ struct S3ObjEnt {
::decode(mtime, bl);
}
};
WRITE_CLASS_ENCODER(S3ObjEnt)
WRITE_CLASS_ENCODER(RGWObjEnt)
static inline void buf_to_hex(const unsigned char *buf, int len, char *str)
{
@ -185,7 +185,7 @@ static inline void buf_to_hex(const unsigned char *buf, int len, char *str)
}
extern int parse_time(const char *time_str, time_t *time);
extern bool verify_permission(S3AccessControlPolicy *policy, string& uid, int perm);
extern bool verify_permission(RGWAccessControlPolicy *policy, string& uid, int perm);
extern bool verify_permission(struct req_state *s, int perm);
extern bool url_decode(string& src_str, string& dest_str);

View File

@ -20,40 +20,40 @@
using namespace std;
struct s3fs_state {
struct rgwfs_state {
DIR *dir;
};
#define DIR_NAME "/tmp/radosgw"
int S3FS::list_buckets_init(string& id, S3AccessHandle *handle)
int RGWFS::list_buckets_init(string& id, RGWAccessHandle *handle)
{
DIR *dir = opendir(DIR_NAME);
struct s3fs_state *state;
struct rgwfs_state *state;
if (!dir)
return -errno;
state = (struct s3fs_state *)malloc(sizeof(struct s3fs_state));
state = (struct rgwfs_state *)malloc(sizeof(struct rgwfs_state));
if (!state)
return -ENOMEM;
state->dir = dir;
*handle = (S3AccessHandle)state;
*handle = (RGWAccessHandle)state;
return 0;
}
int S3FS::list_buckets_next(string& id, S3ObjEnt& obj, S3AccessHandle *handle)
int RGWFS::list_buckets_next(string& id, RGWObjEnt& obj, RGWAccessHandle *handle)
{
struct s3fs_state *state;
struct rgwfs_state *state;
struct dirent *dirent;
#define BUF_SIZE 512
if (!handle)
return -EINVAL;
state = *(struct s3fs_state **)handle;
state = *(struct rgwfs_state **)handle;
if (!state)
return -EINVAL;
@ -82,8 +82,8 @@ int S3FS::list_buckets_next(string& id, S3ObjEnt& obj, S3AccessHandle *handle)
}
}
int S3FS::list_objects(string& id, string& bucket, int max, string& prefix, string& delim,
string& marker, vector<S3ObjEnt>& result, map<string, bool>& common_prefixes)
int RGWFS::list_objects(string& id, string& bucket, int max, string& prefix, string& delim,
string& marker, vector<RGWObjEnt>& result, map<string, bool>& common_prefixes)
{
map<string, bool> dir_map;
char path[BUF_SIZE];
@ -123,7 +123,7 @@ int S3FS::list_objects(string& id, string& bucket, int max, string& prefix, stri
result.clear();
int i;
for (i=0; i<max && iter != dir_map.end(); i++, ++iter) {
S3ObjEnt obj;
RGWObjEnt obj;
char buf[BUF_SIZE];
struct stat statbuf;
obj.name = iter->first;
@ -133,7 +133,7 @@ int S3FS::list_objects(string& id, string& bucket, int max, string& prefix, stri
obj.mtime = statbuf.st_mtime;
obj.size = statbuf.st_size;
char *etag;
if (get_attr(S3_ATTR_ETAG, buf, &etag) >= 0) {
if (get_attr(RGW_ATTR_ETAG, buf, &etag) >= 0) {
strncpy(obj.etag, etag, sizeof(obj.etag));
obj.etag[sizeof(obj.etag)-1] = '\0';
free(etag);
@ -145,7 +145,7 @@ int S3FS::list_objects(string& id, string& bucket, int max, string& prefix, stri
}
int S3FS::create_bucket(std::string& id, std::string& bucket, map<nstring, bufferlist>& attrs)
int RGWFS::create_bucket(std::string& id, std::string& bucket, map<nstring, bufferlist>& attrs)
{
int len = strlen(DIR_NAME) + 1 + bucket.size() + 1;
char buf[len];
@ -172,7 +172,7 @@ int S3FS::create_bucket(std::string& id, std::string& bucket, map<nstring, buffe
return 0;
}
int S3FS::put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
int RGWFS::put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
time_t *mtime,
map<nstring, bufferlist>& attrs)
{
@ -228,7 +228,7 @@ int S3FS::put_obj(std::string& id, std::string& bucket, std::string& obj, const
return 0;
}
int S3FS::copy_obj(std::string& id, std::string& dest_bucket, std::string& dest_obj,
int RGWFS::copy_obj(std::string& id, std::string& dest_bucket, std::string& dest_obj,
std::string& src_bucket, std::string& src_obj,
time_t *mtime,
const time_t *mod_ptr,
@ -236,7 +236,7 @@ int S3FS::copy_obj(std::string& id, std::string& dest_bucket, std::string& dest_
const char *if_match,
const char *if_nomatch,
map<nstring, bufferlist>& attrs,
struct s3_err *err)
struct rgw_err *err)
{
int ret;
char *data;
@ -259,7 +259,7 @@ int S3FS::copy_obj(std::string& id, std::string& dest_bucket, std::string& dest_
}
int S3FS::delete_bucket(std::string& id, std::string& bucket)
int RGWFS::delete_bucket(std::string& id, std::string& bucket)
{
int len = strlen(DIR_NAME) + 1 + bucket.size() + 1;
char buf[len];
@ -272,7 +272,7 @@ int S3FS::delete_bucket(std::string& id, std::string& bucket)
}
int S3FS::delete_obj(std::string& id, std::string& bucket, std::string& obj)
int RGWFS::delete_obj(std::string& id, std::string& bucket, std::string& obj)
{
int len = strlen(DIR_NAME) + 1 + bucket.size() + 1 + obj.size() + 1;
char buf[len];
@ -284,7 +284,7 @@ int S3FS::delete_obj(std::string& id, std::string& bucket, std::string& obj)
return 0;
}
int S3FS::get_attr(const char *name, int fd, char **attr)
int RGWFS::get_attr(const char *name, int fd, char **attr)
{
char *attr_buf;
#define ETAG_LEN 32
@ -311,7 +311,7 @@ int S3FS::get_attr(const char *name, int fd, char **attr)
return attr_len;
}
int S3FS::get_attr(const char *name, const char *path, char **attr)
int RGWFS::get_attr(const char *name, const char *path, char **attr)
{
char *attr_buf;
size_t len = ETAG_LEN;
@ -338,7 +338,7 @@ int S3FS::get_attr(const char *name, const char *path, char **attr)
return attr_len;
}
int S3FS::get_attr(std::string& bucket, std::string& obj,
int RGWFS::get_attr(std::string& bucket, std::string& obj,
const char *name, bufferlist& dest)
{
int len = strlen(DIR_NAME) + 1 + bucket.size() + 1 + obj.size() + 1;
@ -358,7 +358,7 @@ done:
return r;
}
int S3FS::set_attr(std::string& bucket, std::string& obj,
int RGWFS::set_attr(std::string& bucket, std::string& obj,
const char *name, bufferlist& bl)
{
int len = strlen(DIR_NAME) + 1 + bucket.size() + 1 + obj.size() + 1;
@ -375,7 +375,7 @@ int S3FS::set_attr(std::string& bucket, std::string& obj,
return ret;
}
int S3FS::get_obj(std::string& bucket, std::string& obj,
int RGWFS::get_obj(std::string& bucket, std::string& obj,
char **data, off_t ofs, off_t end,
map<nstring, bufferlist> *attrs,
const time_t *mod_ptr,
@ -383,7 +383,7 @@ int S3FS::get_obj(std::string& bucket, std::string& obj,
const char *if_match,
const char *if_nomatch,
bool get_data,
struct s3_err *err)
struct rgw_err *err)
{
int len = strlen(DIR_NAME) + 1 + bucket.size() + 1 + obj.size() + 1;
char buf[len];
@ -426,7 +426,7 @@ int S3FS::get_obj(std::string& bucket, std::string& obj,
}
}
if (if_match || if_nomatch) {
r = get_attr(S3_ATTR_ETAG, fd, &etag);
r = get_attr(RGW_ATTR_ETAG, fd, &etag);
if (r < 0)
goto done;

View File

@ -1,17 +1,17 @@
#ifndef __S3FS_H
#define __S3FS_H
#ifndef __RGWFS_H
#define __RGWFS_H
#include "rgw_access.h"
class S3FS : public S3Access
class RGWFS : public RGWAccess
{
public:
int list_buckets_init(std::string& id, S3AccessHandle *handle);
int list_buckets_next(std::string& id, S3ObjEnt& obj, S3AccessHandle *handle);
int list_buckets_init(std::string& id, RGWAccessHandle *handle);
int list_buckets_next(std::string& id, RGWObjEnt& obj, RGWAccessHandle *handle);
int list_objects(std::string& id, std::string& bucket, int max, std::string& prefix, std::string& delim,
std::string& marker, std::vector<S3ObjEnt>& result, map<string, bool>& common_prefixes);
std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes);
int create_bucket(std::string& id, std::string& bucket, map<nstring, bufferlist>& attrs);
int put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
@ -25,7 +25,7 @@ public:
const char *if_match,
const char *if_nomatch,
map<nstring, bufferlist>& attrs,
struct s3_err *err);
struct rgw_err *err);
int delete_bucket(std::string& id, std::string& bucket);
int delete_obj(std::string& id, std::string& bucket, std::string& obj);
@ -44,7 +44,7 @@ public:
const char *if_match,
const char *if_nomatch,
bool get_data,
struct s3_err *err);
struct rgw_err *err);
};
#endif

View File

@ -139,7 +139,7 @@ static bool verify_signature(struct req_state *s)
qsr = true;
} else {
/* anonymous access */
s3_get_anon_user(s->user);
rgw_get_anon_user(s->user);
return true;
}
} else {
@ -155,7 +155,7 @@ static bool verify_signature(struct req_state *s)
}
/* first get the user info */
if (s3_get_user_info(auth_id, s->user) < 0) {
if (rgw_get_user_info(auth_id, s->user) < 0) {
cerr << "error reading user info, uid=" << auth_id << " can't authenticate" << std::endl;
return false;
}
@ -200,9 +200,9 @@ int main(int argc, char *argv[])
{
struct req_state s;
struct fcgx_state fcgx;
S3Handler_REST s3handler;
RGWHandler_REST rgwhandler;
if (!S3Access::init_storage_provider("rados", argc, argv)) {
if (!RGWAccess::init_storage_provider("rados", argc, argv)) {
cerr << "couldn't init storage provider" << std::endl;
}
@ -210,7 +210,7 @@ int main(int argc, char *argv[])
while (FCGX_Accept(&fcgx.in, &fcgx.out, &fcgx.err, &fcgx.envp) >= 0)
{
s3handler.init_state(&s, &fcgx);
rgwhandler.init_state(&s, &fcgx);
int ret = read_acls(&s);
if (ret < 0) {
@ -230,13 +230,13 @@ int main(int argc, char *argv[])
continue;
}
ret = s3handler.read_permissions();
ret = rgwhandler.read_permissions();
if (ret < 0) {
abort_early(&s, ret);
continue;
}
S3Op *op = s3handler.get_op();
RGWOp *op = rgwhandler.get_op();
if (op) {
op->execute();
}

View File

@ -54,21 +54,21 @@ void get_request_metadata(struct req_state *s, map<nstring, bufferlist>& attrs)
string& val = iter->second;
bufferlist bl;
bl.append(val.c_str(), val.size() + 1);
string attr_name = S3_ATTR_PREFIX;
string attr_name = RGW_ATTR_PREFIX;
attr_name.append(name);
attrs[attr_name.c_str()] = bl;
}
}
}
int read_acls(S3AccessControlPolicy *policy, string& bucket, string& object)
int read_acls(RGWAccessControlPolicy *policy, string& bucket, string& object)
{
bufferlist bl;
int ret = 0;
if (bucket.size()) {
ret = s3store->get_attr(bucket, object,
S3_ATTR_ACL, bl);
ret = rgwstore->get_attr(bucket, object,
RGW_ATTR_ACL, bl);
if (ret >= 0) {
bufferlist::iterator iter = bl.begin();
@ -86,7 +86,7 @@ int read_acls(struct req_state *s, bool only_bucket)
string obj_str;
if (!s->acl) {
s->acl = new S3AccessControlPolicy;
s->acl = new RGWAccessControlPolicy;
if (!s->acl)
return -ENOMEM;
}
@ -101,9 +101,9 @@ int read_acls(struct req_state *s, bool only_bucket)
return ret;
}
void S3GetObj::execute()
void RGWGetObj::execute()
{
if (!verify_permission(s, S3_PERM_READ)) {
if (!verify_permission(s, RGW_PERM_READ)) {
ret = -EACCES;
goto done;
}
@ -114,7 +114,7 @@ void S3GetObj::execute()
init_common();
len = s3store->get_obj(s->bucket_str, s->object_str, &data, ofs, end, &attrs,
len = rgwstore->get_obj(s->bucket_str, s->object_str, &data, ofs, end, &attrs,
mod_ptr, unmod_ptr, if_match, if_nomatch, get_data, &err);
if (len < 0)
ret = len;
@ -123,7 +123,7 @@ done:
send_response();
}
int S3GetObj::init_common()
int RGWGetObj::init_common()
{
if (range_str) {
int r = parse_range(range_str, ofs, end);
@ -145,23 +145,23 @@ int S3GetObj::init_common()
return 0;
}
void S3ListBuckets::execute()
void RGWListBuckets::execute()
{
ret = s3_get_user_buckets(s->user.user_id, buckets);
ret = rgw_get_user_buckets(s->user.user_id, buckets);
if (ret < 0) {
/* hmm.. something wrong here.. the user was authenticated, so it
should exist, just try to recreate */
cerr << "WARNING: failed on s3_get_user_buckets uid=" << s->user.user_id << std::endl;
s3_put_user_buckets(s->user.user_id, buckets);
cerr << "WARNING: failed on rgw_get_user_buckets uid=" << s->user.user_id << std::endl;
rgw_put_user_buckets(s->user.user_id, buckets);
ret = 0;
}
send_response();
}
void S3ListBucket::execute()
void RGWListBucket::execute()
{
if (!verify_permission(s, S3_PERM_READ)) {
if (!verify_permission(s, RGW_PERM_READ)) {
ret = -EACCES;
goto done;
}
@ -175,14 +175,14 @@ void S3ListBucket::execute()
max = -1;
}
delimiter = s->args.get("delimiter");
ret = s3store->list_objects(s->user.user_id, s->bucket_str, max, prefix, delimiter, marker, objs, common_prefixes);
ret = rgwstore->list_objects(s->user.user_id, s->bucket_str, max, prefix, delimiter, marker, objs, common_prefixes);
done:
send_response();
}
void S3CreateBucket::execute()
void RGWCreateBucket::execute()
{
S3AccessControlPolicy policy;
RGWAccessControlPolicy policy;
map<nstring, bufferlist> attrs;
bufferlist aclbl;
@ -193,15 +193,15 @@ void S3CreateBucket::execute()
}
policy.encode(aclbl);
attrs[S3_ATTR_ACL] = aclbl;
attrs[RGW_ATTR_ACL] = aclbl;
ret = s3store->create_bucket(s->user.user_id, s->bucket_str, attrs);
ret = rgwstore->create_bucket(s->user.user_id, s->bucket_str, attrs);
if (ret == 0) {
S3UserBuckets buckets;
RGWUserBuckets buckets;
int r = s3_get_user_buckets(s->user.user_id, buckets);
S3ObjEnt new_bucket;
int r = rgw_get_user_buckets(s->user.user_id, buckets);
RGWObjEnt new_bucket;
switch (r) {
case 0:
@ -211,10 +211,10 @@ void S3CreateBucket::execute()
new_bucket.size = 0;
time(&new_bucket.mtime);
buckets.add(new_bucket);
ret = s3_put_user_buckets(s->user.user_id, buckets);
ret = rgw_put_user_buckets(s->user.user_id, buckets);
break;
default:
cerr << "s3_get_user_buckets returned " << ret << std::endl;
cerr << "rgw_get_user_buckets returned " << ret << std::endl;
break;
}
}
@ -222,26 +222,26 @@ done:
send_response();
}
void S3DeleteBucket::execute()
void RGWDeleteBucket::execute()
{
ret = -EINVAL;
if (!verify_permission(s, S3_PERM_WRITE)) {
if (!verify_permission(s, RGW_PERM_WRITE)) {
abort_early(s, -EACCES);
return;
}
if (s->bucket) {
ret = s3store->delete_bucket(s->user.user_id, s->bucket_str);
ret = rgwstore->delete_bucket(s->user.user_id, s->bucket_str);
if (ret == 0) {
S3UserBuckets buckets;
RGWUserBuckets buckets;
int r = s3_get_user_buckets(s->user.user_id, buckets);
int r = rgw_get_user_buckets(s->user.user_id, buckets);
if (r == 0 || r == -ENOENT) {
buckets.remove(s->bucket_str);
ret = s3_put_user_buckets(s->user.user_id, buckets);
ret = rgw_put_user_buckets(s->user.user_id, buckets);
}
}
}
@ -249,10 +249,10 @@ void S3DeleteBucket::execute()
send_response();
}
void S3PutObj::execute()
void RGWPutObj::execute()
{
ret = -EINVAL;
struct s3_err err;
struct rgw_err err;
if (!s->object) {
goto done;
} else {
@ -260,9 +260,9 @@ void S3PutObj::execute()
if (ret < 0)
goto done;
S3AccessControlPolicy policy;
RGWAccessControlPolicy policy;
if (!verify_permission(s, S3_PERM_WRITE)) {
if (!verify_permission(s, RGW_PERM_WRITE)) {
ret = -EACCES;
goto done;
}
@ -313,29 +313,29 @@ void S3PutObj::execute()
map<nstring, bufferlist> attrs;
bufferlist bl;
bl.append(md5_str.c_str(), md5_str.size() + 1);
attrs[S3_ATTR_ETAG] = bl;
attrs[S3_ATTR_ACL] = aclbl;
attrs[RGW_ATTR_ETAG] = bl;
attrs[RGW_ATTR_ACL] = aclbl;
if (s->content_type) {
bl.clear();
bl.append(s->content_type, strlen(s->content_type) + 1);
attrs[S3_ATTR_CONTENT_TYPE] = bl;
attrs[RGW_ATTR_CONTENT_TYPE] = bl;
}
get_request_metadata(s, attrs);
ret = s3store->put_obj(s->user.user_id, s->bucket_str, s->object_str, data, len, NULL, attrs);
ret = rgwstore->put_obj(s->user.user_id, s->bucket_str, s->object_str, data, len, NULL, attrs);
}
done:
free(data);
send_response();
}
void S3DeleteObj::execute()
void RGWDeleteObj::execute()
{
ret = -EINVAL;
if (s->object) {
ret = s3store->delete_obj(s->user.user_id, s->bucket_str, s->object_str);
ret = rgwstore->delete_obj(s->user.user_id, s->bucket_str, s->object_str);
}
send_response();
@ -368,22 +368,22 @@ static bool parse_copy_source(const char *src, string& bucket, string& object)
return true;
}
int S3CopyObj::init_common()
int RGWCopyObj::init_common()
{
struct s3_err err;
S3AccessControlPolicy dest_policy;
struct rgw_err err;
RGWAccessControlPolicy dest_policy;
bool ret;
bufferlist aclbl;
map<nstring, bufferlist> attrs;
bufferlist bl;
S3AccessControlPolicy src_policy;
RGWAccessControlPolicy src_policy;
string empty_str;
time_t mod_time;
time_t unmod_time;
time_t *mod_ptr = NULL;
time_t *unmod_ptr = NULL;
if (!verify_permission(s, S3_PERM_WRITE)) {
if (!verify_permission(s, RGW_PERM_WRITE)) {
ret = -EACCES;
return ret;
}
@ -406,7 +406,7 @@ int S3CopyObj::init_common()
if (ret < 0)
return ret;
if (!verify_permission(&src_policy, s->user.user_id, S3_PERM_READ)) {
if (!verify_permission(&src_policy, s->user.user_id, RGW_PERM_READ)) {
ret = -EACCES;
return ret;
}
@ -429,13 +429,13 @@ int S3CopyObj::init_common()
unmod_ptr = &unmod_time;
}
attrs[S3_ATTR_ACL] = aclbl;
attrs[RGW_ATTR_ACL] = aclbl;
get_request_metadata(s, attrs);
return 0;
}
void S3CopyObj::execute()
void RGWCopyObj::execute()
{
ret = get_params();
if (ret < 0)
@ -444,7 +444,7 @@ void S3CopyObj::execute()
if (init_common() < 0)
goto done;
ret = s3store->copy_obj(s->user.user_id,
ret = rgwstore->copy_obj(s->user.user_id,
s->bucket_str, s->object_str,
src_bucket, src_object,
&mtime,
@ -458,9 +458,9 @@ done:
send_response();
}
void S3GetACLs::execute()
void RGWGetACLs::execute()
{
if (!verify_permission(s, S3_PERM_READ_ACP)) {
if (!verify_permission(s, RGW_PERM_READ_ACP)) {
abort_early(s, -EACCES);
return;
}
@ -478,14 +478,14 @@ void S3GetACLs::execute()
send_response();
}
static int rebuild_policy(S3AccessControlPolicy& src, S3AccessControlPolicy& dest)
static int rebuild_policy(RGWAccessControlPolicy& src, RGWAccessControlPolicy& dest)
{
ACLOwner *owner = (ACLOwner *)src.find_first("Owner");
if (!owner)
return -EINVAL;
S3UserInfo owner_info;
if (s3_get_user_info(owner->get_id(), owner_info) < 0) {
RGWUserInfo owner_info;
if (rgw_get_user_info(owner->get_id(), owner_info) < 0) {
cerr << "owner info does not exist" << std::endl;
return -EINVAL;
}
@ -493,8 +493,8 @@ static int rebuild_policy(S3AccessControlPolicy& src, S3AccessControlPolicy& des
new_owner.set_id(owner->get_id());
new_owner.set_name(owner_info.display_name);
S3AccessControlList& src_acl = src.get_acl();
S3AccessControlList& acl = dest.get_acl();
RGWAccessControlList& src_acl = src.get_acl();
RGWAccessControlList& acl = dest.get_acl();
XMLObjIter iter = src_acl.find("Grant");
ACLGrant *src_grant = (ACLGrant *)iter.get_next();
@ -508,7 +508,7 @@ static int rebuild_policy(S3AccessControlPolicy& src, S3AccessControlPolicy& des
{
string email = src_grant->get_id();
cerr << "grant user email=" << email << std::endl;
if (s3_get_uid_by_email(email, id) < 0) {
if (rgw_get_uid_by_email(email, id) < 0) {
cerr << "grant user email not found or other error" << std::endl;
break;
}
@ -518,8 +518,8 @@ static int rebuild_policy(S3AccessControlPolicy& src, S3AccessControlPolicy& des
if (type.get_type() == ACL_TYPE_CANON_USER)
id = src_grant->get_id();
S3UserInfo grant_user;
if (s3_get_user_info(id, grant_user) < 0) {
RGWUserInfo grant_user;
if (rgw_get_user_info(id, grant_user) < 0) {
cerr << "grant user does not exist:" << id << std::endl;
} else {
ACLPermission& perm = src_grant->get_permission();
@ -532,8 +532,8 @@ static int rebuild_policy(S3AccessControlPolicy& src, S3AccessControlPolicy& des
case ACL_TYPE_GROUP:
{
string group = src_grant->get_id();
if (group.compare(S3_URI_ALL_USERS) == 0 ||
group.compare(S3_URI_AUTH_USERS) == 0) {
if (group.compare(RGW_URI_ALL_USERS) == 0 ||
group.compare(RGW_URI_AUTH_USERS) == 0) {
new_grant = *src_grant;
grant_ok = true;
cerr << "new grant: " << new_grant.get_id() << std::endl;
@ -552,16 +552,16 @@ static int rebuild_policy(S3AccessControlPolicy& src, S3AccessControlPolicy& des
return 0;
}
void S3PutACLs::execute()
void RGWPutACLs::execute()
{
bufferlist bl;
char *data = NULL;
S3AccessControlPolicy *policy;
S3XMLParser parser;
S3AccessControlPolicy new_policy;
RGWAccessControlPolicy *policy;
RGWXMLParser parser;
RGWAccessControlPolicy new_policy;
if (!verify_permission(s, S3_PERM_WRITE_ACP)) {
if (!verify_permission(s, RGW_PERM_WRITE_ACP)) {
ret = -EACCES;
goto done;
}
@ -574,7 +574,7 @@ void S3PutACLs::execute()
}
if (!s->acl) {
s->acl = new S3AccessControlPolicy;
s->acl = new RGWAccessControlPolicy;
if (!s->acl) {
ret = -ENOMEM;
goto done;
@ -590,7 +590,7 @@ void S3PutACLs::execute()
ret = -EACCES;
goto done;
}
policy = (S3AccessControlPolicy *)parser.find_first("AccessControlPolicy");
policy = (RGWAccessControlPolicy *)parser.find_first("AccessControlPolicy");
if (!policy) {
ret = -EINVAL;
goto done;
@ -609,8 +609,8 @@ void S3PutACLs::execute()
/* FIXME: make some checks around checks and fix policy */
new_policy.encode(bl);
ret = s3store->set_attr(s->bucket_str, s->object_str,
S3_ATTR_ACL, bl);
ret = rgwstore->set_attr(s->bucket_str, s->object_str,
RGW_ATTR_ACL, bl);
done:
free(data);
@ -620,7 +620,7 @@ done:
}
void S3Handler::init_state(struct req_state *s, struct fcgx_state *fcgx)
void RGWHandler::init_state(struct req_state *s, struct fcgx_state *fcgx)
{
this->s = s;
@ -635,14 +635,14 @@ void S3Handler::init_state(struct req_state *s, struct fcgx_state *fcgx)
memset(&s->err, 0, sizeof(s->err));
if (s->acl) {
delete s->acl;
s->acl = new S3AccessControlPolicy;
s->acl = new RGWAccessControlPolicy;
}
s->canned_acl.clear();
provider_init_state();
}
int S3Handler::do_read_permissions(bool only_bucket)
int RGWHandler::do_read_permissions(bool only_bucket)
{
int ret = read_acls(s, only_bucket);

View File

@ -1,5 +1,5 @@
#ifndef __S3OP_H
#define __S3OP_H
#ifndef __RGWOP_H
#define __RGWOP_H
#include <string>
@ -11,22 +11,22 @@ using namespace std;
struct req_state;
extern void get_request_metadata(struct req_state *s, map<nstring, bufferlist>& attrs);
extern int read_acls(S3AccessControlPolicy *policy, string& bucket, string& object);
extern int read_acls(RGWAccessControlPolicy *policy, string& bucket, string& object);
extern int read_acls(struct req_state *s, bool only_bucket = false);
class S3Op {
class RGWOp {
protected:
struct req_state *s;
public:
S3Op() {}
~S3Op() {}
RGWOp() {}
~RGWOp() {}
virtual void init(struct req_state *s) { this->s = s; }
virtual void execute() = 0;
};
class S3GetObj : public S3Op {
class RGWGetObj : public RGWOp {
protected:
const char *range_str;
const char *if_mod;
@ -43,16 +43,16 @@ protected:
map<nstring, bufferlist> attrs;
char *data;
int ret;
struct s3_err err;
struct rgw_err err;
bool get_data;
int init_common();
public:
S3GetObj() {}
~S3GetObj() {}
RGWGetObj() {}
~RGWGetObj() {}
virtual void init(struct req_state *s) {
S3Op::init(s);
RGWOp::init(s);
ofs = 0;
len = 0;
end = -1;
@ -68,24 +68,24 @@ public:
virtual int send_response() = 0;
};
class S3ListBuckets : public S3Op {
class RGWListBuckets : public RGWOp {
protected:
int ret;
S3UserBuckets buckets;
RGWUserBuckets buckets;
public:
virtual void init(struct req_state *s) {
S3Op::init(s);
RGWOp::init(s);
}
S3ListBuckets() {}
~S3ListBuckets() {}
RGWListBuckets() {}
~RGWListBuckets() {}
void execute();
virtual void send_response() = 0;
};
class S3ListBucket : public S3Op {
class RGWListBucket : public RGWOp {
protected:
string prefix;
string marker;
@ -93,15 +93,15 @@ protected:
string delimiter;
int max;
int ret;
vector<S3ObjEnt> objs;
vector<RGWObjEnt> objs;
map<string, bool> common_prefixes;
public:
S3ListBucket() {}
~S3ListBucket() {}
RGWListBucket() {}
~RGWListBucket() {}
virtual void init(struct req_state *s) {
S3Op::init(s);
RGWOp::init(s);
prefix.clear();
marker.clear();
max_keys.clear();
@ -116,32 +116,32 @@ public:
virtual void send_response() = 0;
};
class S3CreateBucket : public S3Op {
class RGWCreateBucket : public RGWOp {
protected:
int ret;
public:
S3CreateBucket() {}
~S3CreateBucket() {}
RGWCreateBucket() {}
~RGWCreateBucket() {}
void execute();
virtual void init(struct req_state *s) {
S3Op::init(s);
RGWOp::init(s);
ret = 0;
}
virtual void send_response() = 0;
};
class S3DeleteBucket : public S3Op {
class RGWDeleteBucket : public RGWOp {
protected:
int ret;
public:
S3DeleteBucket() {}
~S3DeleteBucket() {}
RGWDeleteBucket() {}
~RGWDeleteBucket() {}
virtual void init(struct req_state *s) {
S3Op::init(s);
RGWOp::init(s);
ret = 0;
}
void execute();
@ -149,20 +149,20 @@ public:
virtual void send_response() = 0;
};
class S3PutObj : public S3Op {
class RGWPutObj : public RGWOp {
protected:
int ret;
size_t len;
char *data;
struct s3_err err;
struct rgw_err err;
char *supplied_md5_b64;
public:
S3PutObj() {}
~S3PutObj() {}
RGWPutObj() {}
~RGWPutObj() {}
virtual void init(struct req_state *s) {
S3Op::init(s);
RGWOp::init(s);
ret = 0;
len = 0;
data = NULL;
@ -174,16 +174,16 @@ public:
virtual void send_response() = 0;
};
class S3DeleteObj : public S3Op {
class RGWDeleteObj : public RGWOp {
protected:
int ret;
public:
S3DeleteObj() {}
~S3DeleteObj() {}
RGWDeleteObj() {}
~RGWDeleteObj() {}
virtual void init(struct req_state *s) {
S3Op::init(s);
RGWOp::init(s);
ret = 0;
}
void execute();
@ -191,7 +191,7 @@ public:
virtual void send_response() = 0;
};
class S3CopyObj : public S3Op {
class RGWCopyObj : public RGWOp {
protected:
const char *if_mod;
const char *if_unmod;
@ -204,18 +204,18 @@ protected:
time_t *unmod_ptr;
int ret;
map<nstring, bufferlist> attrs;
struct s3_err err;
struct rgw_err err;
string src_bucket;
string src_object;
time_t mtime;
int init_common();
public:
S3CopyObj() {}
~S3CopyObj() {}
RGWCopyObj() {}
~RGWCopyObj() {}
virtual void init(struct req_state *s) {
S3Op::init(s);
RGWOp::init(s);
if_mod = NULL;
if_unmod = NULL;
if_match = NULL;
@ -238,17 +238,17 @@ public:
virtual void send_response() = 0;
};
class S3GetACLs : public S3Op {
class RGWGetACLs : public RGWOp {
protected:
int ret;
string acls;
public:
S3GetACLs() {}
~S3GetACLs() {}
RGWGetACLs() {}
~RGWGetACLs() {}
virtual void init(struct req_state *s) {
S3Op::init(s);
RGWOp::init(s);
ret = 0;
acls.clear();
}
@ -257,18 +257,18 @@ public:
virtual void send_response() = 0;
};
class S3PutACLs : public S3Op {
class RGWPutACLs : public RGWOp {
protected:
int ret;
size_t len;
char *data;
public:
S3PutACLs() {}
~S3PutACLs() {}
RGWPutACLs() {}
~RGWPutACLs() {}
virtual void init(struct req_state *s) {
S3Op::init(s);
RGWOp::init(s);
ret = 0;
len = 0;
data = NULL;
@ -279,17 +279,17 @@ public:
virtual void send_response() = 0;
};
class S3Handler {
class RGWHandler {
protected:
struct req_state *s;
virtual void provider_init_state() = 0;
int do_read_permissions(bool only_bucket);
public:
S3Handler() {}
virtual ~S3Handler() {}
RGWHandler() {}
virtual ~RGWHandler() {}
void init_state(struct req_state *s, struct fcgx_state *fcgx);
S3Op *get_op();
RGWOp *get_op();
virtual int read_permissions() = 0;
};

View File

@ -16,12 +16,12 @@ using namespace std;
static Rados *rados = NULL;
#define ROOT_BUCKET ".s3"
#define ROOT_BUCKET ".rgw"
static string root_bucket(ROOT_BUCKET);
static rados_pool_t root_pool;
int S3Rados::initialize(int argc, char *argv[])
int RGWRados::initialize(int argc, char *argv[])
{
rados = new Rados();
if (!rados)
@ -36,7 +36,7 @@ int S3Rados::initialize(int argc, char *argv[])
return ret;
}
int S3Rados::open_root_pool(rados_pool_t *pool)
int RGWRados::open_root_pool(rados_pool_t *pool)
{
int r = rados->open_pool(root_bucket.c_str(), pool);
if (r < 0) {
@ -50,16 +50,16 @@ int S3Rados::open_root_pool(rados_pool_t *pool)
return r;
}
class S3RadosListState {
class RGWRadosListState {
public:
vector<string> list;
unsigned int pos;
S3RadosListState() : pos(0) {}
RGWRadosListState() : pos(0) {}
};
int S3Rados::list_buckets_init(std::string& id, S3AccessHandle *handle)
int RGWRados::list_buckets_init(std::string& id, RGWAccessHandle *handle)
{
S3RadosListState *state = new S3RadosListState();
RGWRadosListState *state = new RGWRadosListState();
if (!state)
return -ENOMEM;
@ -68,14 +68,14 @@ int S3Rados::list_buckets_init(std::string& id, S3AccessHandle *handle)
if (r < 0)
return r;
*handle = (S3AccessHandle)state;
*handle = (RGWAccessHandle)state;
return 0;
}
int S3Rados::list_buckets_next(std::string& id, S3ObjEnt& obj, S3AccessHandle *handle)
int RGWRados::list_buckets_next(std::string& id, RGWObjEnt& obj, RGWAccessHandle *handle)
{
S3RadosListState *state = (S3RadosListState *)*handle;
RGWRadosListState *state = (RGWRadosListState *)*handle;
if (state->pos == state->list.size()) {
delete state;
@ -96,8 +96,8 @@ static int open_pool(string& bucket, rados_pool_t *pool)
return rados->open_pool(bucket.c_str(), pool);
}
int S3Rados::list_objects(string& id, string& bucket, int max, string& prefix, string& delim,
string& marker, vector<S3ObjEnt>& result, map<string, bool>& common_prefixes)
int RGWRados::list_objects(string& id, string& bucket, int max, string& prefix, string& delim,
string& marker, vector<RGWObjEnt>& result, map<string, bool>& common_prefixes)
{
rados_pool_t pool;
map<string, object_t> dir_map;
@ -135,7 +135,7 @@ int S3Rados::list_objects(string& id, string& bucket, int max, string& prefix, s
result.clear();
int i, count = 0;
for (i=0; i<max && map_iter != dir_map.end(); i++, ++map_iter) {
S3ObjEnt obj;
RGWObjEnt obj;
obj.name = map_iter->first;
if (!delim.empty()) {
@ -152,7 +152,7 @@ int S3Rados::list_objects(string& id, string& bucket, int max, string& prefix, s
bufferlist bl;
obj.etag[0] = '\0';
if (rados->getxattr(pool, map_iter->second, S3_ATTR_ETAG, bl) >= 0) {
if (rados->getxattr(pool, map_iter->second, RGW_ATTR_ETAG, bl) >= 0) {
strncpy(obj.etag, bl.c_str(), sizeof(obj.etag));
obj.etag[sizeof(obj.etag)-1] = '\0';
}
@ -164,7 +164,7 @@ int S3Rados::list_objects(string& id, string& bucket, int max, string& prefix, s
}
int S3Rados::create_bucket(std::string& id, std::string& bucket, map<nstring, bufferlist>& attrs)
int RGWRados::create_bucket(std::string& id, std::string& bucket, map<nstring, bufferlist>& attrs)
{
object_t bucket_oid(bucket.c_str());
@ -191,7 +191,7 @@ int S3Rados::create_bucket(std::string& id, std::string& bucket, map<nstring, bu
return ret;
}
int S3Rados::put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
int RGWRados::put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
time_t *mtime,
map<nstring, bufferlist>& attrs)
{
@ -230,7 +230,7 @@ int S3Rados::put_obj(std::string& id, std::string& bucket, std::string& obj, con
return 0;
}
int S3Rados::copy_obj(std::string& id, std::string& dest_bucket, std::string& dest_obj,
int RGWRados::copy_obj(std::string& id, std::string& dest_bucket, std::string& dest_obj,
std::string& src_bucket, std::string& src_obj,
time_t *mtime,
const time_t *mod_ptr,
@ -238,7 +238,7 @@ int S3Rados::copy_obj(std::string& id, std::string& dest_bucket, std::string& de
const char *if_match,
const char *if_nomatch,
map<nstring, bufferlist>& attrs, /* in/out */
struct s3_err *err)
struct rgw_err *err)
{
/* FIXME! this should use a special rados->copy() method */
int ret;
@ -265,7 +265,7 @@ int S3Rados::copy_obj(std::string& id, std::string& dest_bucket, std::string& de
}
int S3Rados::delete_bucket(std::string& id, std::string& bucket)
int RGWRados::delete_bucket(std::string& id, std::string& bucket)
{
/* TODO! */
#if 0
@ -280,7 +280,7 @@ int S3Rados::delete_bucket(std::string& id, std::string& bucket)
}
int S3Rados::delete_obj(std::string& id, std::string& bucket, std::string& obj)
int RGWRados::delete_obj(std::string& id, std::string& bucket, std::string& obj)
{
rados_pool_t pool;
@ -297,7 +297,7 @@ int S3Rados::delete_obj(std::string& id, std::string& bucket, std::string& obj)
return 0;
}
int S3Rados::get_attr(std::string& bucket, std::string& obj,
int RGWRados::get_attr(std::string& bucket, std::string& obj,
const char *name, bufferlist& dest)
{
rados_pool_t pool;
@ -322,7 +322,7 @@ int S3Rados::get_attr(std::string& bucket, std::string& obj,
return 0;
}
int S3Rados::set_attr(std::string& bucket, std::string& obj,
int RGWRados::set_attr(std::string& bucket, std::string& obj,
const char *name, bufferlist& bl)
{
rados_pool_t pool;
@ -340,7 +340,7 @@ int S3Rados::set_attr(std::string& bucket, std::string& obj,
return 0;
}
int S3Rados::get_obj(std::string& bucket, std::string& obj,
int RGWRados::get_obj(std::string& bucket, std::string& obj,
char **data, off_t ofs, off_t end,
map<nstring, bufferlist> *attrs,
const time_t *mod_ptr,
@ -348,7 +348,7 @@ int S3Rados::get_obj(std::string& bucket, std::string& obj,
const char *if_match,
const char *if_nomatch,
bool get_data,
struct s3_err *err)
struct rgw_err *err)
{
int r = -EINVAL;
size_t size, len;
@ -396,7 +396,7 @@ int S3Rados::get_obj(std::string& bucket, std::string& obj,
}
}
if (if_match || if_nomatch) {
r = get_attr(bucket, obj, S3_ATTR_ETAG, etag);
r = get_attr(bucket, obj, RGW_ATTR_ETAG, etag);
if (r < 0)
goto done;

View File

@ -1,20 +1,20 @@
#ifndef __S3RADOS_H
#define __S3RADOS_H
#ifndef __RGWRADOS_H
#define __RGWRADOS_H
#include "include/librados.h"
#include "rgw_access.h"
class S3Rados : public S3Access
class RGWRados : public RGWAccess
{
int open_root_pool(rados_pool_t *pool);
public:
int initialize(int argc, char *argv[]);
int list_buckets_init(std::string& id, S3AccessHandle *handle);
int list_buckets_next(std::string& id, S3ObjEnt& obj, S3AccessHandle *handle);
int list_buckets_init(std::string& id, RGWAccessHandle *handle);
int list_buckets_next(std::string& id, RGWObjEnt& obj, RGWAccessHandle *handle);
int list_objects(std::string& id, std::string& bucket, int max, std::string& prefix, std::string& delim,
std::string& marker, std::vector<S3ObjEnt>& result, map<string, bool>& common_prefixes);
std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes);
int create_bucket(std::string& id, std::string& bucket, map<nstring, bufferlist>& attrs);
int put_obj(std::string& id, std::string& bucket, std::string& obj, const char *data, size_t size,
@ -28,7 +28,7 @@ public:
const char *if_match,
const char *if_nomatch,
map<nstring, bufferlist>& attrs,
struct s3_err *err);
struct rgw_err *err);
int delete_bucket(std::string& id, std::string& bucket);
int delete_obj(std::string& id, std::string& bucket, std::string& obj);
@ -45,7 +45,7 @@ public:
const char *if_match,
const char *if_nomatch,
bool get_data,
struct s3_err *err);
struct rgw_err *err);
};
#endif

View File

@ -32,12 +32,12 @@ static struct errno_http hterrs[] = {
{ ERANGE, "416", "InvalidRange" },
{ 0, NULL }};
void dump_errno(struct req_state *s, int err, struct s3_err *s3err)
void dump_errno(struct req_state *s, int err, struct rgw_err *rgwerr)
{
const char *err_str;
const char *code = (s3err ? s3err->code : NULL);
const char *code = (rgwerr ? rgwerr->code : NULL);
if (!s3err || !s3err->num) {
if (!rgwerr || !rgwerr->num) {
err_str = "500";
if (err < 0)
@ -55,14 +55,14 @@ void dump_errno(struct req_state *s, int err, struct s3_err *s3err)
i++;
}
} else {
err_str = s3err->num;
err_str = rgwerr->num;
}
dump_status(s, err_str);
if (err) {
s->err_exist = true;
s->err.code = code;
s->err.message = (s3err ? s3err->message : NULL);
s->err.message = (rgwerr ? rgwerr->message : NULL);
}
}
@ -149,7 +149,7 @@ void end_header(struct req_state *s, const char *content_type)
CGI_PRINTF(s->fcgx->out,"Content-type: %s\r\n\r\n", content_type);
if (s->err_exist) {
dump_start_xml(s);
struct s3_err &err = s->err;
struct rgw_err &err = s->err;
open_section(s, "Error");
if (err.code)
dump_value(s, "Code", err.code);
@ -169,7 +169,7 @@ void list_all_buckets_end(struct req_state *s)
close_section(s, "ListAllMyBucketsResult");
}
void dump_bucket(struct req_state *s, S3ObjEnt& obj)
void dump_bucket(struct req_state *s, RGWObjEnt& obj)
{
open_section(s, "Bucket");
dump_value(s, "Name", obj.name.c_str());
@ -183,7 +183,7 @@ void abort_early(struct req_state *s, int err)
end_header(s);
}
int S3GetObj_REST::get_params()
int RGWGetObj_REST::get_params()
{
range_str = FCGX_GetParam("HTTP_RANGE", s->fcgx->envp);
if_mod = FCGX_GetParam("HTTP_IF_MODIFIED_SINCE", s->fcgx->envp);
@ -194,7 +194,7 @@ int S3GetObj_REST::get_params()
return 0;
}
int S3GetObj_REST::send_response()
int RGWGetObj_REST::send_response()
{
const char *content_type = NULL;
@ -202,7 +202,7 @@ int S3GetObj_REST::send_response()
dump_content_length(s, len);
}
if (!ret) {
map<nstring, bufferlist>::iterator iter = attrs.find(S3_ATTR_ETAG);
map<nstring, bufferlist>::iterator iter = attrs.find(RGW_ATTR_ETAG);
if (iter != attrs.end()) {
bufferlist& bl = iter->second;
if (bl.length()) {
@ -212,10 +212,10 @@ int S3GetObj_REST::send_response()
}
for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
const char *name = iter->first.c_str();
if (strncmp(name, S3_ATTR_META_PREFIX, sizeof(S3_ATTR_META_PREFIX)-1) == 0) {
name += sizeof(S3_ATTR_PREFIX) - 1;
if (strncmp(name, RGW_ATTR_META_PREFIX, sizeof(RGW_ATTR_META_PREFIX)-1) == 0) {
name += sizeof(RGW_ATTR_PREFIX) - 1;
CGI_PRINTF(s->fcgx->out,"%s: %s\r\n", name, iter->second.c_str());
} else if (!content_type && strcmp(name, S3_ATTR_CONTENT_TYPE) == 0) {
} else if (!content_type && strcmp(name, RGW_ATTR_CONTENT_TYPE) == 0) {
content_type = iter->second.c_str();
}
}
@ -229,7 +229,7 @@ int S3GetObj_REST::send_response()
return 0;
}
void S3ListBuckets_REST::send_response()
void RGWListBuckets_REST::send_response()
{
dump_errno(s, ret);
end_header(s, "application/xml");
@ -238,19 +238,19 @@ void S3ListBuckets_REST::send_response()
list_all_buckets_start(s);
dump_owner(s, s->user.user_id, s->user.display_name);
map<string, S3ObjEnt>& m = buckets.get_buckets();
map<string, S3ObjEnt>::iterator iter;
map<string, RGWObjEnt>& m = buckets.get_buckets();
map<string, RGWObjEnt>::iterator iter;
open_section(s, "Buckets");
for (iter = m.begin(); iter != m.end(); ++iter) {
S3ObjEnt obj = iter->second;
RGWObjEnt obj = iter->second;
dump_bucket(s, obj);
}
close_section(s, "Buckets");
list_all_buckets_end(s);
}
void S3ListBucket_REST::send_response()
void RGWListBucket_REST::send_response()
{
dump_errno(s, (ret < 0 ? ret : 0));
@ -272,7 +272,7 @@ void S3ListBucket_REST::send_response()
dump_value(s, "Delimiter", delimiter.c_str());
if (ret >= 0) {
vector<S3ObjEnt>::iterator iter;
vector<RGWObjEnt>::iterator iter;
for (iter = objs.begin(); iter != objs.end(); ++iter) {
open_section(s, "Contents");
dump_value(s, "Key", iter->name.c_str());
@ -295,20 +295,20 @@ void S3ListBucket_REST::send_response()
close_section(s, "ListBucketResult");
}
void S3CreateBucket_REST::send_response()
void RGWCreateBucket_REST::send_response()
{
dump_errno(s, ret);
end_header(s);
}
void S3DeleteBucket_REST::send_response()
void RGWDeleteBucket_REST::send_response()
{
dump_errno(s, ret);
end_header(s);
}
int S3PutObj_REST::get_params()
int RGWPutObj_REST::get_params()
{
size_t cl = atoll(s->length);
if (cl) {
@ -324,19 +324,19 @@ int S3PutObj_REST::get_params()
return 0;
}
void S3PutObj_REST::send_response()
void RGWPutObj_REST::send_response()
{
dump_errno(s, ret, &err);
end_header(s);
}
void S3DeleteObj_REST::send_response()
void RGWDeleteObj_REST::send_response()
{
dump_errno(s, ret);
end_header(s);
}
int S3CopyObj_REST::get_params()
int RGWCopyObj_REST::get_params()
{
if_mod = FCGX_GetParam("HTTP_X_AMZ_COPY_IF_MODIFIED_SINCE", s->fcgx->envp);
if_unmod = FCGX_GetParam("HTTP_X_AMZ_COPY_IF_UNMODIFIED_SINCE", s->fcgx->envp);
@ -346,7 +346,7 @@ int S3CopyObj_REST::get_params()
return 0;
}
void S3CopyObj_REST::send_response()
void RGWCopyObj_REST::send_response()
{
dump_errno(s, ret, &err);
@ -354,7 +354,7 @@ void S3CopyObj_REST::send_response()
if (ret == 0) {
open_section(s, "CopyObjectResult");
dump_time(s, "LastModified", &mtime);
map<nstring, bufferlist>::iterator iter = attrs.find(S3_ATTR_ETAG);
map<nstring, bufferlist>::iterator iter = attrs.find(RGW_ATTR_ETAG);
if (iter != attrs.end()) {
bufferlist& bl = iter->second;
if (bl.length()) {
@ -366,14 +366,14 @@ void S3CopyObj_REST::send_response()
}
}
void S3GetACLs_REST::send_response()
void RGWGetACLs_REST::send_response()
{
end_header(s, "application/xml");
dump_start_xml(s);
FCGX_PutStr(acls.c_str(), acls.size(), s->fcgx->out);
}
int S3PutACLs_REST::get_params()
int RGWPutACLs_REST::get_params()
{
size_t cl = atoll(s->length);
if (cl) {
@ -391,7 +391,7 @@ int S3PutACLs_REST::get_params()
return ret;
}
void S3PutACLs_REST::send_response()
void RGWPutACLs_REST::send_response()
{
dump_errno(s, ret);
end_header(s, "application/xml");
@ -544,7 +544,7 @@ static void init_auth_info(struct req_state *s)
}
}
void S3Handler_REST::provider_init_state()
void RGWHandler_REST::provider_init_state()
{
s->path_name = FCGX_GetParam("SCRIPT_NAME", s->fcgx->envp);
s->path_name_url = FCGX_GetParam("REQUEST_URI", s->fcgx->envp);
@ -588,7 +588,7 @@ static bool is_acl_op(struct req_state *s)
return s->args.exists("acl");
}
S3Op *S3Handler_REST::get_retrieve_obj_op(struct req_state *s, bool get_data)
RGWOp *RGWHandler_REST::get_retrieve_obj_op(struct req_state *s, bool get_data)
{
if (is_acl_op(s)) {
return &get_acls_op;
@ -604,7 +604,7 @@ S3Op *S3Handler_REST::get_retrieve_obj_op(struct req_state *s, bool get_data)
return &list_bucket_op;
}
S3Op *S3Handler_REST::get_retrieve_op(struct req_state *s, bool get_data)
RGWOp *RGWHandler_REST::get_retrieve_op(struct req_state *s, bool get_data)
{
if (s->bucket) {
if (is_acl_op(s)) {
@ -616,7 +616,7 @@ S3Op *S3Handler_REST::get_retrieve_op(struct req_state *s, bool get_data)
return &list_buckets_op;
}
S3Op *S3Handler_REST::get_create_op(struct req_state *s)
RGWOp *RGWHandler_REST::get_create_op(struct req_state *s)
{
if (is_acl_op(s)) {
return &put_acls_op;
@ -632,7 +632,7 @@ S3Op *S3Handler_REST::get_create_op(struct req_state *s)
return NULL;
}
S3Op *S3Handler_REST::get_delete_op(struct req_state *s)
RGWOp *RGWHandler_REST::get_delete_op(struct req_state *s)
{
if (s->object)
return &delete_obj_op;
@ -642,9 +642,9 @@ S3Op *S3Handler_REST::get_delete_op(struct req_state *s)
return NULL;
}
S3Op *S3Handler_REST::get_op()
RGWOp *RGWHandler_REST::get_op()
{
S3Op *op;
RGWOp *op;
switch (s->op) {
case OP_GET:
op = get_retrieve_op(s, true);
@ -668,7 +668,7 @@ S3Op *S3Handler_REST::get_op()
return op;
}
int S3Handler_REST::read_permissions()
int RGWHandler_REST::read_permissions()
{
bool only_bucket;

View File

@ -1,128 +1,128 @@
#ifndef __S3REST_H
#define __S3REST_H
#ifndef __RGWREST_H
#define __RGWREST_H
#include "rgw_op.h"
class S3GetObj_REST : public S3GetObj
class RGWGetObj_REST : public RGWGetObj
{
public:
S3GetObj_REST() {}
~S3GetObj_REST() {}
RGWGetObj_REST() {}
~RGWGetObj_REST() {}
int get_params();
int send_response();
};
class S3ListBuckets_REST : public S3ListBuckets {
class RGWListBuckets_REST : public RGWListBuckets {
public:
S3ListBuckets_REST() {}
~S3ListBuckets_REST() {}
RGWListBuckets_REST() {}
~RGWListBuckets_REST() {}
void send_response();
};
class S3ListBucket_REST : public S3ListBucket {
class RGWListBucket_REST : public RGWListBucket {
public:
S3ListBucket_REST() {}
~S3ListBucket_REST() {}
RGWListBucket_REST() {}
~RGWListBucket_REST() {}
void send_response();
};
class S3CreateBucket_REST : public S3CreateBucket {
class RGWCreateBucket_REST : public RGWCreateBucket {
public:
S3CreateBucket_REST() {}
~S3CreateBucket_REST() {}
RGWCreateBucket_REST() {}
~RGWCreateBucket_REST() {}
void send_response();
};
class S3DeleteBucket_REST : public S3DeleteBucket {
class RGWDeleteBucket_REST : public RGWDeleteBucket {
public:
S3DeleteBucket_REST() {}
~S3DeleteBucket_REST() {}
RGWDeleteBucket_REST() {}
~RGWDeleteBucket_REST() {}
void send_response();
};
class S3PutObj_REST : public S3PutObj
class RGWPutObj_REST : public RGWPutObj
{
public:
S3PutObj_REST() {}
~S3PutObj_REST() {}
RGWPutObj_REST() {}
~RGWPutObj_REST() {}
int get_params();
void send_response();
};
class S3DeleteObj_REST : public S3DeleteObj {
class RGWDeleteObj_REST : public RGWDeleteObj {
public:
S3DeleteObj_REST() {}
~S3DeleteObj_REST() {}
RGWDeleteObj_REST() {}
~RGWDeleteObj_REST() {}
void send_response();
};
class S3CopyObj_REST : public S3CopyObj {
class RGWCopyObj_REST : public RGWCopyObj {
public:
S3CopyObj_REST() {}
~S3CopyObj_REST() {}
RGWCopyObj_REST() {}
~RGWCopyObj_REST() {}
int get_params();
void send_response();
};
class S3GetACLs_REST : public S3GetACLs {
class RGWGetACLs_REST : public RGWGetACLs {
public:
S3GetACLs_REST() {}
~S3GetACLs_REST() {}
RGWGetACLs_REST() {}
~RGWGetACLs_REST() {}
void send_response();
};
class S3PutACLs_REST : public S3PutACLs {
class RGWPutACLs_REST : public RGWPutACLs {
public:
S3PutACLs_REST() {}
~S3PutACLs_REST() {}
RGWPutACLs_REST() {}
~RGWPutACLs_REST() {}
int get_params();
void send_response();
};
class S3Handler_REST : public S3Handler {
S3GetObj_REST get_obj_op;
S3ListBuckets_REST list_buckets_op;
S3ListBucket_REST list_bucket_op;
S3CreateBucket_REST create_bucket_op;
S3DeleteBucket_REST delete_bucket_op;
S3PutObj_REST put_obj_op;
S3DeleteObj_REST delete_obj_op;
S3CopyObj_REST copy_obj_op;
S3GetACLs_REST get_acls_op;
S3PutACLs_REST put_acls_op;
class RGWHandler_REST : public RGWHandler {
RGWGetObj_REST get_obj_op;
RGWListBuckets_REST list_buckets_op;
RGWListBucket_REST list_bucket_op;
RGWCreateBucket_REST create_bucket_op;
RGWDeleteBucket_REST delete_bucket_op;
RGWPutObj_REST put_obj_op;
RGWDeleteObj_REST delete_obj_op;
RGWCopyObj_REST copy_obj_op;
RGWGetACLs_REST get_acls_op;
RGWPutACLs_REST put_acls_op;
S3Op *get_retrieve_obj_op(struct req_state *s, bool get_data);
S3Op *get_retrieve_op(struct req_state *s, bool get_data);
S3Op *get_create_op(struct req_state *s);
S3Op *get_delete_op(struct req_state *s);
RGWOp *get_retrieve_obj_op(struct req_state *s, bool get_data);
RGWOp *get_retrieve_op(struct req_state *s, bool get_data);
RGWOp *get_create_op(struct req_state *s);
RGWOp *get_delete_op(struct req_state *s);
protected:
void provider_init_state();
public:
S3Handler_REST() : S3Handler() {}
~S3Handler_REST() {}
S3Op *get_op();
RGWHandler_REST() : RGWHandler() {}
~RGWHandler_REST() {}
RGWOp *get_op();
int read_permissions();
};
extern void dump_errno(struct req_state *s, int err, struct s3_err *s3err = NULL);
extern void dump_errno(struct req_state *s, int err, struct rgw_err *rgwerr = NULL);
extern void end_header(struct req_state *s, const char *content_type = NULL);
extern void dump_start_xml(struct req_state *s);
extern void list_all_buckets_start(struct req_state *s);
extern void dump_owner(struct req_state *s, string& id, string& name);
extern void open_section(struct req_state *s, const char *name);
extern void close_section(struct req_state *s, const char *name);
extern void dump_bucket(struct req_state *s, S3ObjEnt& obj);
extern void dump_bucket(struct req_state *s, RGWObjEnt& obj);
extern void abort_early(struct req_state *s, int err);
extern void list_all_buckets_end(struct req_state *s);
extern void dump_value(struct req_state *s, const char *name, const char *fmt, ...);

View File

@ -14,14 +14,14 @@ using namespace std;
static string ui_bucket = USER_INFO_BUCKET_NAME;
static string ui_email_bucket = USER_INFO_EMAIL_BUCKET_NAME;
int s3_get_user_info(string user_id, S3UserInfo& info)
int rgw_get_user_info(string user_id, RGWUserInfo& info)
{
bufferlist bl;
int ret;
char *data;
struct s3_err err;
struct rgw_err err;
ret = s3store->get_obj(ui_bucket, user_id, &data, 0, -1, NULL, NULL, NULL, NULL, NULL, true, &err);
ret = rgwstore->get_obj(ui_bucket, user_id, &data, 0, -1, NULL, NULL, NULL, NULL, NULL, true, &err);
if (ret < 0) {
return ret;
}
@ -32,14 +32,14 @@ int s3_get_user_info(string user_id, S3UserInfo& info)
return 0;
}
void s3_get_anon_user(S3UserInfo& info)
void rgw_get_anon_user(RGWUserInfo& info)
{
info.user_id = S3_USER_ANON_ID;
info.user_id = RGW_USER_ANON_ID;
info.display_name.clear();
info.secret_key.clear();
}
int s3_store_user_info(S3UserInfo& info)
int rgw_store_user_info(RGWUserInfo& info)
{
bufferlist bl;
info.encode(bl);
@ -48,12 +48,12 @@ int s3_store_user_info(S3UserInfo& info)
int ret;
map<nstring,bufferlist> attrs;
ret = s3store->put_obj(info.user_id, ui_bucket, info.user_id, data, bl.length(), NULL, attrs);
ret = rgwstore->put_obj(info.user_id, ui_bucket, info.user_id, data, bl.length(), NULL, attrs);
if (ret == -ENOENT) {
ret = s3store->create_bucket(info.user_id, ui_bucket, attrs);
ret = rgwstore->create_bucket(info.user_id, ui_bucket, attrs);
if (ret >= 0)
ret = s3store->put_obj(info.user_id, ui_bucket, info.user_id, data, bl.length(), NULL, attrs);
ret = rgwstore->put_obj(info.user_id, ui_bucket, info.user_id, data, bl.length(), NULL, attrs);
}
if (ret < 0)
@ -62,30 +62,30 @@ int s3_store_user_info(S3UserInfo& info)
if (!info.user_email.size())
return ret;
S3UID ui;
RGWUID ui;
ui.user_id = info.user_id;
bufferlist uid_bl;
ui.encode(uid_bl);
ret = s3store->put_obj(info.user_id, ui_email_bucket, info.user_email, uid_bl.c_str(), uid_bl.length(), NULL, attrs);
ret = rgwstore->put_obj(info.user_id, ui_email_bucket, info.user_email, uid_bl.c_str(), uid_bl.length(), NULL, attrs);
if (ret == -ENOENT) {
map<nstring, bufferlist> attrs;
ret = s3store->create_bucket(info.user_id, ui_email_bucket, attrs);
ret = rgwstore->create_bucket(info.user_id, ui_email_bucket, attrs);
if (ret >= 0)
ret = s3store->put_obj(info.user_id, ui_email_bucket, info.user_email, uid_bl.c_str(), uid_bl.length(), NULL, attrs);
ret = rgwstore->put_obj(info.user_id, ui_email_bucket, info.user_email, uid_bl.c_str(), uid_bl.length(), NULL, attrs);
}
return ret;
}
int s3_get_uid_by_email(string& email, string& user_id)
int rgw_get_uid_by_email(string& email, string& user_id)
{
bufferlist bl;
int ret;
char *data;
struct s3_err err;
S3UID uid;
struct rgw_err err;
RGWUID uid;
ret = s3store->get_obj(ui_email_bucket, email, &data, 0, -1, NULL, NULL, NULL, NULL, NULL, true, &err);
ret = rgwstore->get_obj(ui_email_bucket, email, &data, 0, -1, NULL, NULL, NULL, NULL, NULL, true, &err);
if (ret < 0) {
return ret;
}
@ -97,10 +97,10 @@ int s3_get_uid_by_email(string& email, string& user_id)
return 0;
}
int s3_get_user_buckets(string user_id, S3UserBuckets& buckets)
int rgw_get_user_buckets(string user_id, RGWUserBuckets& buckets)
{
bufferlist bl;
int ret = s3store->get_attr(ui_bucket, user_id, S3_ATTR_BUCKETS, bl);
int ret = rgwstore->get_attr(ui_bucket, user_id, RGW_ATTR_BUCKETS, bl);
switch (ret) {
case 0:
break;
@ -116,11 +116,11 @@ int s3_get_user_buckets(string user_id, S3UserBuckets& buckets)
return 0;
}
int s3_put_user_buckets(string user_id, S3UserBuckets& buckets)
int rgw_put_user_buckets(string user_id, RGWUserBuckets& buckets)
{
bufferlist bl;
buckets.encode(bl);
int ret = s3store->set_attr(ui_bucket, user_id, S3_ATTR_BUCKETS, bl);
int ret = rgwstore->set_attr(ui_bucket, user_id, RGW_ATTR_BUCKETS, bl);
return ret;
}

View File

@ -11,9 +11,9 @@ using namespace std;
#define USER_INFO_BUCKET_NAME ".users"
#define USER_INFO_EMAIL_BUCKET_NAME ".users.email"
#define S3_USER_ANON_ID "anonymous"
#define RGW_USER_ANON_ID "anonymous"
struct S3UID
struct RGWUID
{
string user_id;
void encode(bufferlist& bl) const {
@ -23,19 +23,19 @@ struct S3UID
::decode(user_id, bl);
}
};
WRITE_CLASS_ENCODER(S3UID)
WRITE_CLASS_ENCODER(RGWUID)
extern int s3_get_user_info(string user_id, S3UserInfo& info);
extern void s3_get_anon_user(S3UserInfo& info);
extern int s3_store_user_info(S3UserInfo& info);
extern int s3_get_uid_by_email(string& email, string& user_id);
extern int rgw_get_user_info(string user_id, RGWUserInfo& info);
extern void rgw_get_anon_user(RGWUserInfo& info);
extern int rgw_store_user_info(RGWUserInfo& info);
extern int rgw_get_uid_by_email(string& email, string& user_id);
class S3UserBuckets
class RGWUserBuckets
{
map<string, S3ObjEnt> buckets;
map<string, RGWObjEnt> buckets;
public:
S3UserBuckets() {}
RGWUserBuckets() {}
void encode(bufferlist& bl) const {
::encode(buckets, bl);
}
@ -44,28 +44,28 @@ public:
}
bool owns(string& name) {
map<string, S3ObjEnt>::iterator iter;
map<string, RGWObjEnt>::iterator iter;
iter = buckets.find(name);
return (iter != buckets.end());
}
void add(S3ObjEnt& bucket) {
void add(RGWObjEnt& bucket) {
buckets[bucket.name] = bucket;
}
void remove(string& name) {
map<string, S3ObjEnt>::iterator iter;
map<string, RGWObjEnt>::iterator iter;
iter = buckets.find(name);
if (iter != buckets.end()) {
buckets.erase(iter);
}
}
map<string, S3ObjEnt>& get_buckets() { return buckets; }
map<string, RGWObjEnt>& get_buckets() { return buckets; }
};
WRITE_CLASS_ENCODER(S3UserBuckets)
WRITE_CLASS_ENCODER(RGWUserBuckets)
extern int s3_get_user_buckets(string user_id, S3UserBuckets& buckets);
extern int s3_put_user_buckets(string user_id, S3UserBuckets& buckets);
extern int rgw_get_user_buckets(string user_id, RGWUserBuckets& buckets);
extern int rgw_put_user_buckets(string user_id, RGWUserBuckets& buckets);
#endif