1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
/**
* All operations via the rados gateway are carried out by
* small classes known as RGWOps. This class contains a req_state
* and each possible command is a subclass of this with a defined
* execute() method that does whatever the subclass name implies.
* These subclasses must be further subclassed (by interface type)
* to provide additional virtual methods such as send_response or get_params.
*/
#ifndef __RGW_OP_H
#define __RGW_OP_H
#include <string>
#include "rgw_access.h"
#include "rgw_user.h"
using namespace std;
struct req_state;
/** Get the HTTP request metadata */
extern void get_request_metadata(struct req_state *s, map<string, bufferlist>& attrs);
/**
* Get the ACL for an object off of disk. If you hold the req_state, use next
* method.
*/
extern int read_acls(RGWAccessControlPolicy *policy, string& bucket, string& object);
/** Get the ACL needed for a request off of disk.*/
extern int read_acls(struct req_state *s, bool only_bucket = false);
/**
* Provide the base class for all ops.
*/
class RGWOp {
protected:
struct req_state *s;
public:
RGWOp() {}
~RGWOp() {}
virtual void init(struct req_state *s) { this->s = s; }
virtual void execute() = 0;
};
class RGWGetObj : public RGWOp {
protected:
const char *range_str;
const char *if_mod;
const char *if_unmod;
const char *if_match;
const char *if_nomatch;
off_t ofs;
off_t len;
off_t end;
time_t mod_time;
time_t unmod_time;
time_t *mod_ptr;
time_t *unmod_ptr;
map<string, bufferlist> attrs;
char *data;
int ret;
struct rgw_err err;
bool get_data;
int init_common();
public:
RGWGetObj() {}
~RGWGetObj() {}
virtual void init(struct req_state *s) {
RGWOp::init(s);
ofs = 0;
len = 0;
end = -1;
mod_ptr = NULL;
unmod_ptr = NULL;
}
void set_get_data(bool get_data) {
this->get_data = get_data;
}
void execute();
virtual int get_params() = 0;
virtual int send_response() = 0;
};
class RGWListBuckets : public RGWOp {
protected:
int ret;
RGWUserBuckets buckets;
public:
virtual void init(struct req_state *s) {
RGWOp::init(s);
}
RGWListBuckets() {}
~RGWListBuckets() {}
void execute();
virtual void send_response() = 0;
};
class RGWListBucket : public RGWOp {
protected:
string prefix;
string marker;
string max_keys;
string delimiter;
int max;
int ret;
vector<RGWObjEnt> objs;
map<string, bool> common_prefixes;
public:
RGWListBucket() {}
~RGWListBucket() {}
virtual void init(struct req_state *s) {
RGWOp::init(s);
prefix.clear();
marker.clear();
max_keys.clear();
delimiter.clear();
max = 0;
ret = 0;
objs.clear();
common_prefixes.clear();
}
void execute();
virtual void send_response() = 0;
};
class RGWCreateBucket : public RGWOp {
protected:
int ret;
public:
RGWCreateBucket() {}
~RGWCreateBucket() {}
void execute();
virtual void init(struct req_state *s) {
RGWOp::init(s);
ret = 0;
}
virtual void send_response() = 0;
};
class RGWDeleteBucket : public RGWOp {
protected:
int ret;
public:
RGWDeleteBucket() {}
~RGWDeleteBucket() {}
virtual void init(struct req_state *s) {
RGWOp::init(s);
ret = 0;
}
void execute();
virtual void send_response() = 0;
};
class RGWPutObj : public RGWOp {
protected:
int ret;
size_t len;
char *data;
struct rgw_err err;
char *supplied_md5_b64;
public:
RGWPutObj() {}
~RGWPutObj() {}
virtual void init(struct req_state *s) {
RGWOp::init(s);
ret = 0;
len = 0;
data = NULL;
supplied_md5_b64 = NULL;
}
void execute();
virtual int get_params() = 0;
virtual void send_response() = 0;
};
class RGWDeleteObj : public RGWOp {
protected:
int ret;
public:
RGWDeleteObj() {}
~RGWDeleteObj() {}
virtual void init(struct req_state *s) {
RGWOp::init(s);
ret = 0;
}
void execute();
virtual void send_response() = 0;
};
class RGWCopyObj : public RGWOp {
protected:
const char *if_mod;
const char *if_unmod;
const char *if_match;
const char *if_nomatch;
off_t ofs;
off_t len;
off_t end;
time_t *mod_ptr;
time_t *unmod_ptr;
int ret;
map<string, bufferlist> attrs;
struct rgw_err err;
string src_bucket;
string src_object;
time_t mtime;
int init_common();
public:
RGWCopyObj() {}
~RGWCopyObj() {}
virtual void init(struct req_state *s) {
RGWOp::init(s);
if_mod = NULL;
if_unmod = NULL;
if_match = NULL;
if_nomatch = NULL;
ofs = 0;
len = 0;
end = -1;
mod_ptr = NULL;
unmod_ptr = NULL;
ret = 0;
attrs.clear();
memset(&err, 0, sizeof(err));
src_bucket.clear();
src_object.clear();
mtime = 0;
}
void execute();
virtual int get_params() = 0;
virtual void send_response() = 0;
};
class RGWGetACLs : public RGWOp {
protected:
int ret;
string acls;
public:
RGWGetACLs() {}
~RGWGetACLs() {}
virtual void init(struct req_state *s) {
RGWOp::init(s);
ret = 0;
acls.clear();
}
void execute();
virtual void send_response() = 0;
};
class RGWPutACLs : public RGWOp {
protected:
int ret;
size_t len;
char *data;
public:
RGWPutACLs() {}
~RGWPutACLs() {}
virtual void init(struct req_state *s) {
RGWOp::init(s);
ret = 0;
len = 0;
data = NULL;
}
void execute();
virtual int get_params() = 0;
virtual void send_response() = 0;
};
class RGWHandler {
protected:
struct req_state *s;
virtual void provider_init_state() = 0;
int do_read_permissions(bool only_bucket);
public:
RGWHandler() {}
virtual ~RGWHandler() {}
void init_state(struct req_state *s, struct fcgx_state *fcgx);
RGWOp *get_op();
virtual int read_permissions() = 0;
};
#endif
|