Lines Matching refs:root

73 static void quota_over_flag_check_root(struct quota_root *root);
204 /* <backend>[:<quota root name>[:<backend args>]] */
226 /* save root's name */
242 i_debug("Quota root: name=%s backend=%s args=%s",
343 *error_r = t_strdup_printf("Invalid quota root %s: %s",
371 static void quota_root_deinit(struct quota_root *root)
373 pool_t pool = root->pool;
375 if (root->limit_set_dict != NULL)
376 dict_deinit(&root->limit_set_dict);
377 root->backend.v.deinit(root);
381 int quota_root_default_init(struct quota_root *root, const char *args,
391 return quota_parse_parameters(root, &args, error_r, default_params, TRUE);
398 struct quota_root *root;
400 root = root_set->backend->v.alloc();
401 root->pool = pool_alloconly_create("quota root", 512);
402 root->set = root_set;
403 root->quota = quota;
404 root->backend = *root_set->backend;
405 root->bytes_limit = root_set->default_rule.bytes_limit;
406 root->count_limit = root_set->default_rule.count_limit;
408 array_create(&root->quota_module_contexts, root->pool,
411 if (root->backend.v.init != NULL) {
412 if (root->backend.v.init(root, root_set->args, error_r) < 0) {
414 root->backend.name, *error_r);
418 if (quota_root_default_init(root, root_set->args, error_r) < 0)
423 root->disable_unlimited_tracking) {
424 quota_root_deinit(root);
427 *root_r = root;
435 struct quota_root *root;
449 ret = quota_root_init(root_sets[i], quota, &root, &error);
451 *error_r = t_strdup_printf("Quota root %s: %s",
457 array_append(&quota->roots, &root, 1);
481 static int quota_root_get_rule_limits(struct quota_root *root,
494 if (!root->set->force_default_rule) {
495 if (root->backend.v.init_limits != NULL) {
497 if (root->backend.v.init_limits(root, &error) < 0) {
506 bytes_limit = root->bytes_limit;
507 count_limit = root->count_limit;
512 (void)mail_namespace_find_unalias(root->quota->user->namespaces,
514 rule = quota_root_rule_find(root->set, mailbox_name);
651 bool quota_root_is_namespace_visible(struct quota_root *root,
661 if (root->quota->unwanted_ns == ns)
664 if (root->ns_prefix != NULL) {
665 if (root->ns != ns)
675 quota_root_is_visible(struct quota_root *root, struct mailbox *box,
678 if (root->no_enforcing && enforce) {
679 /* we don't want to include this root in quota enforcing */
682 if (!quota_root_is_namespace_visible(root, box->list->ns))
684 if (array_count(&root->quota->roots) == 1) {
685 /* a single quota root: don't bother checking further */
688 return root->backend.v.match_box == NULL ? TRUE :
689 root->backend.v.match_box(root, box);
694 struct quota_root *const *roots, *root = NULL;
708 root = roots[iter->i];
713 return root;
741 const char *quota_root_get_name(struct quota_root *root)
743 return root->set->name;
746 const char *const *quota_root_get_resources(struct quota_root *root)
749 quota_over_flag_check_root(root);
751 return root->backend.v.get_resources(root);
754 bool quota_root_is_hidden(struct quota_root *root)
756 return root->hidden;
760 quota_get_resource(struct quota_root *root, const char *mailbox_name,
778 ret = root->backend.v.get_resource(root, name, value_r, &error);
782 root->backend.name, name, mailbox_name);
785 "quota-%s: %s", root->set->backend->name, error);
789 if (quota_root_get_rule_limits(root, mailbox_name,
793 "Failed to get quota root rule limits for mailbox %s: %s",
812 int quota_set_resource(struct quota_root *root, const char *name,
818 if (root->set->limit_set == NULL) {
833 if (root->limit_set_dict == NULL) {
837 set.username = root->quota->user->username;
838 set.base_dir = root->quota->user->set->base_dir;
839 if (mail_user_get_home(root->quota->user, &set.home_dir) <= 0)
841 if (dict_init(root->set->limit_set, &set,
842 &root->limit_set_dict, error_r) < 0)
846 trans = dict_transaction_begin(root->limit_set_dict);
940 "Failed to get quota root rule limits for %s: %s",
1009 static void quota_warning_execute(struct quota_root *root, const char *cmd,
1021 if (root->quota->set->debug)
1045 t_strconcat(root->quota->user->set->base_dir,
1065 struct quota_root *root)
1073 warnings = array_get_modifiable(&root->set->warning_rules, &count);
1077 if (quota_get_resource(root, "", QUOTA_NAME_STORAGE_BYTES,
1083 if (quota_get_resource(root, "", QUOTA_NAME_MESSAGES,
1104 quota_warning_execute(root, warnings[i].command,
1168 static bool quota_over_flag_init_root(struct quota_root *root,
1178 name = t_strconcat(root->set->set_name, "_over_script", NULL);
1179 *quota_over_script_r = mail_user_plugin_getenv(root->quota->user, name);
1181 if (root->quota->set->debug) {
1189 name = t_strconcat(root->set->set_name, "_over_flag_value", NULL);
1190 flag_mask = mail_user_plugin_getenv(root->quota->user, name);
1192 if (root->quota->set->debug) {
1201 name = t_strconcat(root->set->set_name, "_over_flag", NULL);
1202 *quota_over_flag_r = mail_user_plugin_getenv(root->quota->user, name);
1208 static void quota_over_flag_check_root(struct quota_root *root)
1218 if (root->quota_over_flag_checked)
1220 if (root->quota->user->session_create_time +
1223 if (root->quota->set->debug) {
1229 if (root->quota->user->session_restored) {
1233 if (root->quota->set->debug) {
1239 root->quota_over_flag_checked = TRUE;
1240 if (!quota_over_flag_init_root(root, &quota_over_script,
1244 resources = quota_root_get_resources(root);
1246 ret = quota_get_resource(root, "", resources[i], &value,
1254 if (root->quota->set->debug) {
1261 if (root->quota->set->debug) {
1268 quota_warning_execute(root, quota_over_script, quota_over_flag,
1405 "Failed to get quota root rule limits: %s",
1470 int quota_parse_parameters(struct quota_root *root, const char **args, const char **error_r,
1501 valid_params->param_handler(root, tmp_param_val);
1510 root->backend.name, *args);