const char *name;
struct acl_backend *(*alloc)(void);
int (*init)(struct acl_backend *backend, const char **error_r);
- int (*init_legacy)(struct acl_backend *backend, const char *data);
void (*deinit)(struct acl_backend *backend);
struct acl_mailbox_list_context *
struct mail_storage;
struct mailbox;
struct acl_object;
-struct acl_settings;
+struct acl_backend;
#define MAILBOX_ATTRIBUTE_PREFIX_ACL \
MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT"acl/"
-/* data contains the information needed to initialize ACL backend. If username
- is NULL, it means the user is anonymous. Username and groups are matched
- case-sensitively. */
-struct acl_backend *
-acl_backend_init(const char *data, struct mailbox_list *list,
- const char *acl_username, const struct acl_settings *set,
- bool owner);
int acl_backend_init_auto(struct mailbox_list *list, struct acl_backend **backend_r,
const char **error_r);
void acl_backend_deinit(struct acl_backend **backend);
return 0;
}
-static int
-acl_backend_vfile_init_legacy(struct acl_backend *_backend, const char *data)
-{
- struct event *event = _backend->event;
- struct acl_backend_vfile *backend =
- container_of(_backend, struct acl_backend_vfile, backend);
- struct stat st;
- const char *value, *const *tmp;
- const char *global_path;
-
- tmp = t_strsplit(data, ":");
- global_path = t_strdup_empty(*tmp);
- backend->cache_secs = ACL_VFILE_DEFAULT_CACHE_SECS;
-
- if (*tmp != NULL)
- tmp++;
- for (; *tmp != NULL; tmp++) {
- if (str_begins(*tmp, "cache_secs=", &value)) {
- if (str_to_uint(value, &backend->cache_secs) < 0) {
- e_error(event,
- "acl vfile: Invalid cache_secs value: %s",
- *tmp + 11);
- return -1;
- }
- } else {
- e_error(event, "acl vfile: Unknown parameter: %s", *tmp);
- return -1;
- }
- }
- if (global_path != NULL) {
- if (stat(global_path, &st) < 0) {
- e_error(event,
- "acl vfile: stat(%s) failed: %m", global_path);
- return -1;
- } else if (S_ISDIR(st.st_mode)) {
- e_error(event,
- "acl vfile: Global ACL directories are no longer supported");
- return -1;
- } else {
- _backend->global_file = acl_global_file_init(
- global_path, backend->cache_secs, event);
- }
- }
- if (_backend->global_file == NULL)
- e_debug(event, "acl vfile: Global ACLs disabled");
- else
- e_debug(event, "acl vfile: Global ACL file: %s", global_path);
-
- _backend->cache =
- acl_cache_init(_backend,
- sizeof(struct acl_backend_vfile_validity));
- return 0;
-}
-
static void acl_backend_vfile_deinit(struct acl_backend *_backend)
{
struct acl_backend_vfile *backend =
.name = "vfile",
.alloc = acl_backend_vfile_alloc,
.init = acl_backend_vfile_init,
- .init_legacy = acl_backend_vfile_init_legacy,
.deinit = acl_backend_vfile_deinit,
.nonowner_lookups_iter_init = acl_backend_vfile_nonowner_iter_init,
.nonowner_lookups_iter_next = acl_backend_vfile_nonowner_iter_next,
return 1;
}
-struct acl_backend *
-acl_backend_init(const char *data, struct mailbox_list *list,
- const char *acl_username, const struct acl_settings *set,
- bool owner)
-{
- struct mail_user *user = mailbox_list_get_user(list);
- struct acl_backend_entry *be;
- struct acl_backend *backend;
- const char *be_name;
-
- e_debug(user->event, "acl: initializing backend with data: %s", data);
- e_debug(user->event, "acl: acl username = %s", acl_username);
- e_debug(user->event, "acl: owner = %d", owner ? 1 : 0);
-
- be_name = strchr(data, ':');
- if (be_name == NULL)
- be_name = data;
- else {
- be_name = t_strdup_until(data, be_name);
- data = be_name++;
- }
-
- be = acl_backend_find(be_name);
-
- backend = be->v->alloc();
- backend->event = event_create(user->event);
- event_add_category(backend->event, &event_category_acl);
-
- backend->v = be->v;
- backend->list = list;
- backend->username = p_strdup(backend->pool, acl_username);
- backend->owner = owner;
-
- if (event_want_debug(user->event) && array_is_created(&set->acl_groups)) {
- const char *group;
- array_foreach_elem(&set->acl_groups, group) {
- e_debug(user->event, "acl: group added: %s", group);
- }
- }
-
- backend->set = set;
-
- T_BEGIN {
- if (backend->v->init_legacy(backend, data) < 0)
- i_fatal("acl: backend %s init failed with data: %s",
- backend->v->name, data);
- } T_END;
-
- backend->default_rights = owner ? owner_mailbox_rights :
- non_owner_mailbox_rights;
- backend->default_aclmask =
- acl_cache_mask_init(backend->cache, backend->pool,
- backend->default_rights);
- return backend;
-}
-
void acl_backend_deinit(struct acl_backend **_backend)
{
struct acl_backend *backend = *_backend;