acl-backend-vfile.c revision 7fb70daba4e571eab5b64f496d20b9e37e31141b
/* Copyright (C) 2006 Timo Sirainen */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "istream.h"
#include "nfs-workarounds.h"
#include "mail-storage-private.h"
#include "acl-cache.h"
#include "acl-api-private.h"
#include <fcntl.h>
#include <unistd.h>
#define ACL_FILENAME "dovecot-acl"
#define ACL_SYNC_SECS 1
struct acl_vfile {
char *path;
};
struct acl_backend_vfile {
struct acl_backend backend;
const char *global_dir;
};
struct acl_object_vfile {
struct acl_object aclobj;
};
struct acl_letter_map {
char letter;
const char *name;
};
static const struct acl_letter_map acl_letter_map[] = {
{ 'l', MAIL_ACL_LOOKUP },
{ 'r', MAIL_ACL_READ },
{ 'w', MAIL_ACL_WRITE },
{ 's', MAIL_ACL_WRITE_SEEN },
{ 'd', MAIL_ACL_WRITE_DELETED },
{ 'i', MAIL_ACL_INSERT },
{ 'e', MAIL_ACL_EXPUNGE },
{ 'c', MAIL_ACL_CREATE },
{ 'd', MAIL_ACL_DELETE },
{ 'a', MAIL_ACL_ADMIN },
{ '\0', NULL }
};
{
struct acl_backend_vfile *backend;
}
{
}
static struct acl_object *
const char *name, const char *control_dir)
{
struct acl_backend_vfile *backend =
(struct acl_backend_vfile *)_backend;
struct acl_object_vfile *aclobj;
}
{
}
static const char *const *
{
const char *const *names;
unsigned int i;
/* parse IMAP ACL list */
acl++;
break;
}
return NULL;
}
}
if (*acl == '\0')
/* parse our own extended ACLs */
if (array_count(&rights) == 0)
return names;
}
static int
{
struct acl_rights rights;
return 0;
/* <id> [<imap acls>] [:<named acls>] */
t_push();
if (p == NULL)
p = "";
else {
p++;
}
if (*line != '-') {
} else {
line++;
}
} else {
}
"ACL file %s line %u: %s",
t_pop();
return -1;
}
t_pop();
return 0;
}
static int
bool try_retry)
{
const char *line;
unsigned int linenum;
if (fd == -1) {
return 1;
}
return -1;
}
linenum = 1;
linenum++) < 0) {
ret = -1;
break;
}
}
if (input->stream_errno != 0) {
ret = 0;
else {
ret = -1;
}
}
if (ret > 0) {
ret = 0;
else {
ret = -1;
}
} else {
}
}
return 0;
return -1;
}
return ret;
}
static int
{
unsigned int i;
int ret;
for (i = 0;; i++) {
i < ACL_ESTALE_RETRY_COUNT);
if (ret != 0)
break;
/* ESTALE - try again */
}
return ret <= 0 ? -1 : 0;
}
static int
{
if (file->last_read_time == 0)
return 1;
/* No global ACL directory */
return 0;
}
return -1;
}
/* same timestamp, but if it was modified within the
same second we want to refresh it again later (but
do it only after a couple of seconds so we don't
keep re-reading it all the time within those
seconds) */
return 0;
}
return 1;
}
{
int ret;
if (ret == 0)
if (ret <= 0)
return ret;
/* either global or local ACLs changed, need to re-read both */
&aclobj->global_file) < 0)
return -1;
return -1;
return 0;
}
const struct acl_rights *rights)
{
/* FIXME */
return -1;
}
static struct acl_object_list_iter *
{
struct acl_object_list_iter *iter;
return iter;
}
static int
struct acl_rights *rights_r)
{
return -1;
}
static void
{
}
struct acl_backend_vfuncs acl_backend_vfile = {
};