/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "safe-mkstemp.h"
#include "istream.h"
#include "ostream.h"
#include "mail-namespace.h"
#include "mail-storage.h"
#include "acl-plugin.h"
#include "acl-cache.h"
#include "acl-lookup-dict.h"
#include "acl-backend-vfile.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
struct acl_mailbox_list_context_vfile {
unsigned int idx;
};
static void
{
pool_alloconly_create("vfile acllist",
} else {
}
}
const char **root_dir_r,
enum mailbox_list_path_type *type_r)
{
return FALSE;
return FALSE;
if (type == MAILBOX_LIST_PATH_TYPE_DIR &&
/* dovecot-acl-list would show up as a mailbox if we
created it to root dir. since we don't really have
any other good alternatives, place it to control
dir */
}
}
*root_dir_r = rootdir;
return TRUE;
}
const char **path_r)
{
const char *root_dir;
return FALSE;
return TRUE;
}
{
/* we're never going to build acllist for this namespace. */
acllist_clear(backend, 0);
return 0;
}
if (backend->acllist_mtime != 0) {
/* see if the file's mtime has changed */
backend->acllist_mtime = 0;
else
return -1;
}
return 0;
}
if (fd == -1) {
backend->acllist_mtime = 0;
return -1;
}
return -1;
}
i_close_fd(&fd);
return -1;
}
i_close_fd(&fd);
return -1;
}
}
if (input->stream_errno != 0)
ret = -1;
return ret;
}
{
if (backend->acllist_last_check +
return;
if (acl_backend_vfile_acllist_read(backend) < 0) {
acllist_clear(backend, 0);
if (!backend->rebuilding_acllist)
}
}
static int
const char *vname)
{
const char *name;
int ret;
break;
}
ret = -1;
if (ret > 0) {
T_BEGIN {
const char *line;
} T_END;
}
return ret < 0 ? -1 : 0;
}
static int
{
return 0;
/* we can't write anything here */
return 0;
}
/* Build it into a temporary file and rename() over. There's no need
to use locking, because even if multiple processes are rebuilding
the file at the same time the result should be the same. */
return -1;
}
if (fd == -1) {
/* Ignore silently if we can't create it */
return 0;
}
i_error("dovecot-acl-list creation failed: "
return -1;
}
ret = 0;
acllist_clear(backend, 0);
ret = -1;
break;
}
}
if (o_stream_finish(output) < 0) {
ret = -1;
}
if (mailbox_list_iter_deinit(&iter) < 0)
ret = -1;
if (ret == 0) {
ret = -1;
}
}
ret = -1;
}
if (ret == 0) {
i_unreached();
i_error("rename(%s, %s) failed: %m",
ret = -1;
}
}
if (ret == 0) {
/* FIXME: dict rebuild is expensive, try to avoid it */
} else {
acllist_clear(backend, 0);
}
return ret;
}
{
const char *acllist_path;
if (acl_backend_vfile_acllist_try_rebuild(backend) == 0)
return 0;
else {
/* delete it to make sure it gets rebuilt later */
i_unreached();
return -1;
}
}
static const struct acl_backend_vfile_acllist *
const char *name)
{
return acllist;
}
return NULL;
}
{
return;
}
struct acl_mailbox_list_context *
{
(struct acl_backend_vfile *)_backend;
}
const char **name_r)
{
(struct acl_mailbox_list_context_vfile *)_ctx;
unsigned int count;
return FALSE;
if (count == 0)
return FALSE;
return TRUE;
}
int
{
int ret;
ret = -1;
ret = 0;
else
ret = 1;
return ret;
}
{
(struct acl_backend_vfile *)_backend;
return acl_backend_vfile_acllist_rebuild(backend);
}