acl-backend-vfile-acllist.c revision 76b43e4417bab52e913da39b5f5bc2a130d3f149
/* Copyright (c) 2007-2008 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-backend-vfile.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
struct acl_mailbox_list_context_vfile {
struct acl_mailbox_list_context ctx;
unsigned int acllist_change_counter;
unsigned int idx;
};
static void
{
pool_alloconly_create("vfile acllist",
} else {
}
}
{
struct acl_backend_vfile_acllist acllist;
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;
}
return -1;
}
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)
}
}
{
const char *const *p;
/* ignore owner rights */
return FALSE;
}
return FALSE;
if (strcmp(*p, MAIL_ACL_LOOKUP) == 0)
return TRUE;
}
return FALSE;
}
static int
{
struct acl_object *aclobj;
struct acl_object_list_iter *iter;
struct acl_rights rights;
struct acl_backend_vfile_acllist acllist;
int ret;
if (rights_has_lookup_changes(&rights))
break;
}
ret = -1;
if (ret > 0) {
const char *line;
);
}
return ret < 0 ? -1 : 0;
}
{
struct mail_namespace *ns;
struct mailbox_list_iterate_context *iter;
const struct mailbox_info *info;
const char *rootdir, *acllist_path;
/* 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. */
if (fd == -1) {
return -1;
}
ret = 0;
acllist_clear(backend, 0);
ret = -1;
break;
}
}
if (mailbox_list_iter_deinit(&iter) < 0)
ret = -1;
if (ret == 0) {
ret = -1;
}
}
ret = -1;
}
if (ret == 0) {
i_error("rename(%s, %s) failed: %m",
ret = -1;
}
}
if (ret == 0) {
} else {
acllist_clear(backend, 0);
}
return ret;
}
static const struct acl_backend_vfile_acllist *
const char *name)
{
const struct acl_backend_vfile_acllist *acllist;
unsigned int i, count;
for (i = 0; i < count; i++) {
return &acllist[i];
}
return NULL;
}
{
const struct acl_backend_vfile_acllist *acllist;
}
struct acl_mailbox_list_context *
{
struct acl_backend_vfile *backend =
(struct acl_backend_vfile *)_backend;
struct acl_mailbox_list_context_vfile *ctx;
}
const char **name_r)
{
struct acl_mailbox_list_context_vfile *ctx =
(struct acl_mailbox_list_context_vfile *)_ctx;
struct acl_backend_vfile *backend =
const struct acl_backend_vfile_acllist *acllist;
unsigned int count;
return -1;
return 0;
return 1;
}
void
{
}