imap-acl-plugin.c revision 6882df5fbca4a09cdaa95f54d70bb31b5920528c
/* Copyright (c) 2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "str.h"
#include "imap-quote.h"
#include "imap-resp-code.h"
#include "commands.h"
#include "mail-storage.h"
#include "mail-namespace.h"
#include "acl-api.h"
#include "acl-storage.h"
#include "imap-acl-plugin.h"
#include <stdlib.h>
"You lack administrator privileges on this mailbox."
#define ACL_MAILBOX_OPEN_FLAGS \
#define IMAP_ACL_ANYONE "anyone"
#define IMAP_ACL_AUTHENTICATED "authenticated"
#define IMAP_ACL_OWNER "owner"
#define IMAP_ACL_GROUP_PREFIX "$"
#define IMAP_ACL_GROUP_OVERRIDE_PREFIX "!$"
#define IMAP_ACL_GLOBAL_PREFIX "#"
struct imap_acl_letter_map {
char letter;
const char *name;
};
static const struct imap_acl_letter_map imap_acl_letter_map[] = {
{ 'l', MAIL_ACL_LOOKUP },
{ 'r', MAIL_ACL_READ },
{ 'w', MAIL_ACL_WRITE },
{ 's', MAIL_ACL_WRITE_SEEN },
{ 't', MAIL_ACL_WRITE_DELETED },
{ 'i', MAIL_ACL_INSERT },
{ 'e', MAIL_ACL_EXPUNGE },
{ 'k', MAIL_ACL_CREATE },
{ 'x', MAIL_ACL_DELETE },
{ 'a', MAIL_ACL_ADMIN },
{ '\0', NULL }
};
static bool acl_anyone_allow = FALSE;
static struct mailbox *
{
struct mail_storage *storage;
int ret;
return NULL;
/* Force opening the mailbox so that we can give a nicer error message
if mailbox isn't selectable but is listable. */
return NULL;
}
if (ret > 0)
return box;
/* not an administrator. */
} else {
}
mailbox_close(&box);
return NULL;
}
static const struct imap_acl_letter_map *
imap_acl_letter_map_find(const char *name)
{
unsigned int i;
return &imap_acl_letter_map[i];
}
return NULL;
}
static void
{
const struct imap_acl_letter_map *map;
unsigned int i;
/* write only letters */
}
}
if (append_c)
if (append_d)
}
static void
{
str_truncate(tmp, 0);
case ACL_ID_ANYONE:
break;
case ACL_ID_AUTHENTICATED:
break;
case ACL_ID_OWNER:
break;
case ACL_ID_USER:
break;
case ACL_ID_GROUP:
break;
case ACL_ID_GROUP_OVERRIDE:
break;
case ACL_ID_TYPE_COUNT:
i_unreached();
}
}
{
struct acl_object_list_iter *iter;
struct acl_rights rights;
int ret;
}
return ret;
}
{
const char *mailbox;
unsigned int len;
int ret;
return TRUE;
}
return TRUE;
if (ret == 0) {
} else {
}
mailbox_close(&box);
return TRUE;
}
{
struct mail_storage *storage;
const char *mailbox, *real_mailbox;
const char *const *rights;
return TRUE;
}
return TRUE;
return TRUE;
}
pool_datastack_create(), &rights) < 0) {
mailbox_close(&box);
return TRUE;
}
return TRUE;
}
{
const char *mailbox, *identifier;
return TRUE;
}
return TRUE;
return TRUE;
}
static int
const char **error_r)
{
unsigned int i;
break;
}
}
*letters);
return -1;
}
}
(void)array_append_space(&rights);
return 0;
}
static int
bool check_anyone, const char **error_r)
{
strlen(IMAP_ACL_GLOBAL_PREFIX)) == 0) {
id);
return -1;
}
if (!acl_anyone_allow && check_anyone) {
*error_r = "'anyone' identifier is disallowed";
return -1;
}
if (!acl_anyone_allow && check_anyone) {
*error_r = "'authenticated' identifier is disallowed";
return -1;
}
strlen(IMAP_ACL_GROUP_PREFIX)) == 0) {
strlen(IMAP_ACL_GROUP_OVERRIDE_PREFIX)) == 0) {
} else {
}
return 0;
}
{
struct acl_rights_update update;
return TRUE;
}
if (*identifier == '-') {
identifier++;
}
return TRUE;
}
return TRUE;
}
return TRUE;
switch (*rights) {
case '-':
rights++;
break;
case '+':
rights++;
break;
default:
break;
}
if (negative) {
}
else
mailbox_close(&box);
return TRUE;
}
{
struct acl_rights_update update;
*identifier == '\0') {
return TRUE;
}
if (*identifier != '-')
else {
identifier++;
}
return TRUE;
}
return TRUE;
else
mailbox_close(&box);
return TRUE;
}
void imap_acl_plugin_init(void)
{
const char *env;
return;
}
void imap_acl_plugin_deinit(void)
{
command_unregister("GETACL");
command_unregister("MYRIGHTS");
command_unregister("SETACL");
command_unregister("DELETEACL");
command_unregister("LISTRIGHTS");
}