1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
/* Copyright (c) 2006-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "imap-match.h"
#include "wildcard-match.h"
#include "mailbox-tree.h"
#include "mail-namespace.h"
#include "mailbox-list-iter-private.h"
#include "acl-api-private.h"
#include "acl-cache.h"
#include "acl-shared-storage.h"
#include "acl-plugin.h"
#define MAILBOX_FLAG_MATCHED 0x40000000
struct acl_mailbox_list_iterate_context {
union mailbox_list_iterate_module_context module_ctx;
struct mailbox_tree_context *lookup_boxes;
struct mailbox_info info;
char sep;
bool hide_nonlistable_subscriptions:1;
bool simple_star_glob:1;
bool autocreate_acls_checked:1;
};
static const char *acl_storage_right_names[ACL_STORAGE_RIGHT_COUNT] = {
MAIL_ACL_LOOKUP,
MAIL_ACL_READ,
MAIL_ACL_WRITE,
MAIL_ACL_WRITE_SEEN,
MAIL_ACL_WRITE_DELETED,
MAIL_ACL_INSERT,
MAIL_ACL_POST,
MAIL_ACL_EXPUNGE,
MAIL_ACL_CREATE,
MAIL_ACL_DELETE,
MAIL_ACL_ADMIN
};
#define ACL_LIST_ITERATE_CONTEXT(obj) \
MODULE_CONTEXT_REQUIRE(obj, acl_mailbox_list_module)
struct acl_mailbox_list_module acl_mailbox_list_module =
MODULE_CONTEXT_INIT(&mailbox_list_module_register);
struct acl_backend *acl_mailbox_list_get_backend(struct mailbox_list *list)
{
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(list);
return alist->rights.backend;
}
int acl_mailbox_list_have_right(struct mailbox_list *list, const char *name,
bool parent, unsigned int acl_storage_right_idx,
bool *can_see_r)
{
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(list);
struct acl_backend *backend = alist->rights.backend;
const unsigned int *idx_arr = alist->rights.acl_storage_right_idx;
struct acl_object *aclobj;
int ret, ret2;
if (alist->ignore_acls)
return 1;
aclobj = !parent ?
acl_object_init_from_name(backend, name) :
acl_object_init_from_parent(backend, name);
ret = acl_object_have_right(aclobj, idx_arr[acl_storage_right_idx]);
if (can_see_r != NULL) {
ret2 = acl_object_have_right(aclobj,
idx_arr[ACL_STORAGE_RIGHT_LOOKUP]);
if (ret2 < 0)
ret = -1;
*can_see_r = ret2 > 0;
}
acl_object_deinit(&aclobj);
if (ret < 0)
mailbox_list_set_internal_error(list);
return ret;
}
static void
acl_mailbox_try_list_fast(struct mailbox_list_iterate_context *_ctx)
{
struct acl_mailbox_list_iterate_context *ctx =
ACL_LIST_ITERATE_CONTEXT(_ctx);
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(_ctx->list);
struct acl_backend *backend = alist->rights.backend;
const unsigned int *idxp;
const struct acl_mask *acl_mask;
struct acl_mailbox_list_context *nonowner_list_ctx;
struct mail_namespace *ns = _ctx->list->ns;
struct mailbox_list_iter_update_context update_ctx;
const char *name;
if ((_ctx->flags & (MAILBOX_LIST_ITER_RAW_LIST |
MAILBOX_LIST_ITER_SELECT_SUBSCRIBED)) != 0)
return;
if (ns->type == MAIL_NAMESPACE_TYPE_PUBLIC) {
/* mailboxes in public namespace should all be listable to
someone. we don't benefit from fast listing. */
return;
}
/* If ACLs are ignored for this namespace don't try fast listing. */
if (alist->ignore_acls)
return;
/* if this namespace's default rights contain LOOKUP, we'll need to
go through all mailboxes in any case. */
idxp = alist->rights.acl_storage_right_idx + ACL_STORAGE_RIGHT_LOOKUP;
if (acl_backend_get_default_rights(backend, &acl_mask) < 0 ||
acl_cache_mask_isset(acl_mask, *idxp))
return;
/* no LOOKUP right by default, we can optimize this */
i_zero(&update_ctx);
update_ctx.iter_ctx = _ctx;
update_ctx.glob =
imap_match_init(pool_datastack_create(), "*",
(ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0,
ctx->sep);
update_ctx.match_parents = TRUE;
update_ctx.tree_ctx = mailbox_tree_init(ctx->sep);
nonowner_list_ctx = acl_backend_nonowner_lookups_iter_init(backend);
while (acl_backend_nonowner_lookups_iter_next(nonowner_list_ctx,
&name)) {
T_BEGIN {
const char *vname =
mailbox_list_get_vname(ns->list, name);
mailbox_list_iter_update(&update_ctx, vname);
} T_END;
}
if (acl_backend_nonowner_lookups_iter_deinit(&nonowner_list_ctx) >= 0)
ctx->lookup_boxes = update_ctx.tree_ctx;
else
mailbox_tree_deinit(&update_ctx.tree_ctx);
}
static struct mailbox_list_iterate_context *
acl_mailbox_list_iter_init_shared(struct mailbox_list *list,
const char *const *patterns,
enum mailbox_list_iter_flags flags)
{
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(list);
struct mailbox_list_iterate_context *ctx;
int ret;
/* before listing anything add namespaces for all users
who may have visible mailboxes */
ret = acl_shared_namespaces_add(list->ns);
ctx = alist->module_ctx.super.iter_init(list, patterns, flags);
if (ret < 0)
ctx->failed = TRUE;
return ctx;
}
static struct mailbox_list_iterate_context *
acl_mailbox_list_iter_init(struct mailbox_list *list,
const char *const *patterns,
enum mailbox_list_iter_flags flags)
{
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(list);
struct mailbox_list_iterate_context *_ctx;
struct acl_mailbox_list_iterate_context *ctx;
const char *p;
unsigned int i;
_ctx = alist->module_ctx.super.iter_init(list, patterns, flags);
ctx = p_new(_ctx->pool, struct acl_mailbox_list_iterate_context, 1);
if (list->ns->type != MAIL_NAMESPACE_TYPE_PRIVATE &&
(list->ns->flags & NAMESPACE_FLAG_SUBSCRIPTIONS) != 0) {
/* non-private namespace with subscriptions=yes. this could be
a site-global subscriptions file, so hide subscriptions for
mailboxes the user doesn't see. */
ctx->hide_nonlistable_subscriptions = TRUE;
}
ctx->sep = mail_namespace_get_sep(list->ns);
/* see if all patterns have only a single '*' and it's at the end.
we can use it to do some optimizations. */
ctx->simple_star_glob = TRUE;
for (i = 0; patterns[i] != NULL; i++) {
p = strchr(patterns[i], '*');
if (p == NULL || p[1] != '\0') {
ctx->simple_star_glob = FALSE;
break;
}
}
MODULE_CONTEXT_SET(_ctx, acl_mailbox_list_module, ctx);
/* Try to avoid reading ACLs from all mailboxes by getting a smaller
list of mailboxes that have even potential to be visible. If we
couldn't get such a list, we'll go through all mailboxes. */
T_BEGIN {
acl_mailbox_try_list_fast(_ctx);
} T_END;
return _ctx;
}
static const struct mailbox_info *
acl_mailbox_list_iter_next_info(struct mailbox_list_iterate_context *_ctx)
{
struct acl_mailbox_list_iterate_context *ctx =
ACL_LIST_ITERATE_CONTEXT(_ctx);
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(_ctx->list);
const struct mailbox_info *info;
for (;;) {
/* Normally the data stack frame is in mailbox_list_iter_next(),
but we're bypassing it here by calling super.iter_next()
directly. */
T_BEGIN {
info = alist->module_ctx.super.iter_next(_ctx);
} T_END;
if (info == NULL)
break;
/* if we've a list of mailboxes with LOOKUP rights, skip the
mailboxes not in the list (since we know they can't be
visible to us). */
if (ctx->lookup_boxes == NULL ||
mailbox_tree_lookup(ctx->lookup_boxes, info->vname) != NULL)
break;
e_debug(_ctx->list->ns->user->event,
"acl: Mailbox not in dovecot-acl-list: %s", info->vname);
}
return info;
}
static const char *
acl_mailbox_list_iter_get_name(struct mailbox_list_iterate_context *ctx,
const char *vname)
{
struct mail_namespace *ns = ctx->list->ns;
const char *name;
size_t len;
name = mailbox_list_get_storage_name(ns->list, vname);
len = strlen(name);
if (len > 0 && name[len-1] == mailbox_list_get_hierarchy_sep(ns->list)) {
/* name ends with separator. this can happen if doing e.g.
LIST "" foo/% and it lists "foo/". */
name = t_strndup(name, len-1);
}
return name;
}
static bool
iter_is_listing_all_children(struct mailbox_list_iterate_context *_ctx)
{
struct acl_mailbox_list_iterate_context *ctx =
ACL_LIST_ITERATE_CONTEXT(_ctx);
const char *child;
/* If all patterns (with '.' separator) are in "name*", "name.*" or
"%.*" style format, simple_star_glob=TRUE and we can easily test
this by simply checking if name/child mailbox matches. */
child = t_strdup_printf("%s%cx", ctx->info.vname, ctx->sep);
return ctx->simple_star_glob &&
imap_match(_ctx->glob, child) == IMAP_MATCH_YES;
}
static bool
iter_mailbox_has_visible_children(struct mailbox_list_iterate_context *_ctx,
bool only_nonpatterns, bool subscribed)
{
struct acl_mailbox_list_iterate_context *ctx =
ACL_LIST_ITERATE_CONTEXT(_ctx);
struct mailbox_list_iterate_context *iter;
const struct mailbox_info *info;
string_t *pattern;
const char *prefix;
size_t i, prefix_len;
bool stars = FALSE, ret = FALSE;
/* do we have child mailboxes with LOOKUP right that don't match
the list pattern? */
if (ctx->lookup_boxes != NULL) {
/* we have a list of mailboxes with LOOKUP rights. before
starting the slow list iteration, check check first
if there even are any children with LOOKUP rights. */
struct mailbox_node *node;
node = mailbox_tree_lookup(ctx->lookup_boxes, ctx->info.vname);
i_assert(node != NULL);
if (node->children == NULL)
return FALSE;
}
/* if mailbox name has '*' characters in it, they'll conflict with the
LIST wildcard. replace then with '%' and verify later that all
results have the correct prefix. */
pattern = t_str_new(128);
for (i = 0; ctx->info.vname[i] != '\0'; i++) {
if (ctx->info.vname[i] != '*')
str_append_c(pattern, ctx->info.vname[i]);
else {
stars = TRUE;
str_append_c(pattern, '%');
}
}
if (i > 0 && ctx->info.vname[i-1] != ctx->sep)
str_append_c(pattern, ctx->sep);
str_append_c(pattern, '*');
prefix = str_c(pattern);
prefix_len = str_len(pattern) - 1;
iter = mailbox_list_iter_init(_ctx->list, str_c(pattern),
(!subscribed ? 0 :
MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
if (only_nonpatterns &&
imap_match(_ctx->glob, info->vname) == IMAP_MATCH_YES) {
/* at least one child matches also the original list
patterns. we don't need to show this mailbox. */
ret = FALSE;
break;
}
if (!stars || strncmp(info->vname, prefix, prefix_len) == 0)
ret = TRUE;
}
(void)mailbox_list_iter_deinit(&iter);
return ret;
}
static int
acl_mailbox_list_info_is_visible(struct mailbox_list_iterate_context *_ctx)
{
struct acl_mailbox_list_iterate_context *ctx =
ACL_LIST_ITERATE_CONTEXT(_ctx);
#define PRESERVE_MAILBOX_FLAGS (MAILBOX_SUBSCRIBED | MAILBOX_CHILD_SUBSCRIBED)
struct mailbox_info *info = &ctx->info;
const char *acl_name;
int ret;
if ((_ctx->flags & MAILBOX_LIST_ITER_RAW_LIST) != 0) {
/* skip ACL checks. */
return 1;
}
if ((_ctx->flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0 &&
(_ctx->flags & MAILBOX_LIST_ITER_RETURN_NO_FLAGS) != 0 &&
!ctx->hide_nonlistable_subscriptions) {
/* don't waste time doing an ACL check. we're going to list
all subscriptions anyway. */
info->flags &= MAILBOX_SUBSCRIBED | MAILBOX_CHILD_SUBSCRIBED;
return 1;
}
acl_name = acl_mailbox_list_iter_get_name(_ctx, info->vname);
ret = acl_mailbox_list_have_right(_ctx->list, acl_name, FALSE,
ACL_STORAGE_RIGHT_LOOKUP,
NULL);
if (ret != 0) {
if ((_ctx->flags & MAILBOX_LIST_ITER_RETURN_NO_FLAGS) != 0) {
/* don't waste time checking if there are visible
children, but also don't return incorrect flags */
info->flags &= ENUM_NEGATE(MAILBOX_CHILDREN);
} else if ((info->flags & MAILBOX_CHILDREN) != 0 &&
!iter_mailbox_has_visible_children(_ctx, FALSE, FALSE)) {
info->flags &= ENUM_NEGATE(MAILBOX_CHILDREN);
info->flags |= MAILBOX_NOCHILDREN;
}
return ret;
}
/* no permission to see this mailbox */
if ((_ctx->flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0) {
/* we're listing subscribed mailboxes. this one or its child
is subscribed, so we'll need to list it. but since we don't
have LOOKUP right, we'll need to show it as nonexistent. */
i_assert((info->flags & PRESERVE_MAILBOX_FLAGS) != 0);
info->flags = MAILBOX_NONEXISTENT |
(info->flags & PRESERVE_MAILBOX_FLAGS);
if (ctx->hide_nonlistable_subscriptions) {
/* global subscriptions file. hide this entry if there
are no visible subscribed children or if we're going
to list the subscribed children anyway. */
if ((info->flags & MAILBOX_CHILD_SUBSCRIBED) == 0)
return 0;
if (iter_is_listing_all_children(_ctx) ||
!iter_mailbox_has_visible_children(_ctx, TRUE, TRUE))
return 0;
/* e.g. LSUB "" % with visible subscribed children */
}
return 1;
}
if (!iter_is_listing_all_children(_ctx) &&
iter_mailbox_has_visible_children(_ctx, TRUE, FALSE)) {
/* no child mailboxes match the list pattern(s), but mailbox
has visible children. we'll need to show this as
non-existent. */
info->flags = MAILBOX_NONEXISTENT | MAILBOX_CHILDREN |
(info->flags & PRESERVE_MAILBOX_FLAGS);
return 1;
}
return 0;
}
static int
acl_mailbox_list_iter_check_autocreate_acls(struct mailbox_list_iterate_context *_ctx)
{
struct acl_mailbox_list_iterate_context *ctx =
ACL_LIST_ITERATE_CONTEXT(_ctx);
struct mailbox_settings *const *box_sets;
unsigned int i, count;
int ret;
ctx->autocreate_acls_checked = TRUE;
if (_ctx->autocreate_ctx == NULL)
return 0;
if ((_ctx->flags & MAILBOX_LIST_ITER_RAW_LIST) != 0) {
/* skip ACL checks. */
return 0;
}
box_sets = array_get(&_ctx->autocreate_ctx->box_sets, &count);
i_assert(array_count(&_ctx->autocreate_ctx->boxes) == count);
for (i = 0; i < count; ) {
const char *acl_name =
acl_mailbox_list_iter_get_name(_ctx, box_sets[i]->name);
ret = acl_mailbox_list_have_right(_ctx->list, acl_name, FALSE,
ACL_STORAGE_RIGHT_LOOKUP,
NULL);
if (ret < 0)
return -1;
if (ret > 0)
i++;
else {
/* no list right - remove the whole autobox */
array_delete(&_ctx->autocreate_ctx->box_sets, i, 1);
array_delete(&_ctx->autocreate_ctx->boxes, i, 1);
box_sets = array_get(&_ctx->autocreate_ctx->box_sets, &count);
}
}
return 0;
}
static const struct mailbox_info *
acl_mailbox_list_iter_next(struct mailbox_list_iterate_context *_ctx)
{
struct acl_mailbox_list_iterate_context *ctx =
ACL_LIST_ITERATE_CONTEXT(_ctx);
const struct mailbox_info *info;
int ret;
if (!ctx->autocreate_acls_checked) {
if (acl_mailbox_list_iter_check_autocreate_acls(_ctx) < 0) {
_ctx->failed = TRUE;
return NULL;
}
}
while ((info = acl_mailbox_list_iter_next_info(_ctx)) != NULL) {
ctx->info = *info;
T_BEGIN {
ret = acl_mailbox_list_info_is_visible(_ctx);
} T_END;
if (ret > 0)
break;
if (ret < 0) {
_ctx->failed = TRUE;
return NULL;
}
/* skip to next one */
e_debug(_ctx->list->ns->user->event,
"acl: No lookup right to mailbox: %s", info->vname);
}
return info == NULL ? NULL : &ctx->info;
}
static int
acl_mailbox_list_iter_deinit(struct mailbox_list_iterate_context *_ctx)
{
struct acl_mailbox_list_iterate_context *ctx =
ACL_LIST_ITERATE_CONTEXT(_ctx);
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(_ctx->list);
int ret = _ctx->failed ? -1 : 0;
if (ctx->lookup_boxes != NULL)
mailbox_tree_deinit(&ctx->lookup_boxes);
if (alist->module_ctx.super.iter_deinit(_ctx) < 0)
ret = -1;
return ret;
}
static void acl_mailbox_list_deinit(struct mailbox_list *list)
{
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(list);
if (alist->rights.backend != NULL)
acl_backend_deinit(&alist->rights.backend);
alist->module_ctx.super.deinit(list);
}
static void acl_mailbox_list_init_shared(struct mailbox_list *list)
{
struct acl_mailbox_list *alist;
struct mailbox_list_vfuncs *v = list->vlast;
alist = p_new(list->pool, struct acl_mailbox_list, 1);
alist->module_ctx.super = *v;
list->vlast = &alist->module_ctx.super;
v->deinit = acl_mailbox_list_deinit;
v->iter_init = acl_mailbox_list_iter_init_shared;
MODULE_CONTEXT_SET(list, acl_mailbox_list_module, alist);
}
static void acl_storage_rights_ctx_init(struct acl_storage_rights_context *ctx,
struct acl_backend *backend)
{
unsigned int i;
ctx->backend = backend;
for (i = 0; i < ACL_STORAGE_RIGHT_COUNT; i++) {
ctx->acl_storage_right_idx[i] =
acl_backend_lookup_right(backend,
acl_storage_right_names[i]);
}
}
static bool acl_namespace_is_ignored(struct mailbox_list *list)
{
const char *value =
mail_user_plugin_getenv(list->ns->user, "acl_ignore_namespace");
for (unsigned int i = 2; value != NULL; i++) {
if (wildcard_match(list->ns->prefix, value))
return TRUE;
value = mail_user_plugin_getenv(list->ns->user,
t_strdup_printf("acl_ignore_namespace%u", i));
}
return FALSE;
}
static void acl_mailbox_list_init_default(struct mailbox_list *list)
{
struct mailbox_list_vfuncs *v = list->vlast;
struct acl_mailbox_list *alist;
if (list->mail_set->mail_full_filesystem_access) {
/* not necessarily, but safer to do this for now. */
i_fatal("mail_full_filesystem_access=yes is "
"incompatible with ACLs");
}
alist = p_new(list->pool, struct acl_mailbox_list, 1);
alist->module_ctx.super = *v;
list->vlast = &alist->module_ctx.super;
v->deinit = acl_mailbox_list_deinit;
v->iter_init = acl_mailbox_list_iter_init;
v->iter_next = acl_mailbox_list_iter_next;
v->iter_deinit = acl_mailbox_list_iter_deinit;
if (acl_namespace_is_ignored(list))
alist->ignore_acls = TRUE;
MODULE_CONTEXT_SET(list, acl_mailbox_list_module, alist);
}
void acl_mail_namespace_storage_added(struct mail_namespace *ns)
{
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(ns->list);
struct acl_backend *backend;
const char *current_username, *owner_username;
bool owner = TRUE;
if (alist == NULL)
return;
struct acl_user *auser = ACL_USER_CONTEXT_REQUIRE(ns->user);
owner_username = ns->user->username;
current_username = auser->acl_user;
if (current_username == NULL)
current_username = owner_username;
else
owner = strcmp(current_username, owner_username) == 0;
/* We don't care about the username for non-private mailboxes.
It's used only when checking if we're the mailbox owner. We never
are for shared/public mailboxes. */
if (ns->type != MAIL_NAMESPACE_TYPE_PRIVATE)
owner = FALSE;
/* we need to know the storage when initializing backend */
backend = acl_backend_init(auser->acl_env, ns->list, current_username,
auser->groups, owner);
if (backend == NULL)
i_fatal("ACL backend initialization failed");
acl_storage_rights_ctx_init(&alist->rights, backend);
}
void acl_mailbox_list_created(struct mailbox_list *list)
{
struct acl_user *auser = ACL_USER_CONTEXT(list->ns->user);
if (auser == NULL) {
/* ACLs disabled for this user */
} else if ((list->ns->flags & NAMESPACE_FLAG_NOACL) != 0) {
/* no ACL checks for internal namespaces (lda, shared) */
if (list->ns->type == MAIL_NAMESPACE_TYPE_SHARED)
acl_mailbox_list_init_shared(list);
} else if ((list->ns->flags & NAMESPACE_FLAG_UNUSABLE) != 0) {
/* this namespace is empty. don't attempt to lookup ACLs,
because they're not going to work anyway and we could
crash doing it. */
} else {
acl_mailbox_list_init_default(list);
}
}
|