/* Copyright (c) 2011-2018 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 {
bool get_match_me;
};
void doveadm_acl_plugin_deinit(void);
static int
{
return -1;
}
if (mailbox_open(box) < 0) {
mailbox_free(&box);
return -1;
}
return 0;
}
{
doveadm_print("global");
else
doveadm_print("");
}
}
{
int ret;
if (!ctx->get_match_me ||
} T_END;
i_error("ACL iteration failed");
}
return ret;
}
static int
{
(struct doveadm_acl_cmd_context *)_ctx;
int ret;
return -1;
mailbox_free(&box);
return ret;
}
{
(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)
{
}
static int
{
const char *const *rights;
int ret = 0;
return -1;
&rights) < 0) {
i_error("Failed to get rights");
ret = -1;
} else {
}
mailbox_free(&box);
return ret;
}
const char *const args[])
{
doveadm_mail_help_name("acl rights");
}
static struct doveadm_mail_cmd_context *
cmd_acl_rights_alloc(void)
{
return ctx;
}
static int
const struct acl_rights_update *update)
{
struct mailbox_transaction_context *t;
int ret;
__func__);
if (mailbox_transaction_commit(&t) < 0)
ret = -1;
return ret;
}
static int
{
(struct doveadm_acl_cmd_context *)_ctx;
const char *error;
int ret;
return -1;
i_error("Failed to set ACL: %s",
}
mailbox_free(&box);
return ret;
}
const char *const args[])
{
doveadm_mail_help_name("acl set");
}
static struct doveadm_mail_cmd_context *
{
}
{
}
{
return cmd_acl_change_alloc(ACL_MODIFY_MODE_ADD);
}
{
}
static int
{
const char *error;
int ret = 0;
return -1;
i_error("Failed to delete ACL: %s",
}
mailbox_free(&box);
return ret;
}
const char *const args[])
{
doveadm_mail_help_name("acl delete");
}
static struct doveadm_mail_cmd_context *
cmd_acl_delete_alloc(void)
{
return ctx;
}
static int
{
return -1;
}
i_error("Failed to recalculate ACL dicts");
return -1;
}
return 0;
}
static struct doveadm_mail_cmd_context *
cmd_acl_recalc_alloc(void)
{
return ctx;
}
static int
{
if (mailbox_open(box) < 0) {
if (error != MAIL_ERROR_NOTFOUND ||
&path) <= 0)
else {
i_error("Mailbox '%s' in namespace '%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;
}
{
int ret;
i_info("Mailbox '%s' is in namespace '%s'",
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;
}
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 int
{
return -1;
i_info("Retrying after rebuilds:");
}
if (ret)
else
mailbox_free(&box);
return 0;
}
const char *const args[])
{
doveadm_mail_help_name("acl debug");
}
static struct doveadm_mail_cmd_context *
cmd_acl_debug_alloc(void)
{
return ctx;
}
{
.name = "acl get",
},
{
.name = "acl rights",
},
{
.name = "acl set",
},
{
.name = "acl add",
},
{
.name = "acl remove",
},
{
.name = "acl delete",
},
{
.name = "acl recalc",
},
{
.name = "acl debug",
}
};
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(acl_commands); i++)
}
void doveadm_acl_plugin_deinit(void)
{
}