acl-lookup-dict.c (dovecot-2.3.16) | : | acl-lookup-dict.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 46 | skipping to change at line 46 | |||
const char *uri, *error; | const char *uri, *error; | |||
dict = i_new(struct acl_lookup_dict, 1); | dict = i_new(struct acl_lookup_dict, 1); | |||
dict->user = user; | dict->user = user; | |||
uri = mail_user_plugin_getenv(user, "acl_shared_dict"); | uri = mail_user_plugin_getenv(user, "acl_shared_dict"); | |||
if (uri != NULL) { | if (uri != NULL) { | |||
struct dict_settings dict_set; | struct dict_settings dict_set; | |||
i_zero(&dict_set); | i_zero(&dict_set); | |||
dict_set.username = ""; | ||||
dict_set.base_dir = user->set->base_dir; | dict_set.base_dir = user->set->base_dir; | |||
dict_set.event_parent = user->event; | dict_set.event_parent = user->event; | |||
if (dict_init(uri, &dict_set, &dict->dict, &error) < 0) | if (dict_init(uri, &dict_set, &dict->dict, &error) < 0) | |||
i_error("acl: dict_init(%s) failed: %s", uri, error); | i_error("acl: dict_init(%s) failed: %s", uri, error); | |||
} else { | } else { | |||
e_debug(user->event, "acl: No acl_shared_dict setting - " | e_debug(user->event, "acl: No acl_shared_dict setting - " | |||
"shared mailbox listing is disabled"); | "shared mailbox listing is disabled"); | |||
} | } | |||
return dict; | return dict; | |||
} | } | |||
skipping to change at line 163 | skipping to change at line 162 | |||
const char *username = dict->user->username; | const char *username = dict->user->username; | |||
struct dict_iterate_context *iter; | struct dict_iterate_context *iter; | |||
struct dict_transaction_context *dt = NULL; | struct dict_transaction_context *dt = NULL; | |||
const char *prefix, *key, *value, *const *old_ids, *const *new_ids, *p; | const char *prefix, *key, *value, *const *old_ids, *const *new_ids, *p; | |||
const char *error; | const char *error; | |||
ARRAY_TYPE(const_string) old_ids_arr; | ARRAY_TYPE(const_string) old_ids_arr; | |||
unsigned int newi, oldi, old_count, new_count; | unsigned int newi, oldi, old_count, new_count; | |||
string_t *path; | string_t *path; | |||
size_t prefix_len; | size_t prefix_len; | |||
int ret; | int ret; | |||
const struct dict_op_settings *set = mail_user_get_dict_op_settings(dict- >user); | ||||
/* get all existing identifiers for the user. we might be able to | /* get all existing identifiers for the user. we might be able to | |||
sync identifiers also for other users whose shared namespaces we | sync identifiers also for other users whose shared namespaces we | |||
have, but it's possible that the other users have other namespaces | have, but it's possible that the other users have other namespaces | |||
that aren't visible to us, so we don't want to remove anything | that aren't visible to us, so we don't want to remove anything | |||
that could break them. */ | that could break them. */ | |||
t_array_init(&old_ids_arr, 128); | t_array_init(&old_ids_arr, 128); | |||
prefix = DICT_PATH_SHARED DICT_SHARED_BOXES_PATH; | prefix = DICT_PATH_SHARED DICT_SHARED_BOXES_PATH; | |||
prefix_len = strlen(prefix); | prefix_len = strlen(prefix); | |||
iter = dict_iterate_init(dict->dict, prefix, DICT_ITERATE_FLAG_RECURSE); | iter = dict_iterate_init(dict->dict, set, prefix, DICT_ITERATE_FLAG_RECUR SE); | |||
while (dict_iterate(iter, &key, &value)) { | while (dict_iterate(iter, &key, &value)) { | |||
/* prefix/$type/$dest/$source */ | /* prefix/$type/$dest/$source */ | |||
key += prefix_len; | key += prefix_len; | |||
p = strrchr(key, '/'); | p = strrchr(key, '/'); | |||
if (p != NULL && strcmp(p + 1, username) == 0) { | if (p != NULL && strcmp(p + 1, username) == 0) { | |||
key = t_strdup_until(key, p); | key = t_strdup_until(key, p); | |||
array_push_back(&old_ids_arr, &key); | array_push_back(&old_ids_arr, &key); | |||
} | } | |||
} | } | |||
if (dict_iterate_deinit(&iter, &error) < 0) { | if (dict_iterate_deinit(&iter, &error) < 0) { | |||
skipping to change at line 206 | skipping to change at line 206 | |||
for (newi = oldi = 0; newi < new_count || oldi < old_count; ) { | for (newi = oldi = 0; newi < new_count || oldi < old_count; ) { | |||
ret = newi == new_count ? 1 : | ret = newi == new_count ? 1 : | |||
oldi == old_count ? -1 : | oldi == old_count ? -1 : | |||
strcmp(new_ids[newi], old_ids[oldi]); | strcmp(new_ids[newi], old_ids[oldi]); | |||
if (ret == 0) { | if (ret == 0) { | |||
newi++; oldi++; | newi++; oldi++; | |||
} else if (ret < 0) { | } else if (ret < 0) { | |||
/* new identifier, add it */ | /* new identifier, add it */ | |||
str_truncate(path, prefix_len); | str_truncate(path, prefix_len); | |||
str_append(path, new_ids[newi]); | str_append(path, new_ids[newi]); | |||
dt = dict_transaction_begin(dict->dict); | dt = dict_transaction_begin(dict->dict, set); | |||
dict_set(dt, str_c(path), "1"); | dict_set(dt, str_c(path), "1"); | |||
newi++; | newi++; | |||
} else if (!no_removes) { | } else if (!no_removes) { | |||
/* old identifier removed */ | /* old identifier removed */ | |||
str_truncate(path, prefix_len); | str_truncate(path, prefix_len); | |||
str_append(path, old_ids[oldi]); | str_append(path, old_ids[oldi]); | |||
str_append_c(path, '/'); | str_append_c(path, '/'); | |||
str_append(path, username); | str_append(path, username); | |||
dt = dict_transaction_begin(dict->dict); | dt = dict_transaction_begin(dict->dict, set); | |||
dict_unset(dt, str_c(path)); | dict_unset(dt, str_c(path)); | |||
oldi++; | oldi++; | |||
} | } | |||
if (dt != NULL && dict_transaction_commit(&dt, &error) < 0) { | if (dt != NULL && dict_transaction_commit(&dt, &error) < 0) { | |||
i_error("acl: dict commit failed: %s", error); | i_error("acl: dict commit failed: %s", error); | |||
return -1; | return -1; | |||
} | } | |||
i_assert(dt == NULL); | i_assert(dt == NULL); | |||
} | } | |||
return 0; | return 0; | |||
skipping to change at line 285 | skipping to change at line 285 | |||
prefix = t_strconcat(DICT_PATH_SHARED DICT_SHARED_BOXES_PATH, | prefix = t_strconcat(DICT_PATH_SHARED DICT_SHARED_BOXES_PATH, | |||
id, "/", NULL); | id, "/", NULL); | |||
prefix_len = strlen(prefix); | prefix_len = strlen(prefix); | |||
/* read all of it to memory. at least currently dict-proxy can support | /* read all of it to memory. at least currently dict-proxy can support | |||
only one iteration at a time, but the acl code can end up rebuilding | only one iteration at a time, but the acl code can end up rebuilding | |||
the dict, which opens another iteration. */ | the dict, which opens another iteration. */ | |||
p_clear(iter->iter_value_pool); | p_clear(iter->iter_value_pool); | |||
array_clear(&iter->iter_values); | array_clear(&iter->iter_values); | |||
dict_iter = dict_iterate_init(iter->dict->dict, prefix, | const struct dict_op_settings *set = mail_user_get_dict_op_settings(iter- | |||
>dict->user); | ||||
dict_iter = dict_iterate_init(iter->dict->dict, set, prefix, | ||||
DICT_ITERATE_FLAG_RECURSE); | DICT_ITERATE_FLAG_RECURSE); | |||
while (dict_iterate(dict_iter, &key, &value)) { | while (dict_iterate(dict_iter, &key, &value)) { | |||
i_assert(prefix_len < strlen(key)); | i_assert(prefix_len < strlen(key)); | |||
key = p_strdup(iter->iter_value_pool, key + prefix_len); | key = p_strdup(iter->iter_value_pool, key + prefix_len); | |||
array_push_back(&iter->iter_values, &key); | array_push_back(&iter->iter_values, &key); | |||
} | } | |||
if (dict_iterate_deinit(&dict_iter, &error) < 0) { | if (dict_iterate_deinit(&dict_iter, &error) < 0) { | |||
i_error("%s", error); | i_error("%s", error); | |||
iter->failed = TRUE; | iter->failed = TRUE; | |||
End of changes. 6 change blocks. | ||||
5 lines changed or deleted | 7 lines changed or added |