dovecot: Make sure there is exactly one inbox=yes namespace.
dovecot at dovecot.org
dovecot at dovecot.org
Tue Jun 26 15:44:28 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/0d409ce8daae
changeset: 5798:0d409ce8daae
user: Timo Sirainen <tss at iki.fi>
date: Mon Jun 25 18:26:36 2007 +0300
description:
Make sure there is exactly one inbox=yes namespace.
diffstat:
1 file changed, 37 insertions(+)
src/lib-storage/mail-namespace.c | 37 +++++++++++++++++++++++++++++++++++++
diffs (54 lines):
diff -r de3a087ea8d2 -r 0d409ce8daae src/lib-storage/mail-namespace.c
--- a/src/lib-storage/mail-namespace.c Mon Jun 25 18:19:28 2007 +0300
+++ b/src/lib-storage/mail-namespace.c Mon Jun 25 18:26:36 2007 +0300
@@ -79,6 +79,41 @@ namespace_add_env(pool_t pool, const cha
return ns;
}
+static bool namespaces_check(struct mail_namespace *namespaces)
+{
+ struct mail_namespace *ns, *inbox_ns = NULL, *private_ns = NULL;
+ unsigned int private_ns_count = 0;
+
+ for (ns = namespaces; ns != NULL; ns = ns->next) {
+ if (ns->inbox) {
+ if (inbox_ns != NULL) {
+ i_error("namespace configuration error: "
+ "There can be only one namespace with "
+ "inbox=yes");
+ return FALSE;
+ }
+ inbox_ns = ns;
+ }
+ if (ns->type == NAMESPACE_PRIVATE) {
+ private_ns = ns;
+ private_ns_count++;
+ }
+ }
+
+ if (inbox_ns == NULL) {
+ if (private_ns_count == 1) {
+ /* just one private namespace. we'll assume it's
+ the INBOX namespace. */
+ private_ns->inbox = TRUE;
+ } else {
+ i_error("namespace configuration error: "
+ "inbox=yes namespace missing");
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
int mail_namespaces_init(pool_t pool, const char *user,
struct mail_namespace **namespaces_r)
{
@@ -112,6 +147,8 @@ int mail_namespaces_init(pool_t pool, co
}
if (namespaces != NULL) {
+ if (!namespaces_check(namespaces))
+ return -1;
*namespaces_r = namespaces;
return 0;
}
More information about the dovecot-cvs
mailing list