]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_aclparser.cc
update sources to v12.2.1
[ceph.git] / ceph / src / rgw / rgw_aclparser.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include <string.h>
5
6 #include "common/ceph_context.h"
7 #include "include/types.h"
8 #include "rgw/rgw_acl.h"
9
10 #include <iostream>
11 #include <map>
12
13 #define dout_subsys ceph_subsys_rgw
14
15 int main(int argc, char **argv) {
16 RGWACLXMLParser parser;
17
18 if (!parser.init())
19 exit(1);
20
21 char buf[1024];
22
23 for (;;) {
24 int done;
25 int len;
26
27 len = fread(buf, 1, sizeof(buf), stdin);
28 if (ferror(stdin)) {
29 fprintf(stderr, "Read error\n");
30 exit(-1);
31 }
32 done = feof(stdin);
33
34 parser.parse(buf, len, done);
35
36 if (done)
37 break;
38 }
39
40 RGWAccessControlPolicy *policy = (RGWAccessControlPolicy *)parser.find_first("AccessControlPolicy");
41
42 if (policy) {
43 string id="79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be";
44 dout(10) << hex << policy->get_perm(g_ceph_context, id, RGW_PERM_ALL) << dec << dendl;
45 policy->to_xml(cout);
46 }
47
48 cout << parser.get_xml() << endl;
49
50 bufferlist bl;
51 policy->encode(bl);
52
53 RGWAccessControlPolicy newpol;
54 bufferlist::iterator iter = bl.begin();
55 newpol.decode(iter);
56
57 newpol.to_xml(cout);
58
59 exit(0);
60 }
61