doveadm-acl.c revision 5c3e746d1a319a911a7b03f80367603b95f7ae2b
/* Copyright (c) 2011 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "module-dir.h"
#include "imap-util.h"
#include "acl-plugin.h"
#include "acl-api-private.h"
#include "acl-lookup-dict.h"
#include "doveadm-print.h"
#include "doveadm-mail.h"
struct doveadm_acl_cmd_context {
struct doveadm_mail_cmd_context ctx;
bool get_match_me;
};
const char *doveadm_acl_plugin_version = DOVECOT_VERSION;
void doveadm_acl_plugin_deinit(void);
static int
{
struct mail_namespace *ns;
return -1;
}
return -1;
}
if (mailbox_open(box) < 0) {
mailbox_free(&box);
return -1;
}
return 0;
}
{
const char *id = "";
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();
}
doveadm_print("global");
else
doveadm_print("");
}
}
{
struct acl_backend *backend;
struct acl_object_list_iter *iter;
struct acl_rights rights;
int ret;
if (!ctx->get_match_me ||
} T_END;
if (ret < 0)
i_error("ACL iteration failed");
}
static void
{
struct doveadm_acl_cmd_context *ctx =
(struct doveadm_acl_cmd_context *)_ctx;
return;
mailbox_free(&box);
}
{
struct doveadm_acl_cmd_context *ctx =
(struct doveadm_acl_cmd_context *)_ctx;
switch (c) {
case 'm':
break;
default:
return FALSE;
}
return TRUE;
}
const char *const args[])
{
doveadm_mail_help_name("acl get");
}
static struct doveadm_mail_cmd_context *
cmd_acl_get_alloc(void)
{
struct doveadm_acl_cmd_context *ctx;
}
static void
{
struct acl_object *aclobj;
const char *const *rights;
return;
&rights) < 0)
i_error("Failed to get rights");
else
mailbox_free(&box);
}
const char *const args[])
{
doveadm_mail_help_name("acl rights");
}
static struct doveadm_mail_cmd_context *
cmd_acl_rights_alloc(void)
{
struct doveadm_mail_cmd_context *ctx;
return ctx;
}
static bool is_standard_right(const char *name)
{
unsigned int i;
for (i = 0; all_mailbox_rights[i] != NULL; i++) {
return TRUE;
}
return FALSE;
}
static void
{
struct acl_object *aclobj;
struct acl_rights_update update;
unsigned int i, j;
return;
if (right[0] != '-')
dest = &dest_rights;
else {
right++;
dest = &dest_neg_rights;
}
if (*right == ':') {
/* non-standard right */
right++;
} else if (is_standard_right(right)) {
} else {
}
} else {
for (j = 0; all_mailbox_rights[j] != NULL; j++)
}
}
if (array_count(&dest_rights) > 0) {
(void)array_append_space(&dest_rights);
} else {
}
if (array_count(&dest_neg_rights) > 0) {
(void)array_append_space(&dest_neg_rights);
} else {
}
i_error("Failed to set ACL");
mailbox_free(&box);
}
const char *const args[])
{
doveadm_mail_help_name("acl set");
}
static struct doveadm_mail_cmd_context *
cmd_acl_set_alloc(void)
{
struct doveadm_mail_cmd_context *ctx;
return ctx;
}
static void
{
struct acl_object *aclobj;
struct acl_rights_update update;
return;
i_error("Failed to set ACL");
mailbox_free(&box);
}
const char *const args[])
{
doveadm_mail_help_name("acl delete");
}
static struct doveadm_mail_cmd_context *
cmd_acl_delete_alloc(void)
{
struct doveadm_mail_cmd_context *ctx;
return ctx;
}
static int
{
struct mail_namespace *ns;
enum mail_error error;
return -1;
}
if (mailbox_open(box) < 0) {
if (error != MAIL_ERROR_NOTFOUND ||
else {
i_error("Mailbox '%s' doesn't exist in %s",
}
mailbox_free(&box);
return -1;
}
i_info("ACL not enabled for user %s, mailbox can be accessed",
mailbox_free(&box);
return -1;
}
return 0;
}
{
struct acl_mailbox_list_context *iter;
struct acl_lookup_dict_iter *diter;
enum mail_flags private_flags_mask;
int ret;
if (private_flags_mask == 0)
i_info("All message flags are shared across users in mailbox");
else {
}
/* check if user has lookup right */
&rights) < 0)
i_fatal("Failed to get rights");
else {
i_info("User %s has rights: %s",
}
i_error("User %s is missing 'lookup' right",
return FALSE;
}
/* check if mailbox is listable */
i_info("Mailbox in user's private namespace");
return TRUE;
}
break;
}
if (ret < 0)
i_fatal("ACL non-owner iteration failed");
if (ret == 0) {
i_error("Mailbox not found from dovecot-acl-list, rebuilding");
if (acl_backend_nonowner_lookups_rebuild(backend) < 0)
i_fatal("dovecot-acl-list rebuilding failed");
} else {
i_info("Mailbox found from dovecot-acl-list");
}
i_info("Mailbox is in public namespace");
return TRUE;
}
i_error("acl_lookup_dict not enabled");
return FALSE;
}
/* shared namespace. see if it's in acl lookup dict */
break;
}
if (acl_lookup_dict_iterate_visible_deinit(&diter) < 0)
i_fatal("ACL shared dict iteration failed");
i_error("User %s not found from ACL shared dict, rebuilding",
i_fatal("ACL lookup dict rebuild failed");
} else {
i_info("User %s found from ACL shared dict",
}
return all_ok;
}
static void
{
return;
i_info("Retrying after rebuilds:");
}
if (ret)
else
mailbox_free(&box);
}
const char *const args[])
{
doveadm_mail_help_name("acl debug");
}
static struct doveadm_mail_cmd_context *
cmd_acl_debug_alloc(void)
{
struct doveadm_mail_cmd_context *ctx;
return ctx;
}
static struct doveadm_mail_cmd acl_commands[] = {
};
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(acl_commands); i++)
}
void doveadm_acl_plugin_deinit(void)
{
}