]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: enable management of admin privileges.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 15 Feb 2016 13:16:58 +0000 (14:16 +0100)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 2 Jun 2016 13:30:38 +0000 (15:30 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_common.h
src/rgw/rgw_user.cc
src/rgw/rgw_user.h
src/test/cli/radosgw-admin/help.t

index 520fcc7986a858d050330fa91097b3641f0c3026..3abfbdd6a3382ede5aad331df43f1918caac256e 100644 (file)
@@ -169,6 +169,7 @@ void _usage()
   cout << "                             of read, write, readwrite, full\n";
   cout << "   --display-name=<name>\n";
   cout << "   --max_buckets             max number of buckets for a user\n";
+  cout << "   --admin                   set the admin flag on the user\n";
   cout << "   --system                  set the system flag on the user\n";
   cout << "   --bucket=<bucket>\n";
   cout << "   --pool=<pool>\n";
@@ -2021,6 +2022,8 @@ int main(int argc, char **argv)
   string start_marker;
   string end_marker;
   int max_entries = -1;
+  int admin = false;
+  bool admin_specified = false;
   int system = false;
   bool system_specified = false;
   int shard_id = -1;
@@ -2124,6 +2127,8 @@ int main(int argc, char **argv)
       // do nothing
     } else if (ceph_argparse_binary_flag(args, i, &skip_zero_entries, NULL, "--skip_zero_entries", (char*)NULL)) {
       // do nothing
+    } else if (ceph_argparse_binary_flag(args, i, &admin, NULL, "--admin", (char*)NULL)) {
+      admin_specified = true;
     } else if (ceph_argparse_binary_flag(args, i, &system, NULL, "--system", (char*)NULL)) {
       system_specified = true;
     } else if (ceph_argparse_binary_flag(args, i, &staging, NULL, "--staging", (char*)NULL)) {
@@ -3639,6 +3644,9 @@ int main(int argc, char **argv)
   if (max_buckets >= 0)
     user_op.set_max_buckets(max_buckets);
 
+  if (admin_specified)
+     user_op.set_admin(admin);
+
   if (system_specified)
     user_op.set_system(system);
 
index 6d87f0b92a630a5ddf0d429a6a796687baededd3..ffb33741b4bb416bb10d96aa80db2081e80e7723 100644 (file)
@@ -540,6 +540,7 @@ struct RGWUserInfo
   uint32_t max_buckets;
   uint32_t op_mask;
   RGWUserCaps caps;
+  __u8 admin;
   __u8 system;
   string default_placement;
   list<string> placement_tags;
@@ -547,7 +548,14 @@ struct RGWUserInfo
   map<int, string> temp_url_keys;
   RGWQuotaInfo user_quota;
 
-  RGWUserInfo() : auid(0), suspended(0), max_buckets(RGW_DEFAULT_MAX_BUCKETS), op_mask(RGW_OP_TYPE_ALL), system(0) {}
+  RGWUserInfo()
+    : auid(0),
+      suspended(0),
+      max_buckets(RGW_DEFAULT_MAX_BUCKETS),
+      op_mask(RGW_OP_TYPE_ALL),
+      admin(0),
+      system(0) {
+  }
 
   RGWAccessKey* get_key0() {
     if (access_keys.empty())
@@ -557,7 +565,7 @@ struct RGWUserInfo
   }
 
   void encode(bufferlist& bl) const {
-     ENCODE_START(17, 9, bl);
+     ENCODE_START(18, 9, bl);
      ::encode(auid, bl);
      string access_key;
      string secret_key;
@@ -596,10 +604,11 @@ struct RGWUserInfo
      ::encode(temp_url_keys, bl);
      ::encode(user_quota, bl);
      ::encode(user_id.tenant, bl);
+     ::encode(admin, bl);
      ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-     DECODE_START_LEGACY_COMPAT_LEN_32(17, 9, 9, bl);
+     DECODE_START_LEGACY_COMPAT_LEN_32(18, 9, 9, bl);
      if (struct_v >= 2) ::decode(auid, bl);
      else auid = CEPH_AUTH_UID_DEFAULT;
      string access_key;
@@ -666,6 +675,9 @@ struct RGWUserInfo
     } else {
       user_id.tenant.clear();
     }
+    if (struct_v >= 18) {
+      ::decode(admin, bl);
+    }
     DECODE_FINISH(bl);
   }
   void dump(Formatter *f) const;
index 1f93aa3d789b8c2b0904faba7363048cc28031c5..403384db288eb4c687eb0bbd58d0a3870c4f33b5 100644 (file)
@@ -1936,6 +1936,7 @@ int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg)
   }
 
   user_info.suspended = op_state.get_suspension_status();
+  user_info.admin = op_state.admin;
   user_info.system = op_state.system;
 
   if (op_state.op_mask_specified)
@@ -2145,6 +2146,9 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg)
   if (op_state.max_buckets_specified)
     user_info.max_buckets = op_state.get_max_buckets();
 
+  if (op_state.admin_specified)
+    user_info.admin = op_state.admin;
+
   if (op_state.system_specified)
     user_info.system = op_state.system;
 
index f3d0bce761a9d25abc514abc602fcf3116ff5c48..1281a4c818f2193af7bef0bcb47ddf9e6f9e4c95 100644 (file)
@@ -162,6 +162,7 @@ struct RGWUserAdminOpState {
   std::string display_name;
   uint32_t max_buckets;
   __u8 suspended;
+  __u8 admin;
   __u8 system;
   __u8 exclusive;
   __u8 fetch_stats;
@@ -201,6 +202,7 @@ struct RGWUserAdminOpState {
   bool op_mask_specified;
   bool caps_specified;
   bool suspension_op;
+  bool admin_specified;
   bool system_specified;
   bool key_op;
   bool temp_url_key_specified;
@@ -320,6 +322,11 @@ struct RGWUserAdminOpState {
     suspension_op = true;
   }
 
+  void set_admin(__u8 is_admin) {
+    admin = is_admin;
+    admin_specified = true;
+  }
+
   void set_system(__u8 is_system) {
     system = is_system;
     system_specified = true;
@@ -477,6 +484,7 @@ struct RGWUserAdminOpState {
     key_type = -1;
     perm_mask = RGW_PERM_NONE;
     suspended = 0;
+    admin = 0;
     system = 0;
     exclusive = 0;
     fetch_stats = 0;
index a2d38585c8d69e4bbcb2121363804eca7f78a22d..b4e5e306bf1af7d0fca59d34981a503c3c21428c 100644 (file)
                                of read, write, readwrite, full
      --display-name=<name>
      --max_buckets             max number of buckets for a user
+     --admin                   set the admin flag on the user
      --system                  set the system flag on the user
      --bucket=<bucket>
      --pool=<pool>