57
59
parser = mail_search_parser_init_imap(args);
58
60
if (mail_search_build(mail_search_register_get_imap(),
59
parser, "UTF-8", &sargs, error_r) < 0)
61
parser, &charset, &sargs, error_r) < 0)
61
63
mail_search_parser_deinit(&parser);
64
imap_parser_destroy(&imap_parser);
66
imap_parser_unref(&imap_parser);
65
67
i_stream_destroy(&input);
137
139
if (*line == '-' || *line == '+' || *line == '!') line++;
138
140
bbox->ns = strcasecmp(line, "INBOX") == 0 ?
139
141
mail_namespace_find_inbox(user->namespaces) :
140
mail_namespace_find(user->namespaces, &line);
142
mail_namespace_find(user->namespaces, line);
143
if (!uni_utf8_str_is_valid(bbox->name)) {
144
*error_r = t_strdup_printf("Mailbox name not UTF-8: %s",
141
148
if (bbox->ns == NULL) {
142
149
*error_r = t_strdup_printf("Namespace not found for %s",
238
245
array_append(&ctx->mbox->backend_boxes, &bbox, 1);
248
static bool virtual_ns_match(struct mail_namespace *config_ns,
249
struct mail_namespace *iter_ns)
251
/* we match only one namespace for each pattern, except with shared
252
namespaces match also autocreated children */
253
if (config_ns == iter_ns)
255
if (config_ns->type == iter_ns->type &&
256
(config_ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0 &&
257
(iter_ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0)
241
262
static bool virtual_config_match(const struct mailbox_info *info,
242
263
ARRAY_TYPE(virtual_backend_box) *boxes_arr,
243
264
unsigned int *idx_r)
248
269
boxes = array_get_modifiable(boxes_arr, &count);
249
270
for (i = 0; i < count; i++) {
250
271
if (boxes[i]->glob != NULL) {
251
/* we match only one namespace for each pattern. */
252
if (boxes[i]->ns == info->ns &&
272
if (virtual_ns_match(boxes[i]->ns, info->ns) &&
253
273
imap_match(boxes[i]->glob,
254
274
info->name) == IMAP_MATCH_YES) {
334
354
struct mail_storage *storage = mbox->box.storage;
335
355
struct virtual_parse_context ctx;
337
const char *path, *line, *error;
357
const char *box_path, *path, *line, *error;
338
358
unsigned int linenum = 0;
341
361
i_array_init(&mbox->backend_boxes, 8);
342
362
mbox->search_args_crc32 = (uint32_t)-1;
344
path = t_strconcat(mbox->box.path, "/"VIRTUAL_CONFIG_FNAME, NULL);
364
box_path = mailbox_get_path(&mbox->box);
365
path = t_strconcat(box_path, "/"VIRTUAL_CONFIG_FNAME, NULL);
345
366
fd = open(path, O_RDONLY);
347
368
if (errno == EACCES) {
348
369
mail_storage_set_critical(storage, "%s",
349
mail_error_eacces_msg("stat", mbox->box.path));
370
mail_error_eacces_msg("open", path));
350
371
} else if (errno != ENOENT) {
351
372
mail_storage_set_critical(storage,
352
373
"open(%s) failed: %m", path);
353
} else if (stat(mbox->box.path, &st) == 0) {
374
} else if (stat(box_path, &st) == 0) {
354
375
mail_storage_set_error(storage, MAIL_ERROR_NOTPOSSIBLE,
355
376
"Virtual mailbox missing configuration file");
356
377
} else if (errno == ENOENT) {
358
379
T_MAIL_ERR_MAILBOX_NOT_FOUND(mbox->box.name));
360
381
mail_storage_set_critical(storage,
361
"stat(%s) failed: %m", mbox->box.path);
382
"stat(%s) failed: %m", box_path);