imap-acl-plugin.c revision 45c872f65e4f327ef166c6e2b71bb43e188ac562
/* Copyright (c) 2008-2009 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 },
{ 'p', MAIL_ACL_POST },
{ 'e', MAIL_ACL_EXPUNGE },
{ 'k', MAIL_ACL_CREATE },
{ 'x', MAIL_ACL_DELETE },
{ 'a', MAIL_ACL_ADMIN },
{ '\0', NULL }
};
const char *imap_acl_plugin_version = PACKAGE_VERSION;
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();
}
}
static int
bool add_default)
{
struct acl_object_list_iter *iter;
struct acl_rights rights;
const char *username;
int ret;
if (convert_owner) {
}
} else {
}
if (owner) {
if (seen_owner && convert_owner) {
/* oops, we have both owner and user=myself.
can't do the conversion, so try again. */
}
seen_owner = TRUE;
}
}
}
}
/* no positive owner rights returned, write default ACLs */
if (!convert_owner) {
} else {
}
}
}
return ret;
}
{
struct acl_backend *backend;
struct mail_namespace *ns;
struct mail_storage *storage;
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;
}
/* Post right alone doesn't give permissions to see if the mailbox
exists or not. Only mail deliveries care about that. */
mailbox_close(&box);
return TRUE;
}
mailbox_close(&box);
return TRUE;
}
{
const char *mailbox, *identifier;
return TRUE;
}
return TRUE;
mailbox_close(&box);
return TRUE;
}
static int
const char **error_r)
{
static const char *acl_k = MAIL_ACL_CREATE;
static const char *acl_x = MAIL_ACL_DELETE;
static const char *acl_e = MAIL_ACL_EXPUNGE;
static const char *acl_t = MAIL_ACL_WRITE_DELETED;
unsigned int i;
break;
}
}
/* Handling of obsolete rights as virtual
rights according to RFC 4314 */
switch (*letters) {
case 'c':
break;
case 'd':
break;
default:
"Invalid ACL right: %c", *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;
*identifier == '\0') {
return TRUE;
}
if (*identifier == '-') {
identifier++;
}
switch (*rights) {
case '-':
rights++;
break;
case '+':
rights++;
break;
default:
break;
}
return TRUE;
}
return TRUE;
}
return TRUE;
if (negative) {
update.modify_mode = 0;
} else {
update.neg_modify_mode = 0;
}
} else 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)
{
return;
command_unregister("GETACL");
command_unregister("MYRIGHTS");
command_unregister("SETACL");
command_unregister("DELETEACL");
command_unregister("LISTRIGHTS");
}