Mercurial > dovecot > core-2.2
changeset 9645:ab31f0f00912 HEAD
shared mailboxes: If only %%n is specified in prefix, default to current user's domain.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 20 Jul 2009 14:35:43 -0400 |
parents | 16849c0931be |
children | d1c159e447a2 |
files | src/lib-storage/index/shared/shared-storage.c |
diffstat | 1 files changed, 16 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/shared/shared-storage.c Fri Jul 17 20:11:05 2009 -0400 +++ b/src/lib-storage/index/shared/shared-storage.c Mon Jul 20 14:35:43 2009 -0400 @@ -175,17 +175,8 @@ } /* successfully matched the name. */ - if (userdomain == NULL) { - if (username == NULL) { - /* trying to open namespace "shared/domain" - namespace prefix. */ - mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND, - T_MAIL_ERR_MAILBOX_NOT_FOUND(*_name)); - return -1; - } - userdomain = domain == NULL ? username : - t_strconcat(username, "@", domain, NULL); - } else { + if (userdomain != NULL) { + /* user@domain given */ domain = strchr(userdomain, '@'); if (domain == NULL) username = userdomain; @@ -193,6 +184,20 @@ username = t_strdup_until(userdomain, domain); domain++; } + } else if (username == NULL) { + /* trying to open namespace "shared/domain" + namespace prefix. */ + mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND, + T_MAIL_ERR_MAILBOX_NOT_FOUND(*_name)); + return -1; + } else { + if (domain == NULL) { + /* no domain given, use ours (if we have one) */ + domain = strchr(user->username, '@'); + if (domain != NULL) domain++; + } + userdomain = domain == NULL ? username : + t_strconcat(username, "@", domain, NULL); } if (*userdomain == '\0') { mailbox_list_set_error(list, MAIL_ERROR_PARAMS,