Projects
Kolab:3.4
cyrus-imapd
0006-Add-ACL-change-notifications.patch
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0006-Add-ACL-change-notifications.patch of Package cyrus-imapd (Revision 67)
Currently displaying revision
67
,
Show latest
From 62103a35b782aad0d94efe21657b82eeab7d27df Mon Sep 17 00:00:00 2001 From: "Jeroen van Meeuwen (Kolab Systems)" <vanmeeuwen@kolabsys.com> Date: Sat, 8 Mar 2014 23:52:02 +0100 Subject: [PATCH 6/6] Add ACL change notifications --- imap/mboxevent.c | 34 ++++++++++++++++++++++++++++++---- imap/mboxevent.h | 12 +++++++++++- imap/mboxlist.c | 9 +++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/imap/mboxevent.c b/imap/mboxevent.c index 0f0d298..9a60b0a 100644 --- a/imap/mboxevent.c +++ b/imap/mboxevent.c @@ -78,7 +78,7 @@ EVENT_MESSAGE_TRASH) #define MAILBOX_EVENTS (EVENT_MAILBOX_CREATE|EVENT_MAILBOX_DELETE|\ - EVENT_MAILBOX_RENAME) + EVENT_MAILBOX_RENAME|EVENT_ACL_CHANGE) #define SUBS_EVENTS (EVENT_MAILBOX_SUBSCRIBE|EVENT_MAILBOX_UNSUBSCRIBE) @@ -122,6 +122,8 @@ static struct mboxevent event_template = { EVENT_DISK_QUOTA, "diskQuota", EVENT_PARAM_INT, 0, 0 }, { EVENT_DISK_USED, "diskUsed", EVENT_PARAM_INT, 0, 0 }, { EVENT_MAX_MESSAGES, "maxMessages", EVENT_PARAM_INT, 0, 0 }, + { EVENT_ACL_SUBJECT, "aclSubject", EVENT_PARAM_STRING, 0, 0 }, + { EVENT_ACL_RIGHTS, "aclRights", EVENT_PARAM_STRING, 0, 0 }, { EVENT_MESSAGES, "messages", EVENT_PARAM_INT, 0, 0 }, { EVENT_UNSEEN_MESSAGES, "vnd.cmu.unseenMessages", EVENT_PARAM_INT, 0, 0 }, { EVENT_CONVEXISTS, "vnd.fastmail.convExists", EVENT_PARAM_INT, 0, 0 }, @@ -191,7 +193,7 @@ EXPORTED void mboxevent_init(void) enabled_events |= FLAGS_EVENTS; if (groups & IMAP_ENUM_EVENT_GROUPS_ACCESS) - enabled_events |= (EVENT_LOGIN|EVENT_LOGOUT); + enabled_events |= (EVENT_LOGIN|EVENT_LOGOUT|EVENT_ACL_CHANGE); if (groups & IMAP_ENUM_EVENT_GROUPS_SUBSCRIPTION) enabled_events |= SUBS_EVENTS; @@ -423,6 +425,10 @@ static int mboxevent_expected_param(enum event_type type, enum event_param param return extra_params & IMAP_ENUM_EVENT_EXTRA_PARAMS_SERVICE; case EVENT_TIMESTAMP: return extra_params & IMAP_ENUM_EVENT_EXTRA_PARAMS_TIMESTAMP; + case EVENT_ACL_SUBJECT: + return type & EVENT_ACL_CHANGE; + case EVENT_ACL_RIGHTS: + return type & EVENT_ACL_CHANGE; case EVENT_UIDNEXT: if (!(extra_params & IMAP_ENUM_EVENT_EXTRA_PARAMS_UIDNEXT)) return 0; @@ -679,12 +685,24 @@ EXPORTED void mboxevent_set_access(struct mboxevent *event, if (userid && mboxevent_expected_param(event->type, EVENT_USER)) { /* translate any separators in user */ char *user = xstrdup(userid); - mboxname_hiersep_toexternal(&namespace, user, - config_virtdomains ? strcspn(user, "@") : 0); + if (user) { + mboxname_hiersep_toexternal(&namespace, user, + config_virtdomains ? strcspn(user, "@") : 0); + } FILL_STRING_PARAM(event, EVENT_USER, user); } } +EXPORTED void mboxevent_set_acl(struct mboxevent *event, const char *identifier, + const char *rights) +{ + if (!event) + return; + + FILL_STRING_PARAM(event, EVENT_ACL_SUBJECT, xstrdup(identifier)); + FILL_STRING_PARAM(event, EVENT_ACL_RIGHTS, xstrdup(rights)); +} + EXPORTED void mboxevent_extract_record(struct mboxevent *event, struct mailbox *mailbox, struct index_record *record) { @@ -1132,6 +1150,8 @@ static const char *event_to_name(enum event_type type) return "MailboxSubscribe"; case EVENT_MAILBOX_UNSUBSCRIBE: return "MailboxUnSubscribe"; + case EVENT_ACL_CHANGE: + return "AclChange"; default: fatal("Unknown message event", EC_SOFTWARE); } @@ -1335,6 +1355,12 @@ EXPORTED void mboxevent_set_access(struct mboxevent *event __attribute__((unused { } +EXPORTED void mboxevent_set_acl(struct mboxevent *event __attribute__((unused)), + const char *identifier __attribute__((unused)), +>.......>.......>.......>.......const char *rights __attribute__((unused))) +{ +} + EXPORTED void mboxevent_extract_record(struct mboxevent *event __attribute__((unused)), struct mailbox *mailbox __attribute__((unused)), struct index_record *record __attribute__((unused))) diff --git a/imap/mboxevent.h b/imap/mboxevent.h index 4e111c7..6106505 100644 --- a/imap/mboxevent.h +++ b/imap/mboxevent.h @@ -80,7 +80,8 @@ enum event_type { EVENT_MAILBOX_RENAME = (1<<17), EVENT_MAILBOX_SUBSCRIBE = (1<<18), EVENT_MAILBOX_UNSUBSCRIBE = (1<<19), - EVENT_CALENDAR = (1<<20) + EVENT_CALENDAR = (1<<20), + EVENT_ACL_CHANGE = (1<<21) }; /* @@ -110,6 +111,8 @@ enum event_param { EVENT_MIDSET, EVENT_FLAG_NAMES, EVENT_PID, + EVENT_ACL_SUBJECT, + EVENT_ACL_RIGHTS, EVENT_USER, EVENT_MESSAGE_SIZE, #ifdef WITH_DAV @@ -221,6 +224,13 @@ void mboxevent_add_flag(struct mboxevent *event, const char *flag); void mboxevent_set_access(struct mboxevent *event, const char *serveraddr, const char *clientaddr, const char *userid, const char *mailboxname); + +/* + * Shortcut to setting event notification parameters + */ +void mboxevent_set_acl(struct mboxevent *event, const char *identifier, + const char *rights); + /* * Extract data from the given record to fill these event parameters : * - uidset from UID diff --git a/imap/mboxlist.c b/imap/mboxlist.c index 2e4b7ee..c313ba7 100644 --- a/imap/mboxlist.c +++ b/imap/mboxlist.c @@ -1854,6 +1854,15 @@ EXPORTED int mboxlist_setacl(struct namespace *namespace, const char *name, name, cyrusdb_strerror(r)); r = IMAP_IOERROR; } + + /* send a AclChange event notification */ + struct mboxevent *mboxevent = mboxevent_new(EVENT_ACL_CHANGE); + mboxevent_extract_mailbox(mboxevent, mailbox); + mboxevent_set_acl(mboxevent, identifier, rights); + + mboxevent_notify(mboxevent); + mboxevent_free(&mboxevent); + } /* 4. Change backup copy (cyrus.header) */ -- 1.8.3.1
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.