quota.c (dovecot-2.3.16) | : | quota.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 836 | skipping to change at line 836 | |||
*limit_r = (*limit_r + 1023) / 1024; | *limit_r = (*limit_r + 1023) / 1024; | |||
} | } | |||
return *limit_r == 0 ? QUOTA_GET_RESULT_UNLIMITED : QUOTA_GET_RESULT_LIMI TED; | return *limit_r == 0 ? QUOTA_GET_RESULT_UNLIMITED : QUOTA_GET_RESULT_LIMI TED; | |||
} | } | |||
int quota_set_resource(struct quota_root *root, const char *name, | int quota_set_resource(struct quota_root *root, const char *name, | |||
uint64_t value, const char **client_error_r) | uint64_t value, const char **client_error_r) | |||
{ | { | |||
struct dict_transaction_context *trans; | struct dict_transaction_context *trans; | |||
const char *key, *error; | const char *key, *error; | |||
const struct dict_op_settings *set; | ||||
if (root->set->limit_set == NULL) { | if (root->set->limit_set == NULL) { | |||
*client_error_r = MAIL_ERRSTR_NO_PERMISSION; | *client_error_r = MAIL_ERRSTR_NO_PERMISSION; | |||
return -1; | return -1; | |||
} | } | |||
if (strcasecmp(name, QUOTA_NAME_STORAGE_KILOBYTES) == 0) | if (strcasecmp(name, QUOTA_NAME_STORAGE_KILOBYTES) == 0) | |||
key = "storage"; | key = "storage"; | |||
else if (strcasecmp(name, QUOTA_NAME_STORAGE_BYTES) == 0) | else if (strcasecmp(name, QUOTA_NAME_STORAGE_BYTES) == 0) | |||
key = "bytes"; | key = "bytes"; | |||
else if (strcasecmp(name, QUOTA_NAME_MESSAGES) == 0) | else if (strcasecmp(name, QUOTA_NAME_MESSAGES) == 0) | |||
skipping to change at line 857 | skipping to change at line 858 | |||
else { | else { | |||
*client_error_r = t_strdup_printf( | *client_error_r = t_strdup_printf( | |||
"Unsupported resource name: %s", name); | "Unsupported resource name: %s", name); | |||
return -1; | return -1; | |||
} | } | |||
if (root->limit_set_dict == NULL) { | if (root->limit_set_dict == NULL) { | |||
struct dict_settings set; | struct dict_settings set; | |||
i_zero(&set); | i_zero(&set); | |||
set.username = root->quota->user->username; | ||||
set.base_dir = root->quota->user->set->base_dir; | set.base_dir = root->quota->user->set->base_dir; | |||
set.event_parent = root->quota->user->event; | set.event_parent = root->quota->user->event; | |||
if (mail_user_get_home(root->quota->user, &set.home_dir) <= 0) | ||||
set.home_dir = NULL; | ||||
if (dict_init(root->set->limit_set, &set, | if (dict_init(root->set->limit_set, &set, | |||
&root->limit_set_dict, &error) < 0) { | &root->limit_set_dict, &error) < 0) { | |||
e_error(root->quota->event, | e_error(root->quota->event, | |||
"dict_init() failed: %s", error); | "dict_init() failed: %s", error); | |||
*client_error_r = "Internal quota limit update error"; | *client_error_r = "Internal quota limit update error"; | |||
return -1; | return -1; | |||
} | } | |||
} | } | |||
trans = dict_transaction_begin(root->limit_set_dict); | set = mail_user_get_dict_op_settings(root->ns->user); | |||
trans = dict_transaction_begin(root->limit_set_dict, set); | ||||
key = t_strdup_printf(QUOTA_LIMIT_SET_PATH"%s", key); | key = t_strdup_printf(QUOTA_LIMIT_SET_PATH"%s", key); | |||
dict_set(trans, key, dec2str(value)); | dict_set(trans, key, dec2str(value)); | |||
if (dict_transaction_commit(&trans, &error) < 0) { | if (dict_transaction_commit(&trans, &error) < 0) { | |||
e_error(root->quota->event, | e_error(root->quota->event, | |||
"dict_transaction_commit() failed: %s", error); | "dict_transaction_commit() failed: %s", error); | |||
*client_error_r = "Internal quota limit update error"; | *client_error_r = "Internal quota limit update error"; | |||
return -1; | return -1; | |||
} | } | |||
return 0; | return 0; | |||
} | } | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 3 lines changed or added |