return 1;
}
- /* RFC 5464:
-
- When the ACL extension [RFC4314] is present, users can only set and
- retrieve private or shared mailbox annotations on a mailbox on which
- they have the "l" right and any one of the "r", "s", "w", "i", or "p"
- rights.
- */
ret = acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_LOOKUP);
if (ret <= 0) {
if (ret < 0)
return -1;
}
- if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_READ) > 0)
- return 0;
- if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_SEEN) > 0)
- return 0;
- if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE) > 0)
- return 0;
- if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_INSERT) > 0)
- return 0;
- if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_POST) > 0)
- return 0;
- return -1;
+ return acl_mailbox_have_extra_attribute_rights(box) ? 0 : -1;
}
int acl_attribute_set(struct mailbox_transaction_context *t,
return 0;
}
+bool acl_mailbox_have_extra_attribute_rights(struct mailbox *box)
+{
+ /* RFC 5464:
+
+ When the ACL extension [RFC4314] is present, users can only set and
+ retrieve private or shared mailbox annotations on a mailbox on which
+ they have the "l" right and any one of the "r", "s", "w", "i", or "p"
+ rights.
+ */
+ if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_READ) > 0)
+ return TRUE;
+ if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_SEEN) > 0)
+ return TRUE;
+ if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE) > 0)
+ return TRUE;
+ if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_INSERT) > 0)
+ return TRUE;
+ if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_POST) > 0)
+ return TRUE;
+ return FALSE;
+}
+
static int acl_mailbox_open_check_acl(struct mailbox *box)
{
struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
sets storage error. */
int acl_mailbox_right_lookup(struct mailbox *box, unsigned int right_idx);
+/* Returns TRUE if mailbox has the necessary extra ACL for accessing
+ attributes. The caller must have checked the LOOKUP right already. */
+bool acl_mailbox_have_extra_attribute_rights(struct mailbox *box);
+
int acl_mailbox_update_acl(struct mailbox_transaction_context *t,
const struct acl_rights_update *update);