Both empty arguments and illegal parameters, can modify the existing configuration to none permissions.
It should be modified to:
1.empty parameter modify the existing configuration to none permissions.
2.illegal parameter return an error.
test fix:
before: subuser create or modify, illegal access parameter can modify the existing configuration.
after changes, do the same procedure, can check for illegal access parameters.
Signed-off-by: guce <guce@h3c.com>
using namespace std;
-
+#define RGW_PERM_NONE 0x00
#define RGW_PERM_READ 0x01
#define RGW_PERM_WRITE 0x02
#define RGW_PERM_READ_ACP 0x04
#define RGW_PERM_FULL_CONTROL ( RGW_PERM_READ | RGW_PERM_WRITE | \
RGW_PERM_READ_ACP | RGW_PERM_WRITE_ACP )
#define RGW_PERM_ALL_S3 RGW_PERM_FULL_CONTROL
+#define RGW_PERM_INVALID 0xFF00
enum ACLGranteeTypeEnum {
/* numbers are encoded, should not change */
RESTArgs::get_bool(s, "generate-secret", false, &gen_secret);
perm_mask = rgw_str_to_perm(perm_str.c_str());
+ op_state.set_perm(perm_mask);
// FIXME: no double checking
if (!uid.empty())
if (!secret_key.empty())
op_state.set_secret_key(secret_key);
- if (perm_mask != 0)
- op_state.set_perm(perm_mask);
-
op_state.set_generate_subuser(gen_subuser);
if (gen_secret)
RESTArgs::get_bool(s, "generate-secret", false, &gen_secret);
perm_mask = rgw_str_to_perm(perm_str.c_str());
+ op_state.set_perm(perm_mask);
// FIXME: no double checking
if (!uid.empty())
if (gen_secret)
op_state.set_gen_secret();
- if (perm_mask != 0)
- op_state.set_perm(perm_mask);
-
if (!key_type_str.empty()) {
if (key_type_str.compare("swift") == 0)
key_type = KEY_TYPE_SWIFT;
uint32_t rgw_str_to_perm(const char *str)
{
- if (strcasecmp(str, "read") == 0)
+ if (strcasecmp(str, "") == 0)
+ return RGW_PERM_NONE;
+ else if (strcasecmp(str, "read") == 0)
return RGW_PERM_READ;
else if (strcasecmp(str, "write") == 0)
return RGW_PERM_WRITE;
else if (strcasecmp(str, "full") == 0)
return RGW_PERM_FULL_CONTROL;
- return 0; // better to return no permission
+ return RGW_PERM_INVALID;
}
static bool validate_access_key(string& key)
return -EINVAL;
}
+ if (op_state.get_subuser_perm() == RGW_PERM_INVALID) {
+ set_err_msg(err_msg, "invaild subuser access");
+ return -EINVAL;
+ }
+
// check if the subuser exists
if (!subuser.empty())
existing = exists(subuser);
{
max_buckets = RGW_DEFAULT_MAX_BUCKETS;
key_type = -1;
- perm_mask = 0;
+ perm_mask = RGW_PERM_NONE;
suspended = 0;
system = 0;
exclusive = 0;