bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "lib.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "array.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "str.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "safe-mkstemp.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "istream.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "ostream.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "mail-namespace.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "mail-storage.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "acl-plugin.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "acl-cache.h"
81e6e1ef0feef60644a4c4b745d82a4c98223affTimo Sirainen#include "acl-lookup-dict.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include "acl-backend-vfile.h"
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include <stdio.h>
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include <unistd.h>
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include <fcntl.h>
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen#include <sys/stat.h>
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenstruct acl_mailbox_list_context_vfile {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_mailbox_list_context ctx;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen unsigned int idx;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen};
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenstatic void
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenacllist_clear(struct acl_backend_vfile *backend, uoff_t file_size)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen{
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (backend->acllist_pool == NULL) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen backend->acllist_pool =
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen pool_alloconly_create("vfile acllist",
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen I_MAX(file_size / 2, 128));
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen i_array_init(&backend->acllist, I_MAX(16, file_size / 60));
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen } else {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen p_clear(backend->acllist_pool);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen array_clear(&backend->acllist);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen}
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainenstatic bool acl_list_get_root_dir(struct acl_backend_vfile *backend,
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen const char **root_dir_r,
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen enum mailbox_list_path_type *type_r)
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen{
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen struct mail_storage *storage;
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen const char *rootdir, *maildir;
8d9540a4536e294e69beb3d1f5b378eb06ba8bdaTimo Sirainen enum mailbox_list_path_type type;
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen
65d4c71add523a7a061da7fb82e97cfc4f7163c3Timo Sirainen if (backend->backend.globals_only)
65d4c71add523a7a061da7fb82e97cfc4f7163c3Timo Sirainen return FALSE;
65d4c71add523a7a061da7fb82e97cfc4f7163c3Timo Sirainen
8d9540a4536e294e69beb3d1f5b378eb06ba8bdaTimo Sirainen storage = mailbox_list_get_namespace(backend->backend.list)->storage;
8d9540a4536e294e69beb3d1f5b378eb06ba8bdaTimo Sirainen type = (storage->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_ROOT) != 0 ?
8d9540a4536e294e69beb3d1f5b378eb06ba8bdaTimo Sirainen MAILBOX_LIST_PATH_TYPE_CONTROL : MAILBOX_LIST_PATH_TYPE_DIR;
8d9540a4536e294e69beb3d1f5b378eb06ba8bdaTimo Sirainen if (!mailbox_list_get_root_path(backend->backend.list, type, &rootdir))
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen return FALSE;
8d9540a4536e294e69beb3d1f5b378eb06ba8bdaTimo Sirainen *type_r = type;
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen
8d9540a4536e294e69beb3d1f5b378eb06ba8bdaTimo Sirainen if (type == MAILBOX_LIST_PATH_TYPE_DIR &&
8d9540a4536e294e69beb3d1f5b378eb06ba8bdaTimo Sirainen mail_storage_is_mailbox_file(storage)) {
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen maildir = mailbox_list_get_root_forced(backend->backend.list,
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen MAILBOX_LIST_PATH_TYPE_MAILBOX);
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen if (strcmp(maildir, rootdir) == 0) {
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen /* dovecot-acl-list would show up as a mailbox if we
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen created it to root dir. since we don't really have
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen any other good alternatives, place it to control
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen dir */
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen rootdir = mailbox_list_get_root_forced(backend->backend.list,
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen MAILBOX_LIST_PATH_TYPE_CONTROL);
94f84d1c3f786d1b92dd2a1507f83a2dad887c56Timo Sirainen *type_r = MAILBOX_LIST_PATH_TYPE_CONTROL;
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen }
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen }
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen *root_dir_r = rootdir;
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen return TRUE;
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen}
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainenstatic bool acl_list_get_path(struct acl_backend_vfile *backend,
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen const char **path_r)
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen{
94f84d1c3f786d1b92dd2a1507f83a2dad887c56Timo Sirainen enum mailbox_list_path_type type;
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen const char *root_dir;
94f84d1c3f786d1b92dd2a1507f83a2dad887c56Timo Sirainen
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen if (!acl_list_get_root_dir(backend, &root_dir, &type))
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen return FALSE;
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen *path_r = t_strconcat(root_dir, "/"ACLLIST_FILENAME, NULL);
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen return TRUE;
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen}
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenstatic int acl_backend_vfile_acllist_read(struct acl_backend_vfile *backend)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen{
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_backend_vfile_acllist acllist;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct istream *input;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct stat st;
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen const char *path, *line, *p;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen int fd, ret = 0;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen backend->acllist_last_check = ioloop_time;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen if (!acl_list_get_path(backend, &path)) {
9aef7a5fcee899c061d35ed8f2fca6b0b5bee3d5Timo Sirainen /* we're never going to build acllist for this namespace. */
9e7eb7beae9828c66d944333264a79744d0313fbTimo Sirainen acllist_clear(backend, 0);
9aef7a5fcee899c061d35ed8f2fca6b0b5bee3d5Timo Sirainen return 0;
9aef7a5fcee899c061d35ed8f2fca6b0b5bee3d5Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (backend->acllist_mtime != 0) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen /* see if the file's mtime has changed */
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (stat(path, &st) < 0) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (errno == ENOENT)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen backend->acllist_mtime = 0;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen else
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen i_error("stat(%s) failed: %m", path);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return -1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (st.st_mtime == backend->acllist_mtime)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return 0;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen fd = open(path, O_RDONLY);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (fd == -1) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (errno == ENOENT) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen backend->acllist_mtime = 0;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return -1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen i_error("open(%s) failed: %m", path);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return -1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (fstat(fd, &st) < 0) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen i_error("fstat(%s) failed: %m", path);
4307c886579381dbb1897ea1388ae6978c96f560Timo Sirainen i_close_fd(&fd);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return -1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen backend->acllist_mtime = st.st_mtime;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acllist_clear(backend, st.st_size);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
e93184a9055c2530366dfe617e07199603c399ddMartti Rannanjärvi input = i_stream_create_fd(fd, (size_t)-1);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen while ((line = i_stream_read_next_line(input)) != NULL) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acllist.mtime = 0;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen for (p = line; *p >= '0' && *p <= '9'; p++)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acllist.mtime = acllist.mtime * 10 + (*p - '0');
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (p == line || *p != ' ' || p[1] == '\0') {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen i_error("Broken acllist file: %s", path);
46b823ac3bce2c0f9f0fc73911e48d3a77b04fbeTimo Sirainen i_unlink_if_exists(path);
af8b1248fed8529d26985460acdc4b1e4b7de675Timo Sirainen i_close_fd(&fd);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return -1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acllist.name = p_strdup(backend->acllist_pool, p + 1);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen array_append(&backend->acllist, &acllist, 1);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (input->stream_errno != 0)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen ret = -1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen i_stream_destroy(&input);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (close(fd) < 0)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen i_error("close(%s) failed: %m", path);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return ret;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen}
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenvoid acl_backend_vfile_acllist_refresh(struct acl_backend_vfile *backend)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen{
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen i_assert(!backend->iterating_acllist);
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen
ff4bb2dfb5714eeb0408d3bb862de1646351d097Timo Sirainen if (backend->acllist_last_check +
ff4bb2dfb5714eeb0408d3bb862de1646351d097Timo Sirainen (time_t)backend->cache_secs > ioloop_time)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (acl_backend_vfile_acllist_read(backend) < 0) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acllist_clear(backend, 0);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (!backend->rebuilding_acllist)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen (void)acl_backend_vfile_acllist_rebuild(backend);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen}
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenstatic int
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenacllist_append(struct acl_backend_vfile *backend, struct ostream *output,
c19f0dd4d274c15ef7b592dcc9d8c2c8c1e22abeTimo Sirainen const char *vname)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen{
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_object *aclobj;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_object_list_iter *iter;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_rights rights;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_backend_vfile_acllist acllist;
c19f0dd4d274c15ef7b592dcc9d8c2c8c1e22abeTimo Sirainen const char *name;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen int ret;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
c0a87e5f3316a57e6f915882fa1951d0fbb74a61Timo Sirainen name = mailbox_list_get_storage_name(backend->backend.list, vname);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acl_cache_flush(backend->backend.cache, name);
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen aclobj = acl_object_init_from_name(&backend->backend, name);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen iter = acl_object_list_init(aclobj);
c7f6992db44e9cd33b3b0d754833a1503ee9a53fAki Tuomi while (acl_object_list_next(iter, &rights)) {
3cd0463d17cf9ecbc3d826d60b36800d09f0633cTimo Sirainen if (acl_rights_has_nonowner_lookup_changes(&rights))
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen break;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
c7f6992db44e9cd33b3b0d754833a1503ee9a53fAki Tuomi ret = acl_object_list_deinit(&iter);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (acl_backend_vfile_object_get_mtime(aclobj, &acllist.mtime) < 0)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen ret = -1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (ret > 0) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acllist.name = p_strdup(backend->acllist_pool, name);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen array_append(&backend->acllist, &acllist, 1);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
19e8adccba16ff419f5675b1575358c2956dce83Timo Sirainen T_BEGIN {
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen const char *line;
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen line = t_strdup_printf("%s %s\n",
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen dec2str(acllist.mtime), name);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen o_stream_nsend_str(output, line);
19e8adccba16ff419f5675b1575358c2956dce83Timo Sirainen } T_END;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acl_object_deinit(&aclobj);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return ret < 0 ? -1 : 0;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen}
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainenstatic int
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainenacl_backend_vfile_acllist_try_rebuild(struct acl_backend_vfile *backend)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen{
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct mailbox_list *list = backend->backend.list;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct mail_namespace *ns;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct mailbox_list_iterate_context *iter;
94f84d1c3f786d1b92dd2a1507f83a2dad887c56Timo Sirainen enum mailbox_list_path_type type;
61e84692827b6a64912343f515c984853021483aTimo Sirainen const struct mailbox_info *info;
76b91bac787101e6b0075122ab6478dd98c8a884Timo Sirainen const char *rootdir, *acllist_path;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct ostream *output;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct stat st;
76b91bac787101e6b0075122ab6478dd98c8a884Timo Sirainen struct mailbox_permissions perm;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen string_t *path;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen int fd, ret;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen i_assert(!backend->rebuilding_acllist);
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen if (!acl_list_get_root_dir(backend, &rootdir, &type))
9aef7a5fcee899c061d35ed8f2fca6b0b5bee3d5Timo Sirainen return 0;
9aef7a5fcee899c061d35ed8f2fca6b0b5bee3d5Timo Sirainen
60b42c6dfdf9edcca8a96b380ef9a0adc60c2464Timo Sirainen ns = mailbox_list_get_namespace(list);
60b42c6dfdf9edcca8a96b380ef9a0adc60c2464Timo Sirainen if ((ns->flags & NAMESPACE_FLAG_UNUSABLE) != 0) {
60b42c6dfdf9edcca8a96b380ef9a0adc60c2464Timo Sirainen /* we can't write anything here */
60b42c6dfdf9edcca8a96b380ef9a0adc60c2464Timo Sirainen return 0;
60b42c6dfdf9edcca8a96b380ef9a0adc60c2464Timo Sirainen }
60b42c6dfdf9edcca8a96b380ef9a0adc60c2464Timo Sirainen
9aef7a5fcee899c061d35ed8f2fca6b0b5bee3d5Timo Sirainen path = t_str_new(256);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen str_printfa(path, "%s/%s", rootdir, mailbox_list_get_temp_prefix(list));
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen /* Build it into a temporary file and rename() over. There's no need
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen to use locking, because even if multiple processes are rebuilding
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen the file at the same time the result should be the same. */
76b91bac787101e6b0075122ab6478dd98c8a884Timo Sirainen mailbox_list_get_root_permissions(list, &perm);
76b91bac787101e6b0075122ab6478dd98c8a884Timo Sirainen fd = safe_mkstemp_group(path, perm.file_create_mode,
76b91bac787101e6b0075122ab6478dd98c8a884Timo Sirainen perm.file_create_gid,
76b91bac787101e6b0075122ab6478dd98c8a884Timo Sirainen perm.file_create_gid_origin);
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen if (fd == -1 && errno == ENOENT) {
94f84d1c3f786d1b92dd2a1507f83a2dad887c56Timo Sirainen if (mailbox_list_mkdir_root(backend->backend.list,
94f84d1c3f786d1b92dd2a1507f83a2dad887c56Timo Sirainen rootdir, type) < 0)
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen return -1;
76b91bac787101e6b0075122ab6478dd98c8a884Timo Sirainen fd = safe_mkstemp_group(path, perm.file_create_mode,
76b91bac787101e6b0075122ab6478dd98c8a884Timo Sirainen perm.file_create_gid,
76b91bac787101e6b0075122ab6478dd98c8a884Timo Sirainen perm.file_create_gid_origin);
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen }
b28bfb6b5dff1f5664c8e559239d2fa0d09d6a3bTimo Sirainen if (fd == -1) {
b16c5adb08f16484dd3b6bccc6f42a49ead51af5Timo Sirainen if (errno == EACCES) {
b16c5adb08f16484dd3b6bccc6f42a49ead51af5Timo Sirainen /* Ignore silently if we can't create it */
b16c5adb08f16484dd3b6bccc6f42a49ead51af5Timo Sirainen return 0;
b16c5adb08f16484dd3b6bccc6f42a49ead51af5Timo Sirainen }
b16c5adb08f16484dd3b6bccc6f42a49ead51af5Timo Sirainen i_error("dovecot-acl-list creation failed: "
b16c5adb08f16484dd3b6bccc6f42a49ead51af5Timo Sirainen "safe_mkstemp(%s) failed: %m", str_c(path));
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return -1;
b28bfb6b5dff1f5664c8e559239d2fa0d09d6a3bTimo Sirainen }
93fa87cf1a96c4f279ec4f5c311820313ba12c34Timo Sirainen output = o_stream_create_fd_file(fd, 0, FALSE);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen o_stream_cork(output);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen ret = 0;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acllist_clear(backend, 0);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen backend->rebuilding_acllist = TRUE;
c19f0dd4d274c15ef7b592dcc9d8c2c8c1e22abeTimo Sirainen iter = mailbox_list_iter_init(list, "*",
c19f0dd4d274c15ef7b592dcc9d8c2c8c1e22abeTimo Sirainen MAILBOX_LIST_ITER_RAW_LIST |
18ffea71d9beeec3cc1d400f751926ee72807f62Timo Sirainen MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen while ((info = mailbox_list_iter_next(iter)) != NULL) {
402e999a878e0cc41a0afb830fea0a93afc75f0dTimo Sirainen if (acllist_append(backend, output, info->vname) < 0) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen ret = -1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen break;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
ad9afb64630511d5e25bc5bc11c5304986156928Timo Sirainen if (o_stream_finish(output) < 0) {
0f3d4fbcf88e2ffd674893aed8cc1288fe17d290Timo Sirainen i_error("write(%s) failed: %s", str_c(path),
0f3d4fbcf88e2ffd674893aed8cc1288fe17d290Timo Sirainen o_stream_get_error(output));
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen ret = -1;
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (mailbox_list_iter_deinit(&iter) < 0)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen ret = -1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen o_stream_destroy(&output);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (ret == 0) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (fstat(fd, &st) < 0) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen i_error("fstat(%s) failed: %m", str_c(path));
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen ret = -1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (close(fd) < 0) {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen i_error("close(%s) failed: %m", str_c(path));
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen ret = -1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen if (ret == 0) {
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen if (!acl_list_get_path(backend, &acllist_path))
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen i_unreached();
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen if (rename(str_c(path), acllist_path) < 0) {
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen i_error("rename(%s, %s) failed: %m",
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen str_c(path), acllist_path);
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen ret = -1;
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen }
07c3b158517f50bb96b9f3d6e549de4195fbbc33Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (ret == 0) {
81e6e1ef0feef60644a4c4b745d82a4c98223affTimo Sirainen struct acl_user *auser = ACL_USER_CONTEXT(ns->user);
3131b3878de3245db7552234e66d437e8fde9351Aki Tuomi i_assert(auser != NULL);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen backend->acllist_mtime = st.st_mtime;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen backend->acllist_last_check = ioloop_time;
19557f192d37cd54a1a090a8a26d9d47265e4413Aki Tuomi /* FIXME: dict rebuild is expensive, try to avoid it */
81e6e1ef0feef60644a4c4b745d82a4c98223affTimo Sirainen (void)acl_lookup_dict_rebuild(auser->acl_lookup_dict);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen } else {
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acllist_clear(backend, 0);
46b823ac3bce2c0f9f0fc73911e48d3a77b04fbeTimo Sirainen i_unlink_if_exists(str_c(path));
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen backend->rebuilding_acllist = FALSE;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return ret;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen}
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainenint acl_backend_vfile_acllist_rebuild(struct acl_backend_vfile *backend)
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen{
d6407ae9e545d41fe6152bba47602f3299c26236Timo Sirainen const char *acllist_path;
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen if (acl_backend_vfile_acllist_try_rebuild(backend) == 0)
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen return 0;
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen else {
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen /* delete it to make sure it gets rebuilt later */
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen if (!acl_list_get_path(backend, &acllist_path))
3bbd5fd417b3b91c509a9174f1c21d5d3665b0adTimo Sirainen i_unreached();
46b823ac3bce2c0f9f0fc73911e48d3a77b04fbeTimo Sirainen i_unlink_if_exists(acllist_path);
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen return -1;
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen }
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen}
b6dab893cde3810ef3c3179531d487c41dbf027fTimo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenstatic const struct acl_backend_vfile_acllist *
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenacl_backend_vfile_acllist_find(struct acl_backend_vfile *backend,
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen const char *name)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen{
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen const struct acl_backend_vfile_acllist *acllist;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
e20e638805c4bd54e039891a3e92760b1dfa189aTimo Sirainen array_foreach(&backend->acllist, acllist) {
e20e638805c4bd54e039891a3e92760b1dfa189aTimo Sirainen if (strcmp(acllist->name, name) == 0)
e20e638805c4bd54e039891a3e92760b1dfa189aTimo Sirainen return acllist;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen }
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return NULL;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen}
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenvoid acl_backend_vfile_acllist_verify(struct acl_backend_vfile *backend,
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen const char *name, time_t mtime)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen{
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen const struct acl_backend_vfile_acllist *acllist;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen if (backend->rebuilding_acllist || backend->iterating_acllist)
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen return;
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acl_backend_vfile_acllist_refresh(backend);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acllist = acl_backend_vfile_acllist_find(backend, name);
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen if (acllist != NULL && acllist->mtime != mtime)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen (void)acl_backend_vfile_acllist_rebuild(backend);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen}
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenstruct acl_mailbox_list_context *
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenacl_backend_vfile_nonowner_iter_init(struct acl_backend *_backend)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen{
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_backend_vfile *backend =
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen (struct acl_backend_vfile *)_backend;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_mailbox_list_context_vfile *ctx;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acl_backend_vfile_acllist_refresh(backend);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen ctx = i_new(struct acl_mailbox_list_context_vfile, 1);
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen ctx->ctx.backend = _backend;
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen backend->iterating_acllist = TRUE;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen return &ctx->ctx;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen}
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomibool acl_backend_vfile_nonowner_iter_next(struct acl_mailbox_list_context *_ctx,
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen const char **name_r)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen{
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_mailbox_list_context_vfile *ctx =
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen (struct acl_mailbox_list_context_vfile *)_ctx;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen struct acl_backend_vfile *backend =
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen (struct acl_backend_vfile *)_ctx->backend;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen const struct acl_backend_vfile_acllist *acllist;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen unsigned int count;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi if (_ctx->failed)
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi return FALSE;
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen acllist = array_get(&backend->acllist, &count);
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi if (count == 0)
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi _ctx->empty = TRUE;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen if (ctx->idx == count)
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi return FALSE;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen *name_r = acllist[ctx->idx++].name;
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi return TRUE;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen}
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomiint
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainenacl_backend_vfile_nonowner_iter_deinit(struct acl_mailbox_list_context *ctx)
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen{
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen struct acl_backend_vfile *backend =
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen (struct acl_backend_vfile *)ctx->backend;
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi int ret;
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen
ae3979ff72bac46826291cff3ff85c0dd41120c6Timo Sirainen backend->iterating_acllist = FALSE;
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi if (ctx->failed)
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi ret = -1;
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi else if (ctx->empty)
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi ret = 0;
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi else
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi ret = 1;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen i_free(ctx);
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi return ret;
2f122b4db3f0d4eeb59ff9d306e54b2009d72cf9Timo Sirainen}
579e70631b8474d20fd3829f477c62950e5f9635Timo Sirainen
579e70631b8474d20fd3829f477c62950e5f9635Timo Sirainenint acl_backend_vfile_nonowner_lookups_rebuild(struct acl_backend *_backend)
579e70631b8474d20fd3829f477c62950e5f9635Timo Sirainen{
579e70631b8474d20fd3829f477c62950e5f9635Timo Sirainen struct acl_backend_vfile *backend =
579e70631b8474d20fd3829f477c62950e5f9635Timo Sirainen (struct acl_backend_vfile *)_backend;
579e70631b8474d20fd3829f477c62950e5f9635Timo Sirainen
579e70631b8474d20fd3829f477c62950e5f9635Timo Sirainen return acl_backend_vfile_acllist_rebuild(backend);
579e70631b8474d20fd3829f477c62950e5f9635Timo Sirainen}