From: Timo Sirainen Date: Fri, 11 Jun 2010 15:14:47 +0000 (+0100) Subject: lib-storage: Fixed crashing on accessing shared mailboxes. X-Git-Tag: 2.0.beta6~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d29e35631075b8c172ce781b85fd1cdaf0a400fd;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fixed crashing on accessing shared mailboxes. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/shared/shared-storage.c b/src/lib-storage/index/shared/shared-storage.c index 4b5e70e0fc..afeae7aa88 100644 --- a/src/lib-storage/index/shared/shared-storage.c +++ b/src/lib-storage/index/shared/shared-storage.c @@ -43,6 +43,8 @@ shared_storage_create(struct mail_storage *_storage, struct mail_namespace *ns, } driver = t_strdup_until(ns->set->location, p); storage->location = p_strdup(_storage->pool, ns->set->location); + storage->unexpanded_location = + p_strdup(_storage->pool, ns->unexpanded_set->location); storage->storage_class = mail_storage_find_class(driver); if (storage->storage_class == NULL) { *error_r = t_strconcat("Unknown shared storage driver: ", @@ -123,7 +125,7 @@ int shared_storage_get_namespace(struct mail_namespace **_ns, }; struct var_expand_table *tab; struct mail_namespace *new_ns, *ns = *_ns; - struct mail_namespace_settings *ns_set; + struct mail_namespace_settings *ns_set, *unexpanded_ns_set; struct mail_user *owner; const char *domain = NULL, *username = NULL, *userdomain = NULL; const char *name, *p, *next, **dest, *error; @@ -276,6 +278,13 @@ int shared_storage_get_namespace(struct mail_namespace **_ns, ns_set->list = "yes"; new_ns->set = ns_set; + unexpanded_ns_set = + p_new(user->pool, struct mail_namespace_settings, 1); + *unexpanded_ns_set = *ns_set; + unexpanded_ns_set->location = + p_strdup(user->pool, storage->unexpanded_location); + new_ns->unexpanded_set = unexpanded_ns_set; + if (mail_storage_create(new_ns, NULL, _storage->flags, &error) < 0) { mailbox_list_set_critical(list, "Namespace '%s': %s", new_ns->prefix, error); diff --git a/src/lib-storage/index/shared/shared-storage.h b/src/lib-storage/index/shared/shared-storage.h index a6f7e04109..b2b5cc8750 100644 --- a/src/lib-storage/index/shared/shared-storage.h +++ b/src/lib-storage/index/shared/shared-storage.h @@ -8,7 +8,7 @@ struct shared_storage { union mailbox_list_module_context list_module_ctx; const char *ns_prefix_pattern; - const char *location; + const char *location, *unexpanded_location; struct mail_storage *storage_class; };