Mercurial > dovecot > core-2.2
changeset 18517:986cbdfb887d
lib-storage: Fixed setting/getting server metadata.
Also added a MAILBOX_ATTRIBUTE_KEY_IS_USER_ACCESSIBLE() macro to make it a
bit easier to check if a key should be accessible to a user or not.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 04 May 2015 23:27:42 +0300 |
parents | 5f43c88e2c87 |
children | 5d67814a596d |
files | src/lib-storage/index/index-attribute.c src/lib-storage/mailbox-attribute.h |
diffstat | 2 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-attribute.c Mon May 04 19:53:53 2015 +0300 +++ b/src/lib-storage/index/index-attribute.c Mon May 04 23:27:42 2015 +0300 @@ -186,8 +186,7 @@ time_t ts = value->last_change != 0 ? value->last_change : ioloop_time; int ret = 0; - if (strncmp(key, MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT, - strlen(MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT)) == 0) { + if (!MAILBOX_ATTRIBUTE_KEY_IS_USER_ACCESSIBLE(key)) { mail_storage_set_error(t->box->storage, MAIL_ERROR_PARAMS, "Internal attributes cannot be changed directly"); return -1; @@ -227,8 +226,7 @@ memset(value_r, 0, sizeof(*value_r)); - if (strncmp(key, MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT, - strlen(MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT)) == 0) + if (!MAILBOX_ATTRIBUTE_KEY_IS_USER_ACCESSIBLE(key)) return 0; if (index_storage_get_dict(t->box, type, &dict, &mailbox_prefix) < 0)
--- a/src/lib-storage/mailbox-attribute.h Mon May 04 19:53:53 2015 +0300 +++ b/src/lib-storage/mailbox-attribute.h Mon May 04 23:27:42 2015 +0300 @@ -11,11 +11,22 @@ users cannot access these in any way. */ #define MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT \ MAILBOX_ATTRIBUTE_PREFIX_DOVECOT"pvt/" -/* Prefix used for server attributes in INBOX. INBOX deletion won't delete - any attributes under this prefix. */ +/* Server attributes are currently stored in INBOX under this private prefix. + They're under the pvt/ prefix so they won't be listed as regular INBOX + attributes, but unlike other pvt/ attributes it's actually possible to + access these attributes as regular users. + + If INBOX is deleted, attributes under this prefix are preserved. */ #define MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT_SERVER \ MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT"server/" +/* User can get/set all non-pvt/ attributes and also pvt/server/ attributes. */ +#define MAILBOX_ATTRIBUTE_KEY_IS_USER_ACCESSIBLE(key) \ + (strncmp(key, MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT, \ + strlen(MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT)) != 0 || \ + strncmp(key, MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT_SERVER, \ + strlen(MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT_SERVER)) == 0) + enum mail_attribute_type { MAIL_ATTRIBUTE_TYPE_PRIVATE, MAIL_ATTRIBUTE_TYPE_SHARED