shared-storage.c revision 42f68772cf11237cdc7f814058222b83cedf4434
/* Copyright (c) 2008-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "ioloop.h"
#include "var-expand.h"
#include "index-storage.h"
#include "shared-storage.h"
#include <stdlib.h>
#include <ctype.h>
#define SHARED_LIST_CONTEXT(obj) \
extern struct mail_storage shared_storage;
extern struct mailbox shared_mailbox;
static struct mail_storage *shared_alloc(void)
{
struct shared_storage *storage;
}
const char **error_r)
{
struct mailbox_list_settings list_set;
const char *driver, *p;
char *wildcardp;
bool have_username;
/* data must begin with the actual mailbox driver */
if (p == NULL) {
*error_r = "Shared mailbox location not prefixed with driver";
return -1;
}
return -1;
}
*error_r = "Shared namespace prefix doesn't contain %";
return -1;
}
if (*p != '%')
continue;
if (*++p == '\0')
break;
if (*p == 'u' || *p == 'n')
else if (*p != '%' && *p != 'd')
break;
}
if (*p != '\0') {
*error_r = "Shared namespace prefix contains unknown variables";
return -1;
}
if (!have_username) {
*error_r = "Shared namespace prefix doesn't contain %u or %n";
return -1;
}
/* truncate prefix after the above checks are done, so they can log
the full prefix in error conditions */
*wildcardp = '\0';
return -1;
return 0;
}
static void
{
/* user wasn't found. we'll still need to create the storage
to avoid exposing which users exist and which don't. */
/* use a reachable but non-existing path as the mail root directory */
}
const char **_name,
struct mail_namespace **ns_r)
{
static struct var_expand_table static_tab[] = {
};
struct var_expand_table *tab;
struct mail_namespace *ns;
struct mail_namespace_settings *ns_set;
int ret;
p = storage->ns_prefix_pattern;
if (*p != '%') {
if (*p != *name)
break;
p++; name++;
continue;
}
switch (*++p) {
case 'd':
break;
case 'n':
break;
case 'u':
dest = &userdomain;
break;
default:
/* we checked this already above */
i_unreached();
}
p++;
name = "";
break;
}
}
if (*p != '\0') {
if (*name == '\0' ||
/* trying to open <prefix>/<user> mailbox */
name = "INBOX";
} else {
"Invalid namespace prefix %s vs %s",
return -1;
}
}
/* successfully matched the name. */
if (userdomain == NULL) {
namespace prefix. */
return -1;
}
} else {
else {
domain++;
}
}
if (*userdomain == '\0') {
"Empty username doesn't exist");
return -1;
}
/* expand the namespace prefix and see if it already exists.
this should normally happen only when the mailbox is being opened */
return 0;
}
ret = 1;
else {
/* we'll need to look up the user's home directory */
"Could not lookup home for user %s",
return -1;
}
}
"Couldn't create namespace '%s' for user %s: %s",
return -1;
}
/* create the new namespace */
if (ret > 0)
else {
}
return -1;
}
return 0;
}
struct mail_namespace *backend_ns)
{
const char *str;
enum mail_error error;
}
{
struct mail_namespace *ns;
int ret;
return -1;
if (ret < 0)
return ret;
}
struct mail_storage shared_storage = {
{
NULL,
NULL,
NULL,
NULL,
NULL,
}
};