/* Copyright (c) 2006-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "hostpid.h"
#include "eacces-error.h"
#include "mkdir-parents.h"
#include "str.h"
#include "subscription-file.h"
#include "mailbox-list-subscriptions.h"
#include "mailbox-list-delete.h"
#include "mailbox-list-maildir.h"
#include <stdio.h>
extern struct mailbox_list maildir_mailbox_list;
extern struct mailbox_list imapdir_mailbox_list;
{
}
{
}
{
(struct maildir_mailbox_list *)_list;
}
static const char *
const char *name)
{
if (*name == '\0')
return dir;
}
static const char *
{
const char *p;
/* fallback to using as ~name */
return name;
}
if (p == NULL)
return name;
p+1);
}
{
(struct maildir_mailbox_list *)_list;
}
static int
{
const char *root_dir;
/* return root directories */
path_r) ? 1 : 0;
}
return 1;
}
switch (type) {
break;
return 0;
break;
return 1;
}
break;
return 1;
}
/* fall through */
return 0;
return 1;
}
break;
return 0;
return 1;
i_unreached();
}
if (type == MAILBOX_LIST_PATH_TYPE_ALT_DIR ||
/* don't use inbox_path */
return 1;
}
return 1;
}
static const char *
{
(struct maildir_mailbox_list *)_list;
}
{
(struct maildir_mailbox_list *)_list;
const char *path;
"Subscriptions not supported");
return -1;
}
}
static const char *
{
(struct maildir_mailbox_list *)_list;
const char *root_dir;
}
static int
{
int ret = 0;
if (ret < 0)
return -1;
if (ret == 0) {
/* we could actually use just unlink_directory()
but error handling is easier this way :) */
&path) <= 0)
i_unreached();
return -1;
}
return 0;
}
static int
{
const char *path;
int ret;
&path);
if (ret < 0)
return -1;
} else {
}
}
{
const char *path;
/* with maildir++ there aren't any non-selectable mailboxes.
we'll always fail. */
&path) <= 0)
i_unreached();
"Mailbox exists");
} else {
}
return -1;
}
enum mailbox_list_path_type type)
{
return 0;
return 0;
return -1;
}
return 0;
}
static int
{
unsigned int i, count;
char old_ns_sep;
int ret;
ret = 0;
/* first get the list of the children and save them to memory, because
we can't rely on readdir() not skipping files while the directory
is being modified. this doesn't protect against modifications by
other processes though. */
const char *name;
/* verify that the prefix matches, otherwise we could have
problems with mailbox names containing '%' and '*' chars */
}
}
if (mailbox_list_iter_deinit(&iter) < 0) {
ret = -1;
} else {
}
for (i = 0; i < count; i++) {
/* When doing RENAME "a" "a.b" we see "a.b" here.
We don't want to rename it anymore to "a.b.b". */
continue;
}
&oldpath) <= 0 ||
&newpath) <= 0)
i_unreached();
/* FIXME: it's possible to merge two mailboxes if either one of
them doesn't have existing root mailbox. We could check this
but I'm not sure if it's worth it. It could be even
considered as a feature.
Anyway, the bug with merging is that if both mailboxes have
identically named child mailbox they conflict. Just ignore
those and leave them under the old mailbox. */
ret = 1;
else {
ret = -1;
break;
}
}
pool_unref(&pool);
return ret;
}
static int
{
int ret;
bool found;
/* NOTE: it's possible to rename a nonexistent mailbox which has
children. In that case we should ignore the rename() error. */
MAILBOX_LIST_PATH_TYPE_MAILBOX, &oldpath) <= 0 ||
MAILBOX_LIST_PATH_TYPE_MAILBOX, &newpath) <= 0)
i_unreached();
/* most likely INBOX */
t_strdup_printf("Renaming %s isn't supported.",
oldname));
return -1;
}
/* if we're renaming under another mailbox, require its permissions
to be same as ours. */
"Renaming not supported across conflicting "
"directory permissions");
return -1;
}
}
T_BEGIN {
} T_END;
if (ret < 0)
return -1;
return -1;
}
return 0;
}
if (EDESTDIREXISTS(errno)) {
"Target mailbox already exists");
} else {
}
return -1;
}
.v = {
}
};
.v = {
}
};