Projects
Kolab:3.4
cyrus-imapd
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 68
View file
cyrus-imapd.spec
Changed
@@ -28,14 +28,17 @@ ## Options ## -%global with_mysql 0 -%global with_pgsql 0 -%global with_dav 0 +%global with_bdb 0 +%global with_mysql 0 +%global with_pgsql 0 + +%global with_dav 0 +%global with_tcpwrap 0 Name: cyrus-imapd Summary: A high-performance mail server with IMAP, POP3, NNTP and SIEVE support Version: 2.5 -Release: 8%{?dist} +Release: 0.1.dev20140724%{?dist} License: BSD Group: System Environment/Daemons URL: http://www.cyrusimap.org @@ -63,16 +66,7 @@ ## Patches ## -Patch0001: 0001-There-is-no-actual-prerequisite-for-libtool-of-2.2.6.patch -Patch0002: 0002-A-non-void-function-should-return-something-so-retur.patch -Patch0003: 0003-Disable-user-parameter-check-to-notify-external.patch -Patch0004: 0004-Fix-display-of-deleted-shared-folders.patch -Patch0005: 0005-Apply-ifdefs-for-building-without-DAV-and-without-re.patch -Patch0006: 0006-Add-ACL-change-notifications.patch -Patch0007: 0007-Correct-location-of-ifdef-endif.patch -Patch0008: 0008-Extend-ifdefs-endifs-for-WITH_DAV.patch -Patch0009: 0009-Keep-the-same-order-between-.c-and-.h-perhaps.patch -Patch0010: 0010-do-not-apply-ptloader-ldap-root-dn-discovery.patch +Patch9999: cyrus-imapd-mupdate-work.patch BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) @@ -84,6 +78,7 @@ BuildRequires: bison BuildRequires: cyrus-sasl-devel +%if 0%{?with_bdb} %if 0%{?suse_version} BuildRequires: db-devel %else @@ -93,6 +88,7 @@ BuildRequires: db4-devel %endif %endif +%endif BuildRequires: flex BuildRequires: gcc-c++ @@ -150,11 +146,13 @@ BuildRequires: sqlite-devel %endif +%if 0%{?with_tcpwrap} %if 0%{?suse_version} BuildRequires: tcpd-devel %else BuildRequires: tcp_wrappers %endif +%endif BuildRequires: transfig BuildRequires: xapian-core-devel @@ -251,16 +249,8 @@ %prep %setup -q -n %{_name}-%{real_version}%{?dot_snapshot_version} -#%patch0001 -p1 -#%patch0002 -p1 -#%patch0003 -p1 -#%patch0004 -p1 -#%patch0005 -p1 -#%patch0006 -p1 -#%patch0007 -p1 -#%patch0008 -p1 -#%patch0009 -p1 -#%patch0010 -p1 + +#%patch9999 -p1 # only to update config.* files aclocal -I cmulocal @@ -308,13 +298,20 @@ --enable-nntp \ --enable-replication \ --enable-xapian \ +%if 0%{?with_bdb} %if 0%{?fedora} >= 20 || 0%{?rhel} || 0%{?suse_version} --with-bdb-incdir=%{_includedir}/db4 \ %else --with-bdb-incdir=%{_includedir}/libdb4 \ %endif +%else + --without-bdb \ +%endif --with-cyrus-prefix=%{_cyrexecdir} \ --with-extraident="Kolab-%{version}-%{release}" \ +%if 0%{?with_tcpwrap} < 1 + --without-wrap \ +%endif %if 0%{?with_dav} --with-http \ %endif @@ -333,7 +330,7 @@ --with-snmp \ --with-syslogfacility=MAIL -%{__make} +%{__make} %{?_smp_mflags} %install %{__rm} -rf %{buildroot} @@ -482,7 +479,13 @@ source %{_sysconfdir}/sysconfig/cyrus-imapd fi -if [ $CHATTRSYNC -ne 0 ]; then +if [ $CHATTRSYNC -eq 0 ]; then + # Force synchronous updates of files in the following directories + chattr -R -S \ + $(grep ^configdirectory: /etc/imapd.conf | cut -d':' -f2) \ + $(grep ^partition- /etc/imapd.conf | cut -d':' -f2) \ + $(grep ^metapartition- /etc/imapd.conf | cut -d':' -f2) 2>/dev/null ||: +else # Force synchronous updates of files in the following directories chattr -R +S \ $(grep ^configdirectory: /etc/imapd.conf | cut -d':' -f2) \ @@ -685,8 +688,6 @@ %attr(0750,%{_cyrususer},%{_cyrusgroup}) %dir %{_var}/lib/imap/user %attr(0750,%{_cyrususer},%{_cyrusgroup}) %dir %{_var}/spool/imap %{_libdir}/*.so.* -%dir %{_var}/lib/imap/ -%dir %{_var}/lib/imap/rpm/ %{_var}/lib/imap/rpm/* %doc perl/imap/README %doc perl/imap/Changes
View file
0001-There-is-no-actual-prerequisite-for-libtool-of-2.2.6.patch
Deleted
@@ -1,25 +0,0 @@ -From 18c6d1d15047ce5e92b9892aeaf73e955e2b57f0 Mon Sep 17 00:00:00 2001 -From: "Jeroen van Meeuwen (Kolab Systems)" <vanmeeuwen@kolabsys.com> -Date: Sat, 8 Mar 2014 23:48:30 +0100 -Subject: [PATCH 1/6] There is no actual prerequisite for libtool of >= 2.2.6 - and it is incompatible with autoconf 2.63 - ---- - configure.ac | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 3c29680..61073e2 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -127,7 +127,6 @@ AH_BOTTOM([#if HAVE_VISIBILITY - #define HIDDEN - #endif]) - --LT_PREREQ([2.2.6]) - LT_INIT([disable-static]) - AC_SUBST([LIBTOOL_DEPS]) - --- -1.8.3.1 -
View file
0002-A-non-void-function-should-return-something-so-retur.patch
Deleted
@@ -1,24 +0,0 @@ -From 49a177f85e57c4a3c2613bf72ae492bc4b855caf Mon Sep 17 00:00:00 2001 -From: "Jeroen van Meeuwen (Kolab Systems)" <vanmeeuwen@kolabsys.com> -Date: Sat, 8 Mar 2014 23:49:04 +0100 -Subject: [PATCH 2/6] A non void function should return something, so return 0 - ---- - imap/xapian_wrap.cpp | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/imap/xapian_wrap.cpp b/imap/xapian_wrap.cpp -index 47d904f..ea96b87 100644 ---- a/imap/xapian_wrap.cpp -+++ b/imap/xapian_wrap.cpp -@@ -291,6 +291,7 @@ xapian_query_t *xapian_query_new_match(const xapian_db_t *db, const char *prefix - catch (const Xapian::Error &err) { - syslog(LOG_ERR, "IOERROR: Xapian: caught exception: %s: %s", - err.get_context().c_str(), err.get_description().c_str()); -+ return 0; - } - } - --- -1.8.3.1 -
View file
0003-Disable-user-parameter-check-to-notify-external.patch
Deleted
@@ -1,38 +0,0 @@ -From 7e8b0d9ecee648e854bc90f674f61e44f8d42c05 Mon Sep 17 00:00:00 2001 -From: "Jeroen van Meeuwen (Kolab Systems)" <vanmeeuwen@kolabsys.com> -Date: Sat, 8 Mar 2014 23:49:27 +0100 -Subject: [PATCH 3/6] Disable user parameter check to notify external - ---- - notifyd/notify_external.c | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/notifyd/notify_external.c b/notifyd/notify_external.c -index 5a2d680..964d1ee 100644 ---- a/notifyd/notify_external.c -+++ b/notifyd/notify_external.c -@@ -71,15 +71,15 @@ char* notify_external(const char *class, const char *priority, - - /* check/parse options */ - if (!(notify = config_getstring(IMAPOPT_NOTIFY_EXTERNAL))) { -- syslog(LOG_ERR, "ERROR: recipient not specified"); -- return strdup("NO external recipient not specified"); -+ syslog(LOG_ERR, "ERROR: external recipient (program) not specified"); -+ return strdup("NO external recipient (program) not specified"); - } - -- if (!*user) { -- syslog(LOG_ERR, "ERROR: recipient not specified"); -- return strdup("NO external recipient not specified"); -+/* if (!*user) { -+ syslog(LOG_ERR, "ERROR: external recipient user not specified"); -+ return strdup("NO external recipient user not specified"); - } -- -+*/ - buf[0] = notify; - buf[1] = "-c"; - buf[2] = class; --- -1.8.3.1 -
View file
0004-Fix-display-of-deleted-shared-folders.patch
Deleted
@@ -1,32 +0,0 @@ -From f931a6f37054f6f9f7638d71147c1b7367242557 Mon Sep 17 00:00:00 2001 -From: "Jeroen van Meeuwen (Kolab Systems)" <vanmeeuwen@kolabsys.com> -Date: Sat, 8 Mar 2014 23:49:50 +0100 -Subject: [PATCH 4/6] Fix display of deleted shared folders - ---- - imap/mboxname.c | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/imap/mboxname.c b/imap/mboxname.c -index 86a755f..f3634c0 100644 ---- a/imap/mboxname.c -+++ b/imap/mboxname.c -@@ -576,7 +576,15 @@ static int mboxname_toexternal(struct namespace *namespace, const char *mboxname - - if (mbparts.box) - strcat(result, "."); -+ } else { -+ /* shared mailbox */ -+ if (mbparts.is_deleted) { -+ const char *dp = config_getstring(IMAPOPT_DELETEDPREFIX); -+ sprintf(result, "%s.", dp); -+ } - } -+ -+ - if (mbparts.box) - strcat(result, mbparts.box); - --- -1.8.3.1 -
View file
0005-Apply-ifdefs-for-building-without-DAV-and-without-re.patch
Deleted
@@ -1,281 +0,0 @@ -From af772395dc3f45dbc2347fc3611606c7242059b5 Mon Sep 17 00:00:00 2001 -From: "Jeroen van Meeuwen (Kolab Systems)" <vanmeeuwen@kolabsys.com> -Date: Sat, 8 Mar 2014 23:50:55 +0100 -Subject: [PATCH 5/6] Apply ifdefs for building without DAV and without - requiring DAV-related software during build - ---- - Makefile.am | 19 ++++++++++++++----- - imap/mailbox.c | 10 ++++++++++ - imap/mailbox.h | 2 ++ - imap/mboxevent.c | 13 ++++++++++++- - imap/mboxevent.h | 2 ++ - imap/sync_server.c | 6 ++++++ - 6 files changed, 46 insertions(+), 6 deletions(-) - -diff --git a/Makefile.am b/Makefile.am -index b1790a5..48d0e8e 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -1190,7 +1190,6 @@ dist_man_MANS = \ - man/deliver.8 \ - man/fetchnews.8 \ - man/fud.8 \ -- man/httpd.8 \ - man/idled.8 \ - man/imapd.8 \ - man/ipurge.8 \ -@@ -1206,17 +1205,27 @@ dist_man_MANS = \ - man/rmnews.8 \ - man/smmapd.8 \ - man/syncnews.8 \ -- man/sync_client.8 \ -- man/sync_reset.8 \ -- man/sync_server.8 \ - man/timsieved.8 \ - man/tls_prune.8 \ - man/unexpunge.8 --if USE_SQUAT -+ -+if SQUATTER - dist_man_MANS += \ - man/squatter.8 - endif - -+if HTTPD -+dist_man_MANS += \ -+ man/httpd.8 -+endif -+ -+if REPLICATION -+dist_man_MANS += \ -+ man/sync_client.8 \ -+ man/sync_reset.8 \ -+ man/sync_server.8 -+endif -+ - master_master_SOURCES = \ - master/cyrusMasterMIB.c \ - master/cyrusMasterMIB.h \ -diff --git a/imap/mailbox.c b/imap/mailbox.c -index 43d8f79..cc457df 100644 ---- a/imap/mailbox.c -+++ b/imap/mailbox.c -@@ -51,7 +51,9 @@ - #elif defined(HAVE_STDINT_H) - # include <stdint.h> - #endif -+#ifdef WITH_DAV - #include <libical/vcc.h> -+#endif - #include <stdio.h> - #include <stdlib.h> - #include <string.h> -@@ -81,8 +83,10 @@ - - #include "annotate.h" - #include "assert.h" -+#ifdef WITH_DAV - #include "caldav_db.h" - #include "carddav_db.h" -+#endif - #include "crc32.h" - #include "md5.h" - #include "exitcodes.h" -@@ -2660,6 +2664,7 @@ out: - return r; - } - -+#ifdef WITH_DAV - static int mailbox_update_carddav(struct mailbox *mailbox, - struct index_record *old, - struct index_record *new) -@@ -2880,6 +2885,7 @@ static int mailbox_update_dav(struct mailbox *mailbox, - return mailbox_update_caldav(mailbox, old, new); - return 0; - } -+#endif //WITH_DAV - - EXPORTED int mailbox_update_conversations(struct mailbox *mailbox, - struct index_record *old, -@@ -3106,8 +3112,10 @@ static int mailbox_update_indexes(struct mailbox *mailbox, - { - int r = 0; - -+#ifdef WITH_DAV - r = mailbox_update_dav(mailbox, old, new); - if (r) return r; -+#endif - - r = mailbox_update_conversations(mailbox, old, new); - if (r) return r; -@@ -4231,6 +4239,7 @@ static int chkchildren(char *name, - return r; - } - -+#ifdef WITH_DAV - EXPORTED int mailbox_add_dav(struct mailbox *mailbox) - { - struct index_record record; -@@ -4250,6 +4259,7 @@ EXPORTED int mailbox_add_dav(struct mailbox *mailbox) - - return 0; - } -+#endif - - EXPORTED int mailbox_add_conversations(struct mailbox *mailbox) - { -diff --git a/imap/mailbox.h b/imap/mailbox.h -index cdcf878..f6174c6 100644 ---- a/imap/mailbox.h -+++ b/imap/mailbox.h -@@ -577,7 +577,9 @@ extern int mailbox_get_annotate_state(struct mailbox *mailbox, - uint32_t mailbox_sync_crc(struct mailbox *mailbox, unsigned vers, int recalc); - unsigned mailbox_best_crcvers(unsigned minvers, unsigned maxvers); - -+#ifdef WITH_DAV - extern int mailbox_add_dav(struct mailbox *mailbox); -+#endif - - /* Rename a CID. Note - this is just one mailbox! */ - extern int mailbox_cid_rename(struct mailbox *mailbox, -diff --git a/imap/mboxevent.c b/imap/mboxevent.c -index 97882a5..0f0d298 100644 ---- a/imap/mboxevent.c -+++ b/imap/mboxevent.c -@@ -53,8 +53,10 @@ - - #include "annotate.h" - #include "assert.h" -+#ifdef WITH_DAV - #include "caldav_db.h" - #include "carddav_db.h" -+#endif - #include "exitcodes.h" - #include "imapurl.h" - #include "libconfig.h" -@@ -131,9 +133,11 @@ static struct mboxevent event_template = - { EVENT_PID, "pid", EVENT_PARAM_INT, 0, 0 }, - { EVENT_USER, "user", EVENT_PARAM_STRING, 0, 0 }, - { EVENT_MESSAGE_SIZE, "messageSize", EVENT_PARAM_INT, 0, 0 }, -+#ifdef WITH_DAV - { EVENT_MBTYPE, "vnd.cmu.mbtype", EVENT_PARAM_STRING, 0, 0 }, - { EVENT_DAV_FILENAME, "vnd.cmu.davFilename", EVENT_PARAM_STRING, 0, 0 }, - { EVENT_DAV_UID, "vnd.cmu.davUid", EVENT_PARAM_STRING, 0, 0 }, -+#endif - { EVENT_MESSAGE_CID, "vnd.fastmail.cid", EVENT_PARAM_STRING, 0, 0 }, - /* always at end to let the parser to easily truncate this part */ - { EVENT_ENVELOPE, "vnd.cmu.envelope", EVENT_PARAM_STRING, 0, 0 }, -@@ -378,8 +382,10 @@ static int mboxevent_expected_param(enum event_type type, enum event_param param - return extra_params & IMAP_ENUM_EVENT_EXTRA_PARAMS_VND_FASTMAIL_SESSIONID; - case EVENT_MAILBOX_ID: - return (type & MAILBOX_EVENTS); -+#ifdef WITH_DAV - case EVENT_MBTYPE: - return (type & MAILBOX_EVENTS); -+#endif - case EVENT_MAX_MESSAGES: - return type & QUOTA_EVENTS; - case EVENT_MESSAGE_CONTENT: -@@ -388,12 +394,14 @@ static int mboxevent_expected_param(enum event_type type, enum event_param param - case EVENT_MESSAGE_SIZE: - return (extra_params & IMAP_ENUM_EVENT_EXTRA_PARAMS_MESSAGESIZE) && - (type & (EVENT_MESSAGE_APPEND|EVENT_MESSAGE_NEW)); -+#ifdef WITH_DAV - case EVENT_DAV_FILENAME: - return (extra_params & IMAP_ENUM_EVENT_EXTRA_PARAMS_VND_CMU_DAVFILENAME) && - (type & EVENT_CALENDAR); - case EVENT_DAV_UID: - return (extra_params & IMAP_ENUM_EVENT_EXTRA_PARAMS_VND_CMU_DAVUID) && - (type & EVENT_CALENDAR); -+#endif - case EVENT_MESSAGE_CID: - return (extra_params & IMAP_ENUM_EVENT_EXTRA_PARAMS_VND_FASTMAIL_CID) && - (type & (EVENT_MESSAGE_APPEND|EVENT_MESSAGE_NEW)); -@@ -743,6 +751,7 @@ EXPORTED void mboxevent_extract_record(struct mboxevent *event, struct mailbox * - cacheitem_size(record, CACHE_BODYSTRUCTURE))); - } - -+#ifdef WITH_DAV - /* add caldav items */ - if ((mailbox->mbtype & (MBTYPES_DAV)) && - (mboxevent_expected_param(event->type, EVENT_DAV_FILENAME) || -@@ -783,7 +792,7 @@ EXPORTED void mboxevent_extract_record(struct mboxevent *event, struct mailbox * - } - } - } -- -+#endif //WITH_DAV - void mboxevent_extract_copied_record(struct mboxevent *event, - const struct mailbox *mailbox, uint32_t uid) - { -@@ -993,8 +1002,10 @@ EXPORTED void mboxevent_extract_mailbox(struct mboxevent *event, - imapurl_toURL(url, &imapurl); - FILL_STRING_PARAM(event, EVENT_URI, xstrdup(url)); - -+#ifdef WITH_DAV - FILL_STRING_PARAM(event, EVENT_MBTYPE, - xstrdup(mboxlist_mbtype_to_string(mailbox->mbtype))); -+#endif - - /* mailbox related events also require mailboxID */ - if (event->type & MAILBOX_EVENTS) { -diff --git a/imap/mboxevent.h b/imap/mboxevent.h -index f0977ef..4e111c7 100644 ---- a/imap/mboxevent.h -+++ b/imap/mboxevent.h -@@ -112,9 +112,11 @@ enum event_param { - EVENT_PID, - EVENT_USER, - EVENT_MESSAGE_SIZE, -+#ifdef WITH_DAV - EVENT_MBTYPE, - EVENT_DAV_FILENAME, - EVENT_DAV_UID, -+#endif - EVENT_MESSAGE_CID, - EVENT_ENVELOPE, - EVENT_BODYSTRUCTURE, -diff --git a/imap/sync_server.c b/imap/sync_server.c -index 745b3cf..e51983d 100644 ---- a/imap/sync_server.c -+++ b/imap/sync_server.c -@@ -74,9 +74,11 @@ - #include "annotate.h" - #include "append.h" - #include "auth.h" -+#ifdef WITH_DAV - #include "caldav_db.h" - #include "carddav_db.h" - #include "dav_db.h" -+#endif - #include "dlist.h" - #include "exitcodes.h" - #include "global.h" -@@ -291,9 +293,11 @@ int service_init(int argc __attribute__((unused)), - statuscache_open(); - } - -+#ifdef WITH_DAV - dav_init(); - caldav_init(); - carddav_init(); -+#endif - - return 0; - } -@@ -455,9 +459,11 @@ void shut_down(int code) - - proc_cleanup(); - -+#ifdef WITH_DAV - carddav_done(); - caldav_done(); - dav_done(); -+#endif - - if (config_getswitch(IMAPOPT_STATUSCACHE)) { - statuscache_close(); --- -1.8.3.1 -
View file
0006-Add-ACL-change-notifications.patch
Deleted
@@ -1,162 +0,0 @@ -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 -
View file
0007-Correct-location-of-ifdef-endif.patch
Deleted
@@ -1,27 +0,0 @@ -From a5446f731ca691d8cd5eecc5ec21d81e70f5a688 Mon Sep 17 00:00:00 2001 -From: "Jeroen van Meeuwen (Kolab Systems)" <vanmeeuwen@kolabsys.com> -Date: Sat, 8 Mar 2014 23:56:42 +0100 -Subject: [PATCH 7/7] Correct location of ifdef/endif - ---- - imap/mboxevent.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/imap/mboxevent.c b/imap/mboxevent.c -index 9a60b0a..feac0fd 100644 ---- a/imap/mboxevent.c -+++ b/imap/mboxevent.c -@@ -809,8 +809,9 @@ EXPORTED void mboxevent_extract_record(struct mboxevent *event, struct mailbox * - } - } - } --} - #endif //WITH_DAV -+} -+ - void mboxevent_extract_copied_record(struct mboxevent *event, - const struct mailbox *mailbox, uint32_t uid) - { --- -1.8.3.1 -
View file
0008-Extend-ifdefs-endifs-for-WITH_DAV.patch
Deleted
@@ -1,47 +0,0 @@ -From 46eb1fa3ba446dbfdb31277fb0499785394a4d72 Mon Sep 17 00:00:00 2001 -From: "Jeroen van Meeuwen (Kolab Systems)" <vanmeeuwen@kolabsys.com> -Date: Sun, 9 Mar 2014 00:00:30 +0100 -Subject: [PATCH 8/8] Extend ifdefs/endifs for WITH_DAV - ---- - imap/mbdump.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/imap/mbdump.c b/imap/mbdump.c -index acabb95..352ed24 100644 ---- a/imap/mbdump.c -+++ b/imap/mbdump.c -@@ -630,6 +630,7 @@ EXPORTED int dump_mailbox(const char *tag, struct mailbox *mailbox, uint32_t uid - fname = mboxkey_getpath(userid); - ftag = "MBOXKEY"; - break; -+#ifdef WITH_DAV - case DAV_DB: { - struct buf dav_file = BUF_INITIALIZER; - -@@ -638,6 +639,7 @@ EXPORTED int dump_mailbox(const char *tag, struct mailbox *mailbox, uint32_t uid - ftag = "DAV"; - break; - } -+#endif // WITH_DAV - default: - fatal("unknown user data file", EC_OSFILE); - } -@@ -1072,12 +1074,14 @@ EXPORTED int undump_mailbox(const char *mbname, - char *s = user_hash_subs(userid); - strlcpy(fnamebuf, s, sizeof(fnamebuf)); - free(s); -+#ifdef WITHDAV - } else if (userid && !strcmp(file.s, "DAV")) { - /* overwriting this outright is absolutely what we want to do */ - struct buf dav_file = BUF_INITIALIZER; - dav_getpath_byuserid(&dav_file, userid); - strlcpy(fnamebuf, buf_cstring(&dav_file), sizeof(fnamebuf)); - buf_free(&dav_file); -+#endif // WITH_DAV - } else if (userid && !strcmp(file.s, "SEEN")) { - seen_file = seen_getpath(userid); - --- -1.8.3.1 -
View file
0009-Keep-the-same-order-between-.c-and-.h-perhaps.patch
Deleted
@@ -1,34 +0,0 @@ -From c70ef68f50b32bbdad04ba4d80b9f9a8bddf8817 Mon Sep 17 00:00:00 2001 -From: "Jeroen van Meeuwen (Kolab Systems)" <vanmeeuwen@kolabsys.com> -Date: Sun, 9 Mar 2014 00:26:18 +0100 -Subject: [PATCH 9/9] Keep the same order between .c and .h perhaps? - ---- - imap/mboxevent.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/imap/mboxevent.c b/imap/mboxevent.c -index feac0fd..4fdf6a5 100644 ---- a/imap/mboxevent.c -+++ b/imap/mboxevent.c -@@ -122,8 +122,6 @@ 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 }, -@@ -133,6 +131,8 @@ static struct mboxevent event_template = - { EVENT_MIDSET, "vnd.cmu.midset", EVENT_PARAM_STRING, 0, 0 }, - { EVENT_FLAG_NAMES, "flagNames", EVENT_PARAM_STRING, 0, 0 }, - { EVENT_PID, "pid", EVENT_PARAM_INT, 0, 0 }, -+ { EVENT_ACL_SUBJECT, "aclSubject", EVENT_PARAM_STRING, 0, 0 }, -+ { EVENT_ACL_RIGHTS, "aclRights", EVENT_PARAM_STRING, 0, 0 }, - { EVENT_USER, "user", EVENT_PARAM_STRING, 0, 0 }, - { EVENT_MESSAGE_SIZE, "messageSize", EVENT_PARAM_INT, 0, 0 }, - #ifdef WITH_DAV --- -1.8.3.1 -
View file
0010-do-not-apply-ptloader-ldap-root-dn-discovery.patch
Deleted
@@ -1,13 +0,0 @@ -diff --git a/ptclient/ldap.c b/ptclient/ldap.c -index b45a1a0..8e30e53 100644 ---- a/ptclient/ldap.c -+++ b/ptclient/ldap.c -@@ -946,7 +946,7 @@ static int ptsmodule_get_dn( - if (rc != PTSM_OK) - return rc; - -- if (ptsm->domain_base_dn && (strrchr(canon_id, '@') != NULL)) { -+ if (ptsm->domain_base_dn && ptsm->domain_base_dn[0] != '\0' && (strrchr(canon_id, '@') != NULL)) { - syslog(LOG_DEBUG, "Attempting to get domain for %s from %s", canon_id, ptsm->domain_base_dn); - - /* Get the base dn to search from domain_base_dn searched on domain_scope with
View file
cyrus-imapd-mupdate-work.patch
Added
@@ -0,0 +1,1319 @@ +diff --git a/imap/annotate.c b/imap/annotate.c +index 2dbac7a..a5c3a6d 100644 +--- a/imap/annotate.c ++++ b/imap/annotate.c +@@ -1183,6 +1183,7 @@ static int annotate_state_set_scope(annotate_state_t *state, + annotate_state_unset_scope(state); + + if (mbentry) { ++ assert(!uid); + if (!mailbox && !mbentry->server) { + /* local mailbox */ + r = mailbox_open_iwl(mbentry->name, &mailbox); +@@ -1190,11 +1191,21 @@ static int annotate_state_set_scope(annotate_state_t *state, + goto out; + state->mailbox_is_ours = 1; + } +- assert(mailbox); ++ ++ if (mailbox) { ++ syslog(LOG_DEBUG, "mailbox: %s (%s:%d)", mailbox->name, __FILE__, __LINE__); ++ } ++ ++ if (mbentry) { ++ syslog(LOG_DEBUG, "%s mbentry->server: %s (%s:%d)", mbentry->name, mbentry->server, __FILE__, __LINE__); ++ syslog(LOG_DEBUG, "%s mbentry->partition: %s (%s:%d)", mbentry->name, mbentry->partition, __FILE__, __LINE__); ++ } ++ ++ state->which = ANNOTATION_SCOPE_MAILBOX; + state->mbentry = mbentry; + } + +- if (uid) { ++ else if (uid) { + assert(mailbox); + state->which = ANNOTATION_SCOPE_MESSAGE; + } +@@ -1209,6 +1220,7 @@ static int annotate_state_set_scope(annotate_state_t *state, + } + assert(oldwhich == ANNOTATION_SCOPE_UNKNOWN || + oldwhich == state->which); ++ + state->mailbox = mailbox; + state->uid = uid; + +@@ -1431,6 +1443,8 @@ static void annotation_get_freespace(annotate_state_t *state, + static void annotation_get_server(annotate_state_t *state, + struct annotate_entry_list *entry) + { ++ syslog(LOG_DEBUG, "%s (%s:%d)", __func__, __FILE__, __LINE__); ++ + struct buf value = BUF_INITIALIZER; + int r; + +@@ -2024,14 +2038,20 @@ static void _annotate_fetch_entries(annotate_state_t *state, + for (ee = state->entry_list; ee; ee = ee->next) { + + if (proxy_check) { +- if (ee->desc->proxytype == BACKEND_ONLY && +- proxy_fetch_func && +- !config_getstring(IMAPOPT_PROXYSERVERS)) ++ if ( ++ ee->desc->proxytype == BACKEND_ONLY && ++ proxy_fetch_func && ++ !config_getstring(IMAPOPT_PROXYSERVERS) ++ ) { ++ syslog(LOG_DEBUG, "%s (%s:%d) backend only (skipping): %s", __func__, __FILE__, __LINE__, ee->desc->name); + continue; ++ } + } + +- if (!_annotate_may_fetch(state, ee->desc)) ++ if (!_annotate_may_fetch(state, ee->desc)) { ++ syslog(LOG_DEBUG, "%s (%s:%d) may not fetch (skipping): %s", __func__, __FILE__, __LINE__, ee->desc->name); + continue; ++ } + + ee->desc->get(state, ee); + } +@@ -2056,6 +2076,9 @@ EXPORTED int annotate_state_fetch(annotate_state_t *state, + state->sizeptr = maxsizeptr; /* pointer to push largest back */ + } + ++ syslog(LOG_DEBUG, "%s (%s:%d) entries: %s", __func__, __FILE__, __LINE__, strarray_join(entries, ",")); ++ syslog(LOG_DEBUG, "%s (%s:%d) attribs: %s", __func__, __FILE__, __LINE__, strarray_join(attribs, ",")); ++ + /* Build list of attributes to fetch */ + for (i = 0 ; i < attribs->count ; i++) + { +@@ -2091,15 +2114,20 @@ EXPORTED int annotate_state_fetch(annotate_state_t *state, + if (!state->attribs) + goto out; + ++ syslog(LOG_DEBUG, "%s (%s:%d) attribs: %s", __func__, __FILE__, __LINE__, strarray_join(attribs, ",")); ++ + if (state->which == ANNOTATION_SCOPE_SERVER) { ++ syslog(LOG_DEBUG, "%s (%s:%d) state->which == ANNOTATION_SCOPE_SERVER", __func__, __FILE__, __LINE__); + non_db_entries = &server_entries; + db_entry = &server_db_entry; + } + else if (state->which == ANNOTATION_SCOPE_MAILBOX) { ++ syslog(LOG_DEBUG, "%s (%s:%d) state->which == ANNOTATION_SCOPE_MAILBOX", __func__, __FILE__, __LINE__); + non_db_entries = &mailbox_entries; + db_entry = &mailbox_db_entry; + } + else if (state->which == ANNOTATION_SCOPE_MESSAGE) { ++ syslog(LOG_DEBUG, "%s (%s:%d) state->which == ANNOTATION_SCOPE_MESSAGE", __func__, __FILE__, __LINE__); + non_db_entries = &message_entries; + db_entry = &message_db_entry; + } +@@ -2109,6 +2137,11 @@ EXPORTED int annotate_state_fetch(annotate_state_t *state, + goto out; + } + ++ if (proxy_fetch_func) ++ syslog(LOG_DEBUG, "we have proxy_fetch_func"); ++ else ++ syslog(LOG_DEBUG, "we do not have proxy_fetch_func"); ++ + /* Build a list of callbacks for fetching the annotations */ + for (i = 0 ; i < entries->count ; i++) + { +@@ -2116,14 +2149,25 @@ EXPORTED int annotate_state_fetch(annotate_state_t *state, + int j; + int check_db = 0; /* should we check the db for this entry? */ + ++ syslog(LOG_DEBUG, "%s (%s:%d) char s: %s", __func__, __FILE__, __LINE__, s); ++ + g = glob_init(s, GLOB_HIERARCHY); + GLOB_SET_SEPARATOR(g, '/'); + + for (j = 0 ; j < non_db_entries->count ; j++) { + const annotate_entrydesc_t *desc = non_db_entries->data[j]; + +- if (!desc->get) ++ syslog(LOG_DEBUG, "%s (%s:%d) non_db_entry '%s'", __func__, __FILE__, __LINE__, desc->name); ++ ++ if (!desc->get) { ++ syslog(LOG_DEBUG, "%s (%s:%d) desc->get returns nothing for '%s'", __func__, __FILE__, __LINE__, desc->name); + continue; ++ } ++ ++ if (desc->proxytype == PROXY_ONLY) ++ syslog(LOG_DEBUG, "%s proxytype is proxy only (%s:%d)", desc->name, __FILE__, __LINE__); ++ else ++ syslog(LOG_DEBUG, "%s proxytype is NOT proxy only (%s:%d)", desc->name, __FILE__, __LINE__); + + if (GLOB_TEST(g, desc->name) != -1) { + /* Add this entry to our list only if it +@@ -2159,6 +2203,35 @@ EXPORTED int annotate_state_fetch(annotate_state_t *state, + glob_free(&g); + } + ++ struct annotate_entry_list *ee; ++ ++ for (ee = state->entry_list; ee; ee = ee->next) { ++ ++ syslog(LOG_DEBUG, "%s (%s:%d) state->entry_list: %s", __func__, __FILE__, __LINE__, ee->name); ++ ++ if ( ++ ee->desc->proxytype == BACKEND_ONLY && ++ !config_getstring(IMAPOPT_PROXYSERVERS) ++ ) { ++ ++ continue; ++ syslog(LOG_DEBUG, "%s (%s:%d) state->entry_list(backend): %s", __func__, __FILE__, __LINE__, ee->name); ++ } ++ ++ if (!_annotate_may_fetch(state, ee->desc)) { ++ syslog(LOG_DEBUG, "%s (%s:%d) may not fetch: %s", __func__, __FILE__, __LINE__, ee->name); ++ continue; ++ } ++ ++ ee->desc->get(state, ee); ++ ++ if (ee->have_shared) ++ syslog(LOG_DEBUG, "%s (%s:%d) entry shared: %s", __func__, __FILE__, __LINE__, ee->shared.s); ++ if (ee->have_priv) ++ syslog(LOG_DEBUG, "%s (%s:%d) entry private: %s", __func__, __FILE__, __LINE__, ee->priv.s); ++ } ++ ++ + if (state->which == ANNOTATION_SCOPE_SERVER) { + _annotate_fetch_entries(state, /*proxy_check*/1); + } +@@ -3313,16 +3386,22 @@ static void init_annotation_definitions(void) + ptrarray_t *entries = NULL; + + /* copy static entries into list */ +- for (i = 0 ; server_builtin_entries[i].name ; i++) ++ for (i = 0 ; server_builtin_entries[i].name ; i++) { ++ syslog(LOG_DEBUG, "appending %s to server_entries", server_builtin_entries[i].name); + ptrarray_append(&server_entries, (void *)&server_builtin_entries[i]); ++ } + + /* copy static entries into list */ +- for (i = 0 ; mailbox_builtin_entries[i].name ; i++) ++ for (i = 0 ; mailbox_builtin_entries[i].name ; i++) { ++ syslog(LOG_DEBUG, "appending %s to mailbox_entries", mailbox_builtin_entries[i].name); + ptrarray_append(&mailbox_entries, (void *)&mailbox_builtin_entries[i]); ++ } + + /* copy static entries into list */ +- for (i = 0 ; message_builtin_entries[i].name ; i++) ++ for (i = 0 ; message_builtin_entries[i].name ; i++) { ++ syslog(LOG_DEBUG, "appending %s to message_entries", message_builtin_entries[i].name); + ptrarray_append(&message_entries, (void *)&message_builtin_entries[i]); ++ } + + memset(&state, 0, sizeof(state)); + +diff --git a/imap/imap_proxy.c b/imap/imap_proxy.c +index f3154e2..88f2b93 100644 +--- a/imap/imap_proxy.c ++++ b/imap/imap_proxy.c +@@ -1345,16 +1345,19 @@ char *find_free_server(void) + be = proxy_findserver(cur_server, &imap_protocol, + proxy_userid, &backend_cached, + &backend_current, &backend_inbox, imapd_in); ++ + if (be) { + unsigned avail = 0; + int c; + + /* fetch annotation from remote */ + proxy_gentag(mytag, sizeof(mytag)); ++ + prot_printf(be->out, + "%s GETANNOTATION \"\" " + "\"/vendor/cmu/cyrus-imapd/freespace\" " + "\"value.shared\"\r\n", mytag); ++ + prot_flush(be->out); + + for (/* each annotation response */;;) { +@@ -1379,20 +1382,30 @@ char *find_free_server(void) + if (c != '\"') { c = EOF; break; } + eatline(be->in, c); /* we don't care about the rest of the line */ + } ++ + if (c != EOF) { + prot_ungetc(c, be->in); + + /* we should be looking at the tag now */ + eatline(be->in, c); + } ++ + if (c == EOF) { + /* uh oh, we're not happy */ + fatal("Lost connection to backend", EC_UNAVAILABLE); + } ++ ++ syslog(LOG_DEBUG, "Current server selected (before eval of %s): %s with %lu bytes", cur_server, server, max_avail); ++ + if (avail > max_avail) { + server = cur_server; + max_avail = avail; + } ++ ++ syslog(LOG_DEBUG, "Current server selected (after eval of %s): %s with %lu bytes", cur_server, server, max_avail); ++ ++ } else { ++ syslog(LOG_ERR, "Could not connect to %s to determine free space available", cur_server); + } + + /* move to next server */ +diff --git a/imap/imapd.c b/imap/imapd.c +index 9809981..902ad45 100644 +--- a/imap/imapd.c ++++ b/imap/imapd.c +@@ -423,7 +423,7 @@ static int parse_annotate_fetch_data(const char *tag, + strarray_t *attribs); + static int parse_metadata_string_or_list(const char *tag, + strarray_t *sa, +- int *was_singlep); ++ int *is_list); + static int parse_annotate_store_data(const char *tag, + int permessage_flag, + struct entryattlist **entryatts); +@@ -5332,7 +5332,7 @@ static void cmd_create(char *tag, char *name, struct dlist *extargs, int localon + { + int r = 0; + char mailboxname[MAX_MAILBOX_BUFFER]; +- int autocreatequotastorage; ++ //int autocreatequotastorage; + int mbtype = 0; + const char *partition = NULL; + const char *server = NULL; +@@ -5342,6 +5342,7 @@ static void cmd_create(char *tag, char *name, struct dlist *extargs, int localon + dlist_getatom(extargs, "PARTITION", &partition); + dlist_getatom(extargs, "SERVER", &server); + use = dlist_getchild(extargs, "USE"); ++ + if (use) { + struct dlist *item; + char *raw; +@@ -5350,212 +5351,331 @@ static void cmd_create(char *tag, char *name, struct dlist *extargs, int localon + * correct error. Sadly, that's a pain - so we compromise by + * "normalising" first */ + strarray_t *su = strarray_new(); ++ + for (item = use->head; item; item = item->next) { + strarray_append(su, dlist_cstring(item)); + } ++ + raw = strarray_join(su, " "); + strarray_free(su); + r = specialuse_validate(raw, &specialuse); + free(raw); ++ + if (r) { + prot_printf(imapd_out, "%s NO [USEATTR] %s\r\n", tag, error_message(r)); + goto done; + } ++ + } + +- if (partition && !imapd_userisadmin) { +- r = IMAP_PERMISSION_DENIED; ++ // A non-admin is not allowed to specify the server nor partition on which ++ // to create the mailbox. ++ if ((server || partition) && !imapd_userisadmin) { ++ prot_printf(imapd_out, "%s NO %s\r\n", tag, error_message(IMAP_PERMISSION_DENIED)); ++ goto done; + } + ++ /* We don't care about trailing hierarchy delimiters. */ + if (name[0] && name[strlen(name)-1] == imapd_namespace.hier_sep) { +- /* We don't care about trailing hierarchy delimiters. */ + name[strlen(name)-1] = '\0'; + } + +- if (!r) { +- r = (*imapd_namespace.mboxname_tointernal)(&imapd_namespace, name, +- imapd_userid, mailboxname); ++ r = (*imapd_namespace.mboxname_tointernal)(&imapd_namespace, name, imapd_userid, mailboxname); ++ ++ if (r) { ++ prot_printf(imapd_out, "%s NO %s\r\n", tag, error_message(r)); ++ goto done; + } + + /* check for INBOX.INBOX creation by broken Apple clients */ +- if (!r) { +- char *copy = xstrdup(mailboxname); +- lcase(copy); +- if (strstr(copy, "inbox.inbox")) +- r = IMAP_MAILBOX_BADNAME; +- free(copy); ++ char *copy = xstrdup(mailboxname); ++ lcase(copy); ++ ++ if (strstr(copy, "inbox.inbox")) ++ r = IMAP_MAILBOX_BADNAME; ++ ++ free(copy); ++ ++ if (r) { ++ prot_printf(imapd_out, "%s NO %s\r\n", tag, error_message(r)); ++ goto done; + } + +- if (!r && !localonly && config_mupdate_server) { +- int guessedpart = 0; ++ // If the create command does not mandate the mailbox must be created ++ // locally, let's go and find the most appropriate location. ++ if (!localonly) { + +- /* determine if we're creating locally or remotely */ +- if (!partition && !server) { +- char *foundpart = NULL; +- guessedpart = 1; +- r = mboxlist_createmailboxcheck(mailboxname, 0, 0, +- imapd_userisadmin || imapd_userisproxyadmin, +- imapd_userid, imapd_authstate, +- NULL, &foundpart, 0); +- partition = foundpart; ++ // If we're running in a Murder, things get more complicated. ++ if (config_mupdate_server) { + +- if (!r && !partition && +- (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_STANDARD) && +- !config_getstring(IMAPOPT_PROXYSERVERS)) { +- /* proxy-only server, and no parent mailbox */ +- guessedpart = 0; ++ // Consider your actions on a per type of topology basis. ++ // ++ // First up: Standard / discrete murder topology, with dedicated ++ // imap frontends. ++ if (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_STANDARD) { ++ if (!config_getstring(IMAPOPT_PROXYSERVERS)) { ++ syslog(LOG_DEBUG, "I believe I am a dedicated frontend!"); + +- /* use defaultserver if specified */ +- partition = config_getstring(IMAPOPT_DEFAULTSERVER); ++ // Find the parent mailbox, if any. ++ mbentry_t *parent = NULL; + +- /* otherwise, find server with most available space */ +- if (!partition) partition = find_free_server(); ++ // mboxlist_findparent either supplies the parent ++ // or has a return code of IMAP_MAILBOX_NONEXISTENT. ++ r = mboxlist_findparent(mailboxname, &parent); + +- if (!partition) r = IMAP_SERVER_UNAVAILABLE; +- } +- } ++ if (r) { ++ if (r != IMAP_MAILBOX_NONEXISTENT) { ++ prot_printf(imapd_out, "%s NO %s (%s:%d)\r\n", tag, error_message(r), __FILE__, __LINE__); ++ goto done; ++ } else { ++ syslog(LOG_DEBUG, "OK, no parent for mailbox %s (yet)", mailboxname); ++ } ++ } + +- if (!r && !config_partitiondir(partition)) { +- /* invalid partition, assume its a server (remote mailbox) */ +- struct backend *s = NULL; +- char *p; +- int res; +- +- /* check for a remote partition */ +- server = partition; +- p = strchr(server, '!'); +- if (p) *p++ = '\0'; +- partition = guessedpart ? NULL : p; ++ if (!server && !partition) { ++ if (!parent) { ++ server = find_free_server(); + +- s = proxy_findserver(server, &imap_protocol, +- proxy_userid, &backend_cached, +- &backend_current, &backend_inbox, imapd_in); +- if (!s) r = IMAP_SERVER_UNAVAILABLE; ++ if (server) { ++ syslog(LOG_DEBUG, "server selected based on free disk space: %s", server); + +- if (!r && imapd_userisadmin && supports_referrals) { +- /* They aren't an admin remotely, so let's refer them */ +- imapd_refer(tag, server, name); +- referral_kick = 1; +- return; +- } ++ } else { ++ prot_printf(imapd_out, "%s NO %s\r\n", tag, error_message(IMAP_SERVER_UNAVAILABLE)); ++ goto done; ++ } + +- if (!r) { +- if (!CAPA(s, CAPA_MUPDATE)) { +- /* reserve mailbox on MUPDATE */ +- } +- } ++ } else { ++ server = parent->server; ++ partition = parent->partition; ++ syslog(LOG_DEBUG, "using parent server/partition: %s, %s", server, partition); ++ ++/* ++ syslog(LOG_DEBUG, "starting mboxlist_entry_free(parent)"); ++ mboxlist_entry_free(parent); ++ syslog(LOG_DEBUG, "mboxlist_entry_free(parent) done"); ++*/ ++ } + +- if (!r) { +- /* ok, send the create to that server */ +- prot_printf(s->out, "%s CREATE ", tag); +- prot_printastring(s->out, name); +- /* special use needs extended support, so pass through extargs */ +- if (specialuse.len) { +- prot_printf(s->out, "(USE (%s)", buf_cstring(&specialuse)); +- if (partition) { +- prot_printf(s->out, " PARTITION "); +- prot_printastring(s->out, partition); + } +- prot_putc(')', s->out); +- } +- /* Send partition as an atom, since its supported by older servers */ +- else if (partition) { +- prot_putc(' ', s->out); +- prot_printastring(s->out, partition); +- } +- prot_printf(s->out, "\r\n"); + +- res = pipe_until_tag(s, tag, 0); ++ struct backend *s_conn = NULL; + +- if (!CAPA(s, CAPA_MUPDATE)) { +- /* do MUPDATE create operations */ +- } +- /* make sure we've seen the update */ +- if (ultraparanoid && res == PROXY_OK) kick_mupdate(); +- } ++ syslog(LOG_DEBUG, "connecting proxy_findserver()"); + +- imapd_check(s, 0); ++ s_conn = proxy_findserver( ++ server, ++ &imap_protocol, ++ proxy_userid, ++ &backend_cached, ++ &backend_current, ++ &backend_inbox, ++ imapd_in ++ ); + +- if (r) { +- prot_printf(imapd_out, "%s NO %s\r\n", tag, error_message(r)); +- } else { +- /* we're allowed to reference last_result since the noop, if +- sent, went to a different server */ +- prot_printf(imapd_out, "%s %s", tag, s->last_result.s); ++ if (!s_conn) { ++ prot_printf(imapd_out, "%s NO %s\r\n", tag, error_message(IMAP_SERVER_UNAVAILABLE)); ++ goto done; ++ } ++ ++ syslog(LOG_DEBUG, "proxy_findserver() done"); ++ ++ // Huh? ++ if (imapd_userisadmin && supports_referrals) { ++ syslog(LOG_DEBUG, "going to refer the admin..."); ++ // "They are not an admin remotely, so let's refer them" -- ++ // - Who is they? ++ // - How did imapd_userisadmin get set all of a sudden? ++ imapd_refer(tag, server, name); ++ referral_kick = 1; ++ syslog(LOG_DEBUG, "done referring the admin"); ++ return; ++ } ++ ++ if (!CAPA(s_conn, CAPA_MUPDATE)) { ++ // Huh? ++ // "reserve mailbox on MUPDATE" ++ syslog(LOG_WARNING, "backend %s is not advertising any MUPDATE capability (%s:%d)", server, __FILE__, __LINE__); ++ } ++ ++ // ok, send the create to that server as localcreate ++ //prot_printf(s_conn->out, "%s LOCALCREATE ", tag); ++ // originally with CREATE ++ prot_printf(s_conn->out, "%s CREATE ", tag); ++ prot_printastring(s_conn->out, name); ++ ++ // special use needs extended support, so pass through extargs ++ if (specialuse.len) { ++ prot_printf(s_conn->out, "(USE (%s)", buf_cstring(&specialuse)); ++ ++ if (partition) { ++ prot_printf(s_conn->out, " PARTITION "); ++ prot_printastring(s_conn->out, partition); ++ } ++ ++ prot_putc(')', s_conn->out); ++ } ++ ++ // Send partition as an atom, since its supported by older servers ++ else if (partition) { ++ prot_putc(' ', s_conn->out); ++ prot_printastring(s_conn->out, partition); ++ } ++ ++ prot_printf(s_conn->out, "\r\n"); ++ ++ int res = pipe_until_tag(s_conn, tag, 0); ++ ++ if (!CAPA(s_conn, CAPA_MUPDATE)) { ++ // Huh? ++ // "do MUPDATE create operations" ++ syslog(LOG_WARNING, "backend %s is not advertising any MUPDATE capability (%s:%d)", server, __FILE__, __LINE__); ++ } ++ ++ /* make sure we've seen the update */ ++ if (ultraparanoid && res == PROXY_OK) kick_mupdate(); ++ ++ imapd_check(s_conn, 0); ++ ++ syslog(LOG_DEBUG, "passing (%s:%d)", __FILE__, __LINE__); ++ ++ prot_printf(imapd_out, "%s %s\r\n", tag, s_conn->last_result.s); ++ ++ goto done; ++ ++ } else { // (!config_getstring(IMAPOPT_PROXYSERVERS)) ++ syslog(LOG_DEBUG, "I have a standard murder config but also proxy servers configured; I'm a backend!"); ++ goto localcreate; ++ ++ } // (!config_getstring(IMAPOPT_PROXYSERVERS)) ++ ++ } // (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_STANDARD) ++ ++ else if (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_UNIFIED) { ++ } // (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_UNIFIED) ++ ++ else if (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_REPLICATED) { ++ } // (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_REPLICATED) ++ ++ else { ++ syslog(LOG_ERR, "murder configuration I cannot deal with"); ++ prot_printf(imapd_out, "%s NO %s (%s:%d)\r\n", tag, error_message(IMAP_SERVER_UNAVAILABLE), __FILE__, __LINE__); ++ goto done; + } + ++ } else { // (config_mupdate_server) ++ // go localcreate ++ syslog(LOG_ERR, "Cannot create a mailbox 'not locally', while I'm not a part of a Cyrus IMAP Murder"); ++ prot_printf(imapd_out, "%s NO %s (%s:%d)\r\n", tag, error_message(IMAP_SERVER_UNAVAILABLE), __FILE__, __LINE__); + goto done; +- } +-#if 0 +- else if (!r && +- (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_STANDARD) && +- !config_getstring(IMAPOPT_PROXYSERVERS)) { +- /* can't create maiilboxes on proxy-only servers */ +- r = IMAP_PERMISSION_DENIED; +- } +-#endif ++ } // (config_mupdate_server) + +- /* local mailbox -- fall through */ +- if (guessedpart) { +- partition = NULL; +- r = 0; +- } ++ } else { // (!localonly) ++ goto localcreate; + } + +- /* local mailbox */ +- if (!r) { ++localcreate: ++ syslog(LOG_DEBUG, "creating mailbox %s locally", mailboxname); + +- /* xxx we do forced user creates on LOCALCREATE to facilitate +- * mailbox moves */ +- r = mboxlist_createmailbox(mailboxname, mbtype, partition, +- imapd_userisadmin || imapd_userisproxyadmin, +- imapd_userid, imapd_authstate, +- localonly, localonly, 0, 1, NULL); ++ r = mboxlist_createmailbox( ++ mailboxname, // const char name ++ mbtype, // int mbtype ++ partition, // const char partition ++ imapd_userisadmin || imapd_userisproxyadmin, // int isadmin ++ imapd_userid, // const char userid ++ imapd_authstate, // struct auth_state auth_state ++ localonly, // int localonly ++ localonly, // int forceuser ++ 0, // int dbonly ++ 1, // int notify ++ NULL // struct mailbox mailboxptr ++ ); ++ ++#if 0 ++ // Clausing autocreate for the INBOX ++ if (r == IMAP_PERMISSION_DENIED) { ++ if (!strcasecmp(name, "INBOX")) { ++ if ((autocreatequotastorage = config_getint(IMAPOPT_AUTOCREATEQUOTA))) { ++ r = mboxlist_createmailbox( ++ mailboxname, ++ 0, ++ partition, ++ 1, ++ imapd_userid, ++ imapd_authstate, ++ 0, ++ 0, ++ 0, ++ 1, ++ NULL ++ ); + +- if (r == IMAP_PERMISSION_DENIED && !strcasecmp(name, "INBOX") && +- (autocreatequotastorage = config_getint(IMAPOPT_AUTOCREATEQUOTA))) { ++ if (r) { ++ prot_printf(imapd_out, "%s NO %s (%s:%d)\r\n", tag, error_message(r), __FILE__, __LINE__); ++ goto done; ++ } + +- /* Auto create INBOX is always type zero */ +- r = mboxlist_createmailbox(mailboxname, /*mbtype*/0, partition, +- 1, imapd_userid, imapd_authstate, +- 0, 0, 0, 1, NULL); ++ int autocreatequotamessage = config_getint(IMAPOPT_AUTOCREATEQUOTAMSG); + +- int autocreatequotamessage = config_getint(IMAPOPT_AUTOCREATEQUOTAMSG); +- if (!r && ((autocreatequotastorage > 0) || (autocreatequotamessage > 0))) { +- int res; +- int newquotas[QUOTA_NUMRESOURCES]; ++ if ((autocreatequotastorage > 0) || (autocreatequotamessage > 0)) { ++ int newquotas[QUOTA_NUMRESOURCES]; ++ int res; + +- for (res = 0 ; res < QUOTA_NUMRESOURCES ; res++) +- newquotas[res] = QUOTA_UNLIMITED; +- newquotas[QUOTA_STORAGE] = autocreatequotastorage; +- newquotas[QUOTA_MESSAGE] = autocreatequotamessage; ++ for (res = 0; res < QUOTA_NUMRESOURCES; res++) { ++ newquotas[res] = QUOTA_UNLIMITED; ++ } + +- (void) mboxlist_setquotas(mailboxname, newquotas, 0); +- } +- } ++ newquotas[QUOTA_STORAGE] = autocreatequotastorage; ++ newquotas[QUOTA_MESSAGE] = autocreatequotamessage; + +- if (!r && specialuse.len) { +- r = annotatemore_write(mailboxname, "/specialuse", imapd_userid, &specialuse); +- if (r) { +- /* XXX - failure here SHOULD cause a cleanup of the created mailbox */ +- syslog(LOG_ERR, "IOERROR: failed to write specialuse for %s on %s (%s)", +- imapd_userid, mailboxname, buf_cstring(&specialuse)); +- } ++ (void) mboxlist_setquotas(mailboxname, newquotas, 0); ++ } // (autocreatequotastorage > 0) || (autocreatequotamessage > 0) ++ ++ } else { // (autocreatequotastorage = config_getint(IMAPOPT_AUTOCREATEQUOTA)) ++ syslog( ++ LOG_DEBUG, ++ "Attempt to create INBOX by %s but automatic creation not configured", ++ imapd_userid ++ ); ++ ++ prot_printf(imapd_out, "%s NO %s (%s:%d)\r\n", tag, error_message(IMAP_PERMISSION_DENIED), __FILE__, __LINE__); ++ goto done; ++ ++ } // (autocreatequotastorage = config_getint(IMAPOPT_AUTOCREATEQUOTA)) ++ ++ } else { // (!strcasecmp(name, "INBOX")) ++ prot_printf(imapd_out, "%s NO %s (%s:%d)\r\n", tag, error_message(IMAP_PERMISSION_DENIED), __FILE__, __LINE__); ++ goto done; ++ } // (!strcasecmp(name, "INBOX")) ++ ++ } else { // (r == IMAP_PERMISSION_DENIED) ++ prot_printf(imapd_out, "%s NO %s (%s:%d)\r\n", tag, error_message(IMAP_PERMISSION_DENIED), __FILE__, __LINE__); ++ goto done; ++ } // (r == IMAP_PERMISSION_DENIED) ++ ++ if (specialuse.len) { ++ r = annotatemore_write(mailboxname, "/specialuse", imapd_userid, &specialuse); ++ if (r) { ++ /* XXX - failure here SHOULD cause a cleanup of the created mailbox */ ++ syslog( ++ LOG_ERR, ++ "IOERROR: failed to write specialuse for %s on %s (%s) (%s:%d)", ++ imapd_userid, ++ mailboxname, ++ buf_cstring(&specialuse), ++ __FILE__, ++ __LINE__ ++ ); ++ ++ prot_printf(imapd_out, "%s NO %s (%s:%d)\r\n", tag, error_message(r), __FILE__, __LINE__); ++ goto done; + } + } + +- imapd_check(NULL, 0); ++#endif + +- if (r) { +- prot_printf(imapd_out, "%s NO %s\r\n", tag, error_message(r)); +- } +- else { +- if (config_mupdate_server) +- kick_mupdate(); ++ prot_printf(imapd_out, "%s OK Completed\r\n", tag); + +- prot_printf(imapd_out, "%s OK %s\r\n", tag, +- error_message(IMAP_OK_COMPLETED)); +- } ++ imapd_check(NULL, 0); + + done: + buf_free(&specialuse); +@@ -5588,8 +5708,9 @@ static int delmbox(char *name, + } + + if(r) { +- prot_printf(imapd_out, "* NO delete %s: %s\r\n", +- name, error_message(r)); ++ prot_printf(imapd_out, "* NO delete %s: %s (%s:%d)\r\n", ++ name, error_message(r), ++ __FILE__, __LINE__); + } + + return 0; +@@ -5647,7 +5768,7 @@ static void cmd_delete(char *tag, char *name, int localonly, int force) + imapd_check(s, 0); + + if (r) { +- prot_printf(imapd_out, "%s NO %s\r\n", tag, error_message(r)); ++ prot_printf(imapd_out, "%s NO %s (%s:%d)\r\n", tag, error_message(r), __FILE__, __LINE__); + } else { + /* we're allowed to reference last_result since the noop, if + sent, went to a different server */ +@@ -5710,7 +5831,7 @@ static void cmd_delete(char *tag, char *name, int localonly, int force) + imapd_check(NULL, 0); + + if (r) { +- prot_printf(imapd_out, "%s NO %s\r\n", tag, error_message(r)); ++ prot_printf(imapd_out, "%s NO %s (%s:%d)\r\n", tag, error_message(r), __FILE__, __LINE__); + } + else { + if (config_mupdate_server) +@@ -5787,8 +5908,9 @@ static int renmbox(char *name, + imapd_userid, newextname); + + if(r) { +- prot_printf(imapd_out, "* NO rename %s %s: %s\r\n", +- oldextname, newextname, error_message(r)); ++ prot_printf(imapd_out, "* NO rename %s %s: %s (%s:%d)\r\n", ++ oldextname, newextname, error_message(r), ++ __FILE__, __LINE__); + if (RENAME_STOP_ON_ERROR) return r; + } else { + /* If we're renaming a user, change quotaroot and ACL */ +@@ -5874,8 +5996,10 @@ static void cmd_rename(char *tag, char *oldname, char *newname, char *partition) + + if (strcmp(oldname, newname)) { + prot_printf(imapd_out, +- "%s NO Cross-server or cross-partition move w/rename not supported\r\n", +- tag); ++ "%s NO Cross-server or cross-partition move w/rename not supported (%s:%d)\r\n", ++ tag, ++ __FILE__, ++ __LINE__); + goto done; + } + +@@ -5886,7 +6010,7 @@ static void cmd_rename(char *tag, char *oldname, char *newname, char *partition) + char newserver[MAX_MAILBOX_BUFFER]; + if (strlen(partition) >= sizeof(newserver)) { + prot_printf(imapd_out, +- "%s NO Partition name too long\r\n", tag); ++ "%s NO Partition name too long (%s:%d)\r\n", tag, __FILE__, __LINE__); + goto done; + } + strcpy(newserver, partition); +@@ -5898,8 +6022,8 @@ static void cmd_rename(char *tag, char *oldname, char *newname, char *partition) + /* xxx this would require administrative access to the + * backend, which we won't get */ + prot_printf(imapd_out, +- "%s NO Can't move across partitions via a proxy\r\n", +- tag); ++ "%s NO Can't move across partitions via a proxy (%s:%d)\r\n", ++ tag, __FILE__, __LINE__); + goto done; + } else { + /* Cross Server */ +@@ -7877,12 +8001,14 @@ static int parse_annotate_fetch_data(const char *tag, + */ + static int parse_metadata_string_or_list(const char *tag, + strarray_t *entries, +- int *was_singlep) ++ int *is_list) + { + int c; + static struct buf arg; + +- *was_singlep = 0; ++ // Again, the assumption is that what can be lists, are ++ // lists until proven otherwise. ++ *is_list = 1; + + c = prot_getc(imapd_in); + if (c == EOF) { +@@ -7928,7 +8054,7 @@ static int parse_metadata_string_or_list(const char *tag, + } + + strarray_append(entries, arg.s); +- *was_singlep = 1; ++ *is_list = 0; + } + + if (c == ' ' || c == '\r') return c; +@@ -8507,7 +8633,8 @@ static void cmd_getmetadata(const char *tag) + strarray_t lists[3] = { STRARRAY_INITIALIZER, + STRARRAY_INITIALIZER, + STRARRAY_INITIALIZER }; +- int was_single[3] = { 0, 0, 0 }; ++ // The default is to consider potential lists a list ++ int is_list[3] = { 1, 1, 1 }; + int nlists = 0; + strarray_t *options = NULL; + strarray_t *mboxes = NULL; +@@ -8529,7 +8656,7 @@ static void cmd_getmetadata(const char *tag) + + while (nlists < 3) + { +- c = parse_metadata_string_or_list(tag, &lists[nlists], &was_single[nlists]); ++ c = parse_metadata_string_or_list(tag, &lists[nlists], &is_list[nlists]); + if (c == EOF) + goto missingargs; + nlists++; +@@ -8537,6 +8664,14 @@ static void cmd_getmetadata(const char *tag) + break; + } + ++ // GETMETADATA: parse result lists[0]: shared/test@lhm.klab.cc ++ // GETMETADATA: parse result lists[1]: /shared/vendor/cmu/cyrus-imapd/server ++ // GETMETADATA: parse result lists[2]: (null) ++ ++ syslog(LOG_DEBUG, "GETMETADATA: parse result lists[0]: %s", strarray_join(&lists[0], ",")); ++ syslog(LOG_DEBUG, "GETMETADATA: parse result lists[1]: %s", strarray_join(&lists[1], ",")); ++ syslog(LOG_DEBUG, "GETMETADATA: parse result lists[2]: %s", strarray_join(&lists[2], ",")); ++ + /* check for CRLF */ + if (c == '\r') c = prot_getc(imapd_in); + if (c != '\n') { +@@ -8579,9 +8714,10 @@ static void cmd_getmetadata(const char *tag) + goto missingargs; + entries = &lists[nlists-1]; /* entries always last */ + if (nlists == 2) { ++ syslog(LOG_DEBUG, "GETMETADATA: no options specified"); + /* no options */ + mboxes = &lists[0]; +- mbox_is_pattern = was_single[0]; ++ mbox_is_pattern = is_list[0]; + } + if (nlists == 3) { + /* options, either before or after */ +@@ -8595,12 +8731,12 @@ static void cmd_getmetadata(const char *tag) + /* (options) (mailboxes) */ + options = &lists[0]; + mboxes = &lists[1]; +- mbox_is_pattern = was_single[1]; ++ mbox_is_pattern = is_list[1]; + break; + case 2: + /* (mailboxes) (options) */ + mboxes = &lists[0]; +- mbox_is_pattern = was_single[0]; ++ mbox_is_pattern = is_list[0]; + options = &lists[1]; + break; + case 3: +@@ -8656,6 +8792,9 @@ static void cmd_getmetadata(const char *tag) + } + } + ++ syslog(LOG_DEBUG, "GETMETADATA: parse result newe: %s", strarray_join(&newe, ",")); ++ syslog(LOG_DEBUG, "GETMETADATA: parse result mboxes: %s", strarray_join(mboxes, ",")); ++ + if (have_private) strarray_append(&newa, "value.priv"); + if (have_shared) strarray_append(&newa, "value.shared"); + +@@ -8664,6 +8803,12 @@ static void cmd_getmetadata(const char *tag) + imapd_userisadmin || imapd_userisproxyadmin, + imapd_userid, imapd_authstate); + basesize = opts.maxsize; ++ ++ if (mbox_is_pattern) ++ syslog(LOG_DEBUG, "GETMETADATA: mbox is a pattern"); ++ else ++ syslog(LOG_DEBUG, "GETMETADATA: mbox is not a pattern"); ++ + if (!mboxes->count || !strcmpsafe(mboxes->data[0], NULL)) { + r = annotate_state_set_server(astate); + if (!r) +diff --git a/imap/lmtpd.c b/imap/lmtpd.c +index 634f350..cfa4518 100644 +--- a/imap/lmtpd.c ++++ b/imap/lmtpd.c +@@ -475,7 +475,7 @@ static int mlookup(const char *name, mbentry_t **mbentryptr) + + mbentry = mboxlist_entry_create(); + mbentry->acl = xstrdupnull(mailboxdata->acl); +- mbentry->server = xstrdupnull(mailboxdata->server); ++ mbentry->server = xstrdupnull(mailboxdata->location); + + /* XXX hack for now - should pull this out into mupdate_find */ + c = strchr(mbentry->server, '!'); +diff --git a/imap/mboxlist.c b/imap/mboxlist.c +index 403aeb9..2bc0bed 100644 +--- a/imap/mboxlist.c ++++ b/imap/mboxlist.c +@@ -485,7 +485,10 @@ HIDDEN int mboxlist_findstage(const char *name, char *stagedir, size_t sd_len) + root = config_partitiondir(mbentry->partition); + mboxlist_entry_free(&mbentry); + +- if (!root) return IMAP_PARTITION_UNKNOWN; ++ if (!root) { ++ syslog(LOG_ERR, "no stage directory for unknown partition"); ++ return IMAP_PARTITION_UNKNOWN; ++ } + + snprintf(stagedir, sd_len, "%s/stage./", root); + +@@ -544,7 +547,7 @@ EXPORTED int mboxlist_update(mbentry_t *mbentry, int localonly) + return r; + } + +-static int mboxlist_findparent(const char *mboxname, ++EXPORTED int mboxlist_findparent(const char *mboxname, + mbentry_t **mbentryp) + { + mbentry_t *mbentry = NULL; +@@ -592,11 +595,15 @@ static int mboxlist_create_partition(const char *mboxname, + part = find_free_partition(NULL); + + /* Configuration error */ +- if (strlen(part) > MAX_PARTITION_LEN) ++ if (strlen(part) > MAX_PARTITION_LEN) { ++ syslog(LOG_ERR, "part longer than maximum partition length in mboxlist_create_partition()"); + goto err; ++ } + +- if (!config_partitiondir(part)) ++ if (!config_partitiondir(part)) { ++ syslog(LOG_ERR, "no configuration for partition dir in mboxlist_create_partition()"); + goto err; ++ } + + *out = xstrdupnull(part); + +@@ -769,16 +776,26 @@ EXPORTED int mboxlist_createmailboxcheck(const char *name, int mbtype __attribut + + r = mboxlist_create_namecheck(name, userid, auth_state, + isadmin, forceuser); +- if (r) goto done; ++ if (r) { ++ syslog(LOG_DEBUG, "mboxlist_create_namecheck returns %s (%s:%d)", error_message(r), __FILE__, __LINE__); ++ goto done; ++ } + + if (newacl) { + r = mboxlist_create_acl(name, &acl); +- if (r) goto done; ++ if (r) { ++ syslog(LOG_DEBUG, "mboxlist_create_acl returns %s (%s:%d)", error_message(r), __FILE__, __LINE__); ++ goto done; ++ } + } + + if (newpartition) { ++ syslog(LOG_DEBUG, "calling mboxlist_create_partition from mboxlist_createmailboxcheck"); + r = mboxlist_create_partition(name, partition, &part); +- if (r) goto done; ++ if (r) { ++ syslog(LOG_DEBUG, "mboxlist_create_partition returns %s (%s:%d)", error_message(r), __FILE__, __LINE__); ++ goto done; ++ } + } + + done: +@@ -822,10 +839,16 @@ static int mboxlist_createmailbox_full(const char *mboxname, int mbtype, + + r = mboxlist_create_namecheck(mboxname, userid, auth_state, + isadmin, forceuser); +- if (r) goto done; ++ if (r) { ++ syslog(LOG_DEBUG, "mboxlist_create_namecheck returns %s (%s:%d)", error_message(r), __FILE__, __LINE__); ++ goto done; ++ } + + /* check if a previous deleted mailbox existed */ + r = mboxlist_mylookup(mboxname, &mbentry, NULL, 0); ++ ++ syslog(LOG_DEBUG, "mboxlist_mylookup returns %s (%s:%d)", error_message(r), __FILE__, __LINE__); ++ + if (!r && mbentry->mbtype == MBTYPE_DELETED) { + /* changing the unique id since last time? */ + if (strcmpsafe(uniqueid, mbentry->uniqueid)) { +@@ -843,17 +866,30 @@ static int mboxlist_createmailbox_full(const char *mboxname, int mbtype, + if (r) goto done; + } + ++ syslog(LOG_DEBUG, "calling mboxlist_create_partition from mboxlist_createmailbox_full"); + r = mboxlist_create_partition(mboxname, partition, &newpartition); +- if (r) goto done; ++ syslog(LOG_DEBUG, "mboxlist_create_partition from mboxlist_createmailbox_full done"); ++ ++ if (r) { ++ syslog(LOG_DEBUG, "mboxlist_create_partition returns %s (%s:%d)", error_message(r), __FILE__, __LINE__); ++ goto done; ++ } + + if (!dbonly && !isremote) { + + /* Filesystem Operations */ ++ syslog(LOG_DEBUG, "calling mailbox_create from mboxlist_createmailbox_full"); + r = mailbox_create(mboxname, mbtype, newpartition, acl, uniqueid, + options, uidvalidity, &newmailbox); +- if (r) goto done; /* CREATE failed */ ++ syslog(LOG_DEBUG, "mailbox_create from mboxlist_createmailbox_full done"); ++ if (r) { ++ syslog(LOG_DEBUG, "mailbox_create returns %s (%s:%d)", error_message(r), __FILE__, __LINE__); ++ goto done; /* CREATE failed */ ++ } + } + ++ syslog(LOG_DEBUG, "all is well, activate the mailbox"); ++ + /* all is well - activate the mailbox */ + newmbentry = mboxlist_entry_create(); + newmbentry->acl = xstrdupnull(acl); +@@ -918,10 +954,24 @@ EXPORTED int mboxlist_createmailbox(const char *name, int mbtype, + int r; + struct mailbox *mailbox = NULL; + +- r = mboxlist_createmailbox_full(name, mbtype, partition, +- isadmin, userid, auth_state, +- options, 0, NULL, NULL, localonly, +- forceuser, dbonly, &mailbox); ++ syslog(LOG_DEBUG, "calling mboxlist_createmailbox_full from mboxlist_createmailbox"); ++ ++ r = mboxlist_createmailbox_full( ++ name, // const char mboxname ++ mbtype, // int mbtype ++ partition, // const char partition ++ isadmin, // int isadmin ++ userid, // const char userid ++ auth_state, // struct auth_state auth_state ++ options, // int options ++ 0, // unsigned uidvalidity ++ NULL, // const char copyacl ++ NULL, // const char uniqueid ++ localonly, // int localonly ++ forceuser, // int forceuser ++ dbonly, // int dbonly ++ &mailbox // struct mailbox mailboxptr ++ ); + + if (notify && !r) { + /* send a MailboxCreate event notification */ +@@ -945,6 +995,8 @@ EXPORTED int mboxlist_createsync(const char *name, int mbtype, + const char *acl, const char *uniqueid, + struct mailbox **mboxptr) + { ++ syslog(LOG_DEBUG, "calling mboxlist_createmailbox_full from mboxlist_createsync"); ++ + return mboxlist_createmailbox_full(name, mbtype, partition, + 1, userid, auth_state, + options, uidvalidity, acl, uniqueid, +@@ -959,6 +1011,8 @@ EXPORTED int mboxlist_insertremote(mbentry_t *mbentry, + int r = 0; + + if (mbentry->server) { ++ syslog(LOG_DEBUG, "%s mbentry->server specified", __func__); ++ + /* remote mailbox */ + if (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_UNIFIED && + !strcasecmp(mbentry->server, config_servername)) { +@@ -974,6 +1028,8 @@ EXPORTED int mboxlist_insertremote(mbentry_t *mbentry, + + mboxent = mboxlist_entry_cstring(mbentry); + ++ syslog(LOG_DEBUG, "mboxent: %s (%s:%d)", mboxent, __FILE__, __LINE__); ++ + /* database put */ + r = cyrusdb_store(mbdb, mbentry->name, strlen(mbentry->name), + mboxent, strlen(mboxent), tid); +@@ -1344,6 +1400,8 @@ EXPORTED int mboxlist_renamemailbox(const char *oldname, const char *newname, + /* this is OK because it uses a different static buffer */ + root = config_partitiondir(partition); + if (!root) { ++ syslog(LOG_ERR, "partition rename without existing target partition"); ++ + r = IMAP_PARTITION_UNKNOWN; + goto done; + } +@@ -1405,6 +1463,7 @@ EXPORTED int mboxlist_renamemailbox(const char *oldname, const char *newname, + isadmin, forceuser); + if (r) goto done; + ++ syslog(LOG_DEBUG, "calling mboxlist_create_partition from mboxlist_renamemailbox"); + r = mboxlist_create_partition(newname, partition, &newpartition); + if (r) goto done; + +diff --git a/imap/mboxlist.h b/imap/mboxlist.h +index 1b13dae..34d26ef 100644 +--- a/imap/mboxlist.h ++++ b/imap/mboxlist.h +@@ -124,6 +124,9 @@ int mboxlist_createmailboxcheck(const char *name, int mbtype, + char **newacl, char **newpartition, + int forceuser); + ++/* Find a parent mailbox */ ++int mboxlist_findparent(const char *mboxname, mbentry_t **mbentryp); ++ + /* create mailbox */ + /* localonly creates the local mailbox without touching mupdate */ + /* forceuser allows the creation of user.x.<name> without a user.x */ +diff --git a/imap/quota.c b/imap/quota.c +index d3b16e9..38583fa 100644 +--- a/imap/quota.c ++++ b/imap/quota.c +@@ -360,7 +360,8 @@ done: + */ + int buildquotalist(char *domain, char **roots, int nroots) + { +- int i, r; ++ int i; ++ int r = 1; // error + char buf[MAX_MAILBOX_BUFFER], *tail; + size_t domainlen = 0; + +@@ -611,7 +612,8 @@ done: + int fixquota_dopass(char *domain, char **roots, int nroots, + foreach_cb *cb) + { +- int i, r; ++ int i; ++ int r = 1; // error + char buf[MAX_MAILBOX_BUFFER], *tail; + size_t domainlen = 0; + +diff --git a/imap/rfc822_header.c b/imap/rfc822_header.c +index bd57930..7bb1f79 100644 +--- a/imap/rfc822_header.c ++++ b/imap/rfc822_header.c +@@ -1,5 +1,5 @@ + /* ANSI-C code produced by gperf version 3.0.4 */ +-/* Command-line: gperf /tmp/compile_st_NBXFPK.gperf */ ++/* Command-line: gperf /home/kanarip/tmp/compile_st_2BOtSi.gperf */ + /* Computed positions: -k'1,10,$' */ + + #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ +diff --git a/lib/imapoptions b/lib/imapoptions +index 2c477a6..3c338b2 100644 +--- a/lib/imapoptions ++++ b/lib/imapoptions +@@ -126,7 +126,7 @@ are listed with ``<none>''. + /* Permit logins by the user "anonymous" using any password. Also + allows use of the SASL ANONYMOUS mechanism. */ + +-{ "allowapop", 1, SWITCH } ++{ "allowapop", 0, SWITCH } + /* Allow use of the POP3 APOP authentication command. + .PP + Note that this command requires that SASL is compiled with APOP +@@ -141,9 +141,14 @@ are listed with ``<none>''. + enabled when absolutely necessary. */ + + { "allowplaintext", 0, SWITCH } +-/* Allow the use of cleartext passwords on the wire. */ ++/* Allow the use of cleartext passwords on the wire ++.PP ++ WARNING: Enabling this option allows cleartext, legible passwords ++ to be transmitted over the network, without any transport layer ++ security (such as SSL encryption) and creates an MiM attack ++ vector. */ + +-{ "allowusermoves", 0, SWITCH } ++{ "allowusermoves", 1, SWITCH } + /* Allow moving user accounts (with associated meta-data) via RENAME + or XFER. + .PP +@@ -152,7 +157,7 @@ are listed with ``<none>''. + to do so may result in the user's meta-data (seen state, + subscriptions, etc) being corrupted or out of date. */ + +-{ "altnamespace", 0, SWITCH } ++{ "altnamespace", 1, SWITCH } + /* Use the alternate IMAP namespace, where personal folders reside at the + same level in the hierarchy as INBOX. + .PP +@@ -170,7 +175,7 @@ are listed with ``<none>''. + /* The absolute path to the annotations db file. If not specified, + will be confdir/annotations.db */ + +-{ "anyoneuseracl", 1, SWITCH } ++{ "anyoneuseracl", 0, SWITCH } + /* Should non-admin users be allowed to set ACLs for the 'anyone' + user on their mailboxes? In a large organization this can cause + support problems, but it's enabled by default. */ +@@ -482,7 +487,7 @@ Blank lines and lines beginning with ``#'' are ignored. + { "failedloginpause", 3, INT } + /* Number of seconds to pause after a failed login. */ + +-{ "flushseenstate", 0, SWITCH } ++{ "flushseenstate", 1, SWITCH } + /* If enabled, changes to the seen state will be flushed to disk + immediately, otherwise changes will be cached and flushed when the + mailbox is closed. This option may be used to fix the problem of +@@ -510,7 +515,7 @@ Blank lines and lines beginning with ``#'' are ignored. + server must be quiesced and then the directories moved with the + \fBrehash\fR utility. */ + +-{ "hashimapspool", 0, SWITCH } ++{ "hashimapspool", 1, SWITCH } + /* If enabled, the partitions will also be hashed, in addition to the + hashing done on configuration directories. This is recommended if + one partition has a very bushy mailbox tree. */ +@@ -751,7 +756,7 @@ Blank lines and lines beginning with ``#'' are ignored. + /* If enabled, lmtpd will convert the recipient addresses to lowercase + (up to a '+' character, if present). */ + +-{ "lmtp_fuzzy_mailbox_match", 0, SWITCH } ++{ "lmtp_fuzzy_mailbox_match", 1, SWITCH } + /* If enabled, and the mailbox specified in the detail part of the + recipient (everything after the '+') does not exist, lmtpd will try + to find the closest match (ignoring case, ignoring whitespace, +@@ -1508,7 +1513,7 @@ product version in the capabilities */ + /* Number of seconds to wait for a response before returning a timeout + failure when talking to a replication peer (client or server). */ + +-{ "syslog_prefix", NULL, STRING } ++{ "syslog_prefix", "cyrus-imapd", STRING } + /* String to be prepended to the process name in syslog entries. */ + + { "syslog_facility", NULL, STRING } +@@ -1598,12 +1603,12 @@ product version in the capabilities */ + with a backend (such as LDAP) that can make getgrent() calls very + slow) */ + +-{ "unixhierarchysep", 0, SWITCH } ++{ "unixhierarchysep", 1, SWITCH } + /* Use the UNIX separator character '/' for delimiting levels of + mailbox hierarchy. The default is to use the netnews separator + character '.'. */ + +-{ "virtdomains", "off", ENUM("off", "userid", "on") } ++{ "virtdomains", "userid", ENUM("off", "userid", "on") } + /* Enable virtual domain support. If enabled, the user's domain will + be determined by splitting a fully qualified userid at the last '@' + or '%' symbol. If the userid is unqualified, and the virtdomains
View file
cyrus-imapd-2.5.tar.gz/imap/annotate.c
Changed
@@ -1190,6 +1190,7 @@ goto out; state->mailbox_is_ours = 1; } + assert(mailbox); state->mbentry = mbentry; }
View file
cyrus-imapd-2.5.tar.gz/imap/ctl_mboxlist.c
Changed
@@ -72,6 +72,7 @@ #include "assert.h" #include "annotate.h" +#include "dlist.h" #include "exitcodes.h" #include "imap/imap_err.h" #include "global.h" @@ -109,7 +110,7 @@ struct mb_node { char mailbox[MAX_MAILBOX_BUFFER]; - char server[MAX_MAILBOX_BUFFER]; + char location[MAX_MAILBOX_BUFFER]; char *acl; struct mb_node *next; }; @@ -144,7 +145,7 @@ /* the server thinks we have it, do we think we have it? */ ret = mboxlist_lookup(mdata->mailbox, NULL, NULL); - if(ret) { + if (ret) { struct mb_node *next; next = xzmalloc(sizeof(struct mb_node)); @@ -160,8 +161,8 @@ next = xzmalloc(sizeof(struct mb_node)); strlcpy(next->mailbox, mdata->mailbox, sizeof(next->mailbox)); - strlcpy(next->server, mdata->server, sizeof(next->server)); - if(!strncmp(cmd, "MAILBOX", 7)) + strlcpy(next->location, mdata->location, sizeof(next->location)); + if (!strncmp(cmd, "MAILBOX", 7)) next->acl = xstrdup(mdata->acl); *act_tail = next; @@ -177,36 +178,149 @@ struct dumprock *d = (struct dumprock *) rockp; int r = 0; char *p; - char *name, *part, *acl; - int mbtype; + char *name, *server, *part; + char *acl = NULL; + uint32_t mbtype = 0; + struct dlist *dl = NULL; /* \0 terminate 'name' */ name = xstrndup(key, keylen); - /* Get mailbox type */ - mbtype = strtol(data, &p, 10); + // this is a dlist + if (data[0] == '%') { + char *mbtype_str = '\0'; // placeholder for string obtained from dlist - p = strchr(data, ' '); - if (p == NULL) { - abort(); - } - p++; - acl = strchr(p, ' '); - if (acl == NULL) { - abort(); - } - /* grab 'part', \0 terminate */ - part = xstrndup(p, acl - p); + r = dlist_parsemap(&dl, 0, data, datalen); + + if (!r) { + struct dlist *dl_acl = dlist_getchild(dl, "A"); + struct dlist *dl_ace; + + for (dl_ace = dl_acl->head; dl_ace; dl_ace = dl_ace->next) { + const char *tmp; + r = dlist_getatom(dl_acl, dl_ace->name, &tmp); + + if (!r) { + syslog( + LOG_ERR, + "Failed to dlist_getatom for (A)CL " + "dlist_kvlist key '%s' (%s:%d)", + dl_ace->name, + __FILE__, + __LINE__ + ); - /* \0 terminate 'acl' */ - p = acl + 1; - acl = xstrndup(p, datalen - (p - data)); + continue; + } // if (r = dlist_getatom()) + + if (dl_ace->name && tmp) { + const char *ace = strconcat(xstrdup(dl_ace->name), " ", xstrdup(tmp)); + + if (acl) { + acl = strconcat(xstrdup(acl), " ", ace); + } else { + acl = xstrdup(ace); + } + } + } + + // The partition is always there... + r = dlist_getatom(dl, "P", (const char **)&part); + + if (!r) { + syslog( + LOG_ERR, + "Failed to obtain (P)artition from dlist " + "(%s:%d)", + __FILE__, + __LINE__ + ); + + } + + // The mailbox type is always there too... as a string + r = dlist_getatom(dl, "T", (const char **)&mbtype_str); + + if (!r) { + syslog( + LOG_ERR, + "Failed to obtain (T)ype from dlist (%s:%d)", + __FILE__, + __LINE__ + ); + + } + + mbtype = mboxlist_string_to_mbtype(mbtype_str); + + // If the mailbox is 'remote', the 'server' field matters + if (mbtype & MBTYPE_REMOTE) { + r = dlist_getatom(dl, "S", (const char **)&server); + + if (!r) { + syslog( + LOG_ERR, + "Failed to obtain (S)erver from dlist " + "(%s:%d)", + __FILE__, + __LINE__ + ); + + } + + + if (server == config_servername) { + syslog( + LOG_WARNING, + "Mailbox %s is marked remote, but the server " + "on which it is supposed to reside equals " + "our server name.", + name + ); + } + + // Since we have a server, make it part of the location + part = strconcat(server, "!", xstrdup(part)); + + } // (mbtype & MBTYPE_REMOTE) + } // if (r = dlist_parsemap()) + else { + syslog( + LOG_ERR, + "Failed to parse dlist (%s:%d)", + __FILE__, + __LINE__ + ); + } + + } // (data[0] == '%') + else { + /* Get mailbox type */ + mbtype = strtol(data, &p, 10); + + p = strchr(data, ' '); + if (p == NULL) { + abort(); + } + p++; + acl = strchr(p, ' '); + if (acl == NULL) { + abort(); + } + + /* grab 'part', \0 terminate */ + part = xstrndup(p, acl - p); + + /* \0 terminate 'acl' */ + p = acl + 1; + acl = xstrndup(p, datalen - (p - data)); + } switch (d->op) { case DUMP: - if(!d->partition || !strcmp(d->partition, part)) { + if (!d->partition || !strcmp(d->partition, part)) { printf("%s\t%d %s %s\n", name, mbtype, part, acl); - if(d->purge) { + if (d->purge) { cyrusdb_delete(mbdb, key, keylen, &(d->tid), 0); } } @@ -230,16 +344,16 @@ * need to send fresh data. There will be no point at which something * is in the act_head list that we do not have locally, because that * is a condition of being in the act_head list */ - if(act_head && !strcmp(name, act_head->mailbox)) { + if (act_head && !strcmp(name, act_head->mailbox)) { struct mb_node *tmp; /* If this mailbox was moving, we want to unmark the movingness, * since the MUPDATE server agreed that it lives here. */ /* (and later also force an mupdate push) */ - if(mbtype & MBTYPE_MOVING) { + if (mbtype & MBTYPE_MOVING) { struct mb_node *next; - if(warn_only) { + if (warn_only) { printf("Remove remote flag on: %s\n", name); } else { next = xzmalloc(sizeof(struct mb_node)); @@ -251,8 +365,8 @@ /* No need to update mupdate NOW, we'll get it when we * untag the mailbox */ skip_flag = 1; - } else if(act_head->acl && - !strcmp(realpart, act_head->server) && + } else if (act_head->acl && + !strcmp(realpart, act_head->location) && !strcmp(acl, act_head->acl)) { /* Do not update if location does match, and there is an acl, * and the acl matches */ @@ -263,10 +377,10 @@ } /* in any case, free the node. */ - if(act_head->acl) free(act_head->acl); + if (act_head->acl) free(act_head->acl); tmp = act_head; act_head = act_head->next; - free(tmp); + if (tmp) free(tmp); } else { /* if they do not match, do an explicit MUPDATE find on the * mailbox, and if it is living somewhere else, delete the local @@ -276,7 +390,7 @@ /* if this is okay, we found it (so it is on another host, since * it wasn't in our list in this position) */ - if(!local_authoritative && + if (!local_authoritative && !mupdate_find(d->h, name, &mdata)) { /* since it lives on another server, schedule it for a wipe */ struct mb_node *next; @@ -287,15 +401,15 @@ * if wrong, we'll end up removing the authoritative * mailbox. */ - if (strcmp(realpart, mdata->server) == 0 ) { + if (strcmp(realpart, mdata->location) == 0 ) { if ( act_head ) { fprintf( stderr, "mupdate said: %s %s %s\n", - act_head->mailbox, act_head->server, act_head->acl ); + act_head->mailbox, act_head->location, act_head->acl ); } fprintf( stderr, "mailboxes.db said: %s %s %s\n", name, realpart, acl ); fprintf( stderr, "mupdate says: %s %s %s\n", - mdata->mailbox, mdata->server, mdata->acl ); + mdata->mailbox, mdata->location, mdata->acl ); fatal("mupdate said not us before it said us", EC_SOFTWARE); } @@ -308,7 +422,7 @@ if (config_mupdate_config != IMAP_ENUM_MUPDATE_CONFIG_UNIFIED) { /* But not for a unified configuration */ - if(warn_only) { + if (warn_only) { printf("Remove Local Mailbox: %s\n", name); } else { next = xzmalloc(sizeof(struct mb_node)); @@ -321,12 +435,12 @@ skip_flag = 1; } else { /* Check that it isn't flagged moving */ - if(mbtype & MBTYPE_MOVING) { + if (mbtype & MBTYPE_MOVING) { /* it's flagged moving, we'll fix it later (and * push it then too) */ struct mb_node *next; - if(warn_only) { + if (warn_only) { printf("Remove remote flag on: %s\n", name); } else { next = xzmalloc(sizeof(struct mb_node)); @@ -345,11 +459,11 @@ } } - if(skip_flag) { + if (skip_flag) { free(realpart); break; } - if(warn_only) { + if (warn_only) { printf("Force Activate: %s\n", name); free(realpart); break; @@ -358,7 +472,7 @@ free(realpart); - if(r == MUPDATE_NOCONN) { + if (r == MUPDATE_NOCONN) { fprintf(stderr, "permanant failure storing '%s'\n", name); r = IMAP_IOERROR; } else if (r == MUPDATE_FAIL) { @@ -376,15 +490,15 @@ break; } - free(name); - free(part); - free(acl); + if (name) free(name); + if (part) free(part); + if (acl) free(acl); return r; } /* - * True iff user types Y\n or y\n. Anthing else is false. + * True if user types Y\n or y\n. Anthing else is false. */ static int yes(void) { @@ -431,9 +545,9 @@ d.purge = purge; d.tid = NULL; - if(op == M_POPULATE) { + if (op == M_POPULATE) { ret = mupdate_connect(NULL, NULL, &(d.h), NULL); - if(ret) { + if (ret) { fprintf(stderr, "couldn't connect to mupdate server\n"); exit(1); } @@ -443,21 +557,21 @@ * (to ensure we get exactly our hostname) */ snprintf(buf, sizeof(buf), "%s!", config_servername); ret = mupdate_list(d.h, mupdate_list_cb, buf, NULL); - if(ret) { + if (ret) { fprintf(stderr, "couldn't do LIST command on mupdate server\n"); exit(1); } /* Run pending mupdate deletes */ - while(del_head) { + while (del_head) { struct mb_node *me = del_head; del_head = del_head->next; - if(warn_only) { + if (warn_only) { printf("Remove from MUPDATE: %s\n", me->mailbox); } else { ret = mupdate_delete(d.h, me->mailbox); - if(ret) { + if (ret) { fprintf(stderr, "couldn't mupdate delete %s\n", me->mailbox); exit(1); @@ -485,7 +599,7 @@ unflag_head = unflag_head->next; ret = mboxlist_lookup(me->mailbox, &mbentry, NULL); - if(ret) { + if (ret) { fprintf(stderr, "couldn't perform lookup to un-remote-flag %s\n", me->mailbox); @@ -534,7 +648,7 @@ } } - while(wipe_head) { + while (wipe_head) { struct mb_node *me = wipe_head; wipe_head = wipe_head->next; @@ -645,10 +759,10 @@ free(data); - if(--untilCommit == 0) { + if (--untilCommit == 0) { /* commit */ r = cyrusdb_commit(mbdb, tid); - if(r) break; + if (r) break; tid = NULL; untilCommit = PER_COMMIT; strlcpy(last_commit,key,sizeof(last_commit)); @@ -657,16 +771,16 @@ if (r) break; } - if(!r && tid) { + if (!r && tid) { /* commit the last transaction */ r=cyrusdb_commit(mbdb, tid); } if (r) { - if(tid) cyrusdb_abort(mbdb, tid); + if (tid) cyrusdb_abort(mbdb, tid); fprintf(stderr, "db error: %s\n", cyrusdb_strerror(r)); - if(key) fprintf(stderr, "was processing mailbox: %s\n", key); - if(last_commit[0]) fprintf(stderr, "last commit was at: %s\n", + if (key) fprintf(stderr, "was processing mailbox: %s\n", key); + if (last_commit[0]) fprintf(stderr, "last commit was at: %s\n", last_commit); else fprintf(stderr, "no commits\n"); } @@ -1039,11 +1153,11 @@ } } - if(op != M_POPULATE && (local_authoritative || warn_only)) usage(); - if(op != DUMP && partition) usage(); - if(op != DUMP && dopurge) usage(); + if (op != M_POPULATE && (local_authoritative || warn_only)) usage(); + if (op != DUMP && partition) usage(); + if (op != DUMP && dopurge) usage(); - if(op == RECOVER) { + if (op == RECOVER) { syslog(LOG_NOTICE, "running mboxlist recovery"); libcyrus_config_setint(CYRUSOPT_DB_INIT_FLAGS, CYRUSDB_RECOVER); }
View file
cyrus-imapd-2.5.tar.gz/imap/mboxlist.c
Changed
@@ -514,7 +514,8 @@ "cannot connect to mupdate server for update of '%s'", mbentry->name); } else { - char *location = strconcat(config_servername, (char *)NULL); + char *location = strconcat(config_servername, "!", + mbentry->partition, (char *)NULL); r = mupdate_activate(mupdate_h, mbentry->name, location, mbentry->acl); free(location); @@ -875,7 +876,7 @@ /* 9. set MUPDATE entry as commited (CRASH: commited) */ if (!r && config_mupdate_server && !localonly) { mupdate_handle *mupdate_h = NULL; - char *loc = strconcat(config_servername, (char *)NULL); + char *loc = strconcat(config_servername, "!", newpartition, (char *)NULL); r = mupdate_connect(config_mupdate_server, NULL, &mupdate_h, NULL); if (!r) r = mupdate_reserve(mupdate_h, mboxname, loc); @@ -1482,7 +1483,7 @@ if (config_mupdate_server) { /* commit the mailbox in MUPDATE */ - char *loc = strconcat(config_servername, (char *)NULL); + char *loc = strconcat(config_servername, "!", newpartition, (char *)NULL); r = mupdate_connect(config_mupdate_server, NULL, &mupdate_h, NULL); if (!partitionmove) {
View file
cyrus-imapd-2.5.tar.gz/imap/mupdate-client.c
Changed
@@ -167,12 +167,12 @@ const char *cmd, void *context __attribute__((unused))) { - syslog(LOG_ERR, "mupdate_scarf_one was called, but shouldn't be. Command recieved was %s", cmd); + syslog(LOG_ERR, "mupdate_scarf_one was called, but shouldn't be. Command received was %s", cmd); return -1; } EXPORTED int mupdate_activate(mupdate_handle *handle, - const char *mailbox, const char *server, + const char *mailbox, const char *location, const char *acl) { int ret; @@ -180,22 +180,31 @@ const char *p; if (!handle) return MUPDATE_BADPARAM; - if (!mailbox || !server || !acl) return MUPDATE_BADPARAM; + if (!mailbox || !location || !acl) return MUPDATE_BADPARAM; if (!handle->saslcompleted) return MUPDATE_NOAUTH; + syslog(LOG_DEBUG, "mupdate_activate for mailbox: %s, location: %s, acl: %s", mailbox, location, acl); + /* make sure we don't have a double server!partition */ - if ((p = strchr(server, '!')) && strchr(p+1, '!')) return MUPDATE_BADPARAM; + if ((p = strchr(location, '!')) && strchr(p+1, '!')) return MUPDATE_BADPARAM; if (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_REPLICATED) { /* we don't care about the server part, everything is local */ - if (p) server = p + 1; + if (p) location = p + 1; } + syslog(LOG_DEBUG, "mupdate_activate for mailbox: %s, location: %s, acl: %s", mailbox, location, acl); + prot_printf(handle->conn->out, - "X%u ACTIVATE {" SIZE_T_FMT "+}\r\n%s" - " {" SIZE_T_FMT "+}\r\n%s {" SIZE_T_FMT "+}\r\n%s\r\n", - handle->tagn++, strlen(mailbox), mailbox, - strlen(server), server, strlen(acl), acl); + "X%u ACTIVATE " + "{" SIZE_T_FMT "+}\r\n%s " + "{" SIZE_T_FMT "+}\r\n%s " + "{" SIZE_T_FMT "+}\r\n%s\r\n", + handle->tagn++, + strlen(mailbox), mailbox, + strlen(location), location, + strlen(acl), acl + ); ret = mupdate_scarf(handle, mupdate_scarf_one, NULL, 1, &response); if (ret) { @@ -208,28 +217,34 @@ } HIDDEN int mupdate_reserve(mupdate_handle *handle, - const char *mailbox, const char *server) + const char *mailbox, const char *location) { int ret; enum mupdate_cmd_response response; const char *p; if (!handle) return MUPDATE_BADPARAM; - if (!mailbox || !server) return MUPDATE_BADPARAM; + if (!mailbox || !location) return MUPDATE_BADPARAM; if (!handle->saslcompleted) return MUPDATE_NOAUTH; /* make sure we don't have a double server!partition */ - if ((p = strchr(server, '!')) && strchr(p+1, '!')) return MUPDATE_BADPARAM; + if ((p = strchr(location, '!')) && strchr(p+1, '!')) return MUPDATE_BADPARAM; if (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_REPLICATED) { - /* we don't care about the server part, everything is local */ - if (p) server = p + 1; + /* we don't care about the location part, everything is local */ + if (p) location = p + 1; } + syslog(LOG_DEBUG, "mupdate_reserve for mailbox: %s, location: %s", mailbox, location); + prot_printf(handle->conn->out, - "X%u RESERVE {" SIZE_T_FMT "+}\r\n%s {" SIZE_T_FMT "+}\r\n%s\r\n", - handle->tagn++, strlen(mailbox), mailbox, - strlen(server), server); + "X%u RESERVE " + "{" SIZE_T_FMT "+}\r\n%s " + "{" SIZE_T_FMT "+}\r\n%s\r\n", + handle->tagn++, + strlen(mailbox), mailbox, + strlen(location), location + ); ret = mupdate_scarf(handle, mupdate_scarf_one, NULL, 1, &response); if (ret) { @@ -242,28 +257,32 @@ } EXPORTED int mupdate_deactivate(mupdate_handle *handle, - const char *mailbox, const char *server) + const char *mailbox, const char *location) { int ret; enum mupdate_cmd_response response; const char *p; if (!handle) return MUPDATE_BADPARAM; - if (!mailbox || !server) return MUPDATE_BADPARAM; + if (!mailbox || !location) return MUPDATE_BADPARAM; if (!handle->saslcompleted) return MUPDATE_NOAUTH; - /* make sure we don't have a double server!partition */ - if ((p = strchr(server, '!')) && strchr(p+1, '!')) return MUPDATE_BADPARAM; + /* make sure we don't have a double location!partition */ + if ((p = strchr(location, '!')) && strchr(p+1, '!')) return MUPDATE_BADPARAM; if (config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_REPLICATED) { /* we don't care about the server part, everything is local */ - if (p) server = p + 1; + if (p) location = p + 1; } prot_printf(handle->conn->out, - "X%u DEACTIVATE {" SIZE_T_FMT "+}\r\n%s {" SIZE_T_FMT "+}\r\n%s\r\n", - handle->tagn++, strlen(mailbox), mailbox, - strlen(server), server); + "X%u DEACTIVATE " + "{" SIZE_T_FMT "+}\r\n%s " + "{" SIZE_T_FMT "+}\r\n%s\r\n", + handle->tagn++, + strlen(mailbox), mailbox, + strlen(location), location + ); ret = mupdate_scarf(handle, mupdate_scarf_one, NULL, 1, &response); if (ret) { @@ -310,7 +329,7 @@ /* coyp the data to the handle storage */ /* xxx why can't we just point to the 'mdata' buffers? */ strlcpy(h->mailbox_buf, mdata->mailbox, sizeof(h->mailbox_buf)); - strlcpy(h->server_buf, mdata->server, sizeof(h->server_buf)); + strlcpy(h->location_buf, mdata->location, sizeof(h->location_buf)); if(!strncmp(cmd, "MAILBOX", 7)) { h->mailboxdata_buf.t = ACTIVE; @@ -327,7 +346,7 @@ } h->mailboxdata_buf.mailbox = h->mailbox_buf; - h->mailboxdata_buf.server = h->server_buf; + h->mailboxdata_buf.location = h->location_buf; h->mailboxdata_buf.acl = h->acl; return 0; @@ -554,7 +573,7 @@ /* Handle mailbox command */ memset(&box, 0, sizeof(box)); box.mailbox = handle->arg1.s; - box.server = handle->arg2.s; + box.location = handle->arg2.s; box.acl = handle->arg3.s; r = callback(&box, handle->cmd.s, context); if (r) { /* callback error ? */ @@ -607,7 +626,7 @@ /* Handle reserve command */ memset(&box, 0, sizeof(box)); box.mailbox = handle->arg1.s; - box.server = handle->arg2.s; + box.location = handle->arg2.s; r = callback(&box, handle->cmd.s, context); if (r) { /* callback error ? */ syslog(LOG_ERR,
View file
cyrus-imapd-2.5.tar.gz/imap/mupdate-client.h
Changed
@@ -58,16 +58,16 @@ /* activate a mailbox */ int mupdate_activate(mupdate_handle *handle, - const char *mailbox, const char *server, + const char *mailbox, const char *location, const char *acl); /* reserve a piece of namespace */ int mupdate_reserve(mupdate_handle *handle, - const char *mailbox, const char *server); + const char *mailbox, const char *location); /* deactivate a mailbox (ACTIVE->RESERVE) */ int mupdate_deactivate(mupdate_handle *handle, - const char *mailbox, const char *server); + const char *mailbox, const char *location); /* delete a mailbox */ int mupdate_delete(mupdate_handle *handle, @@ -80,7 +80,7 @@ /* mailbox data structure */ struct mupdate_mailboxdata { const char *mailbox; - const char *server; + const char *location; const char *acl; enum mbtype t; };
View file
cyrus-imapd-2.5.tar.gz/imap/mupdate.c
Changed
@@ -209,7 +209,7 @@ const char *clientstart); static void cmd_set(struct conn *C, const char *tag, const char *mailbox, - const char *server, const char *acl, enum settype t); + const char *location, const char *acl, enum settype t); static void cmd_find(struct conn *C, const char *tag, const char *mailbox, int send_ok, int send_delete); static void cmd_list(struct conn *C, const char *tag, const char *host_prefix); @@ -284,7 +284,7 @@ C->saslprops.ipremoteport, NULL, 0, &C->saslconn); - if(r != SASL_OK) { + if (r != SASL_OK) { syslog(LOG_ERR, "failed to start sasl for connection: %s", sasl_errstring(r, NULL, NULL)); prot_printf(C->pout, SERVER_UNABLE_STRING); @@ -367,7 +367,7 @@ #endif cyrus_close_sock(C->fd); - if(C->logfd != -1) close(C->logfd); + if (C->logfd != -1) close(C->logfd); if (C->saslconn) sasl_dispose(&C->saslconn); @@ -380,7 +380,7 @@ buf_free(&(C->arg2)); buf_free(&(C->arg3)); - if(C->streaming_hosts) strarray_free(C->streaming_hosts); + if (C->streaming_hosts) strarray_free(C->streaming_hosts); free(C); } @@ -489,27 +489,27 @@ /* Do minor configuration checking */ workers_to_start = config_getint(IMAPOPT_MUPDATE_WORKERS_START); - if(config_getint(IMAPOPT_MUPDATE_WORKERS_MAX) < config_getint(IMAPOPT_MUPDATE_WORKERS_MINSPARE)) { + if (config_getint(IMAPOPT_MUPDATE_WORKERS_MAX) < config_getint(IMAPOPT_MUPDATE_WORKERS_MINSPARE)) { syslog(LOG_CRIT, "Maximum total worker threads is less than minimum spare worker threads"); return EC_SOFTWARE; } - if(workers_to_start < config_getint(IMAPOPT_MUPDATE_WORKERS_MINSPARE)) { + if (workers_to_start < config_getint(IMAPOPT_MUPDATE_WORKERS_MINSPARE)) { syslog(LOG_CRIT, "Starting worker threads is less than minimum spare worker threads"); return EC_SOFTWARE; } - if(config_getint(IMAPOPT_MUPDATE_WORKERS_MAXSPARE) < workers_to_start) { + if (config_getint(IMAPOPT_MUPDATE_WORKERS_MAXSPARE) < workers_to_start) { syslog(LOG_CRIT, "Maximum spare worker threads is less than starting worker threads"); return EC_SOFTWARE; } - if(config_getint(IMAPOPT_MUPDATE_WORKERS_MINSPARE) > workers_to_start) { + if (config_getint(IMAPOPT_MUPDATE_WORKERS_MINSPARE) > workers_to_start) { syslog(LOG_CRIT, "Minimum spare worker threads is greater than starting worker threads"); return EC_SOFTWARE; } - if(config_getint(IMAPOPT_MUPDATE_WORKERS_MAX) < workers_to_start) { + if (config_getint(IMAPOPT_MUPDATE_WORKERS_MAX) < workers_to_start) { syslog(LOG_CRIT, "Maximum total worker threads is less than starting worker threads"); return EC_SOFTWARE; } @@ -546,7 +546,7 @@ fatal("cannot run mupdate master on a unified server", EC_USAGE); } - if(pipe(conn_pipe) == -1) { + if (pipe(conn_pipe) == -1) { syslog(LOG_ERR, "could not setup connection signaling pipe %m"); return EC_OSERR; } @@ -555,7 +555,7 @@ if (!masterp) { r = pthread_create(&t, NULL, &mupdate_client_start, NULL); - if(r == 0) { + if (r == 0) { pthread_detach(t); } else { syslog(LOG_ERR, "could not start client thread"); @@ -564,14 +564,14 @@ /* Wait until they sync the database */ pthread_mutex_lock(&synced_mutex); - if(!synced) + if (!synced) pthread_cond_wait(&synced_cond, &synced_mutex); pthread_mutex_unlock(&synced_mutex); } else { pthread_t t; r = pthread_create(&t, NULL, &mupdate_placebo_kick_start, NULL); - if(r == 0) { + if (r == 0) { pthread_detach(t); } else { syslog(LOG_ERR, "could not start placebo kick thread"); @@ -584,7 +584,7 @@ /* Now create the worker thread pool */ for(i=0; i < workers_to_start; i++) { r = pthread_create(&t, NULL, &thread_main, NULL); - if(r == 0) { + if (r == 0) { pthread_detach(t); } else { syslog(LOG_ERR, "could not start client thread"); @@ -605,7 +605,7 @@ { static int recurse_code = 0; - if(recurse_code) exit(code); + if (recurse_code) exit(code); else recurse_code = code; syslog(LOG_ERR, "%s", s); @@ -661,7 +661,7 @@ /* parse command name */ ch = getword(c->pin, &(c->cmd)); - if(ch == EOF) { + if (ch == EOF) { goto lost_conn; } else if (!c->cmd.s[0]) { prot_printf(c->pout, "%s BAD \"Null command\"\r\n", c->tag.s); @@ -883,11 +883,11 @@ while(ch == ' ') { /* Hey, look, more bits of a PARTIAL-UPDATE command */ ch = getstring(c->pin, c->pout, &(c->arg1)); - if(c->arg1.s[0] == '\0') { + if (c->arg1.s[0] == '\0') { strarray_free(arg); goto badargs; } - if(counter-- == 0) { + if (counter-- == 0) { strarray_free(arg); goto extraargs; } @@ -963,7 +963,7 @@ done: /* Restore the state of the input stream */ - if(was_blocking) + if (was_blocking) prot_BLOCK(c->pin); else prot_NONBLOCK(c->pin); @@ -1001,7 +1001,7 @@ syslog(LOG_ERR, "Server too busy, dropping connection."); if (r) return 0; /* filthy hack to avoid warning on 'r' */ - } else if(write(conn_pipe[1], &fd, sizeof(fd)) == -1) { + } else if (write(conn_pipe[1], &fd, sizeof(fd)) == -1) { /* signal that a new file descriptor is available. * If it fails... */ @@ -1028,8 +1028,8 @@ &mechs, NULL, &mechcount); /* Add mupdate:// tag if necessary */ - if(!masterp) { - if(!config_mupdate_server) + if (!masterp) { + if (!config_mupdate_server) fatal("mupdate server was not specified for slave", EC_TEMPFAIL); @@ -1100,10 +1100,10 @@ max_worker_flag = (idle_worker_count >= config_getint(IMAPOPT_MUPDATE_WORKERS_MAXSPARE)); /* Increment Idle Workers */ - if(!max_worker_flag) idle_worker_count++; + if (!max_worker_flag) idle_worker_count++; pthread_mutex_unlock(&idle_worker_mutex); - if(max_worker_flag) goto worker_thread_done; + if (max_worker_flag) goto worker_thread_done; retry_lock: @@ -1377,11 +1377,25 @@ /* log change to database. database must be locked. */ static void database_log(const struct mbent *mb, struct txn **mytid) { + char *c; + char *location = NULL; mbentry_t *mbentry = NULL; mbentry = mboxlist_entry_create(); mbentry->name = xstrdupnull(mb->mailbox); - mbentry->server = xstrdupnull(mb->server); + + location = xstrdupnull(mb->location); + + mbentry->server = xstrdupnull(mb->location); + + c = strchr(mbentry->server, '!'); + if (c) { + *c++ = '\0'; + mbentry->partition = xstrdupnull(c); + } + + if (location) free(location); + mbentry->acl = xstrdupnull(mb->acl); switch (mb->t) { @@ -1416,7 +1430,7 @@ { mbentry_t *mbentry = NULL; struct mbent *out; - char *server = NULL; + char *location = NULL; int r; if (!name) return NULL; @@ -1427,28 +1441,32 @@ /* XXX - if mbtype & MBTYPE_DELETED, maybe set a delete */ if (mbentry->mbtype & MBTYPE_RESERVE) { - if(!pool) out = xmalloc(sizeof(struct mbent) + 1); + if (!pool) out = xmalloc(sizeof(struct mbent) + 1); else out = mpool_malloc(pool, sizeof(struct mbent) + 1); out->t = SET_RESERVE; out->acl[0] = '\0'; } else { - if(!pool) out = xmalloc(sizeof(struct mbent) + strlen(mbentry->acl)); + if (!pool) out = xmalloc(sizeof(struct mbent) + strlen(mbentry->acl)); else out = mpool_malloc(pool, sizeof(struct mbent) + strlen(mbentry->acl)); out->t = SET_ACTIVE; strcpy(out->acl, mbentry->acl); } - if (mbentry->server) - server = xstrdup(mbentry->server); + if (mbentry->server && mbentry->partition) + location = strconcat(mbentry->server, "!", mbentry->partition, NULL); + else if (mbentry->server) + location = xstrdup(mbentry->server); + else if (mbentry->partition) + location = xstrdup(mbentry->partition); else - server = xstrdup(""); + location = xstrdup(""); out->mailbox = (pool) ? mpool_strdup(pool, name) : xstrdup(name); - out->server = (pool) ? mpool_strdup(pool, server) - : xstrdup(server); + out->location = (pool) ? mpool_strdup(pool, location) + : xstrdup(location); - free(server); + free(location); mboxlist_entry_free(&mbentry); return out; @@ -1501,7 +1519,7 @@ /* Successful Authentication */ r = sasl_getprop(C->saslconn, SASL_USERNAME, &val); - if(r != SASL_OK) { + if (r != SASL_OK) { prot_printf(C->pout, "%s NO \"SASL Error\"\r\n", tag); reset_saslconn(C); return; @@ -1523,11 +1541,11 @@ /* Log the update out to anyone who is in our updatelist */ /* INVARIANT: caller MUST hold mailboxes_mutex */ -/* oldserver is the previous value of the server in this update, - thisserver is the current value of the mailbox's server */ +/* oldlocation is the previous value of the location in this update, + thislocation is the current value of the mailbox's location */ static void log_update(const char *mailbox, - const char *oldserver, - const char *thisserver) + const char *oldlocation, + const char *thislocation) { struct conn *upc; @@ -1538,11 +1556,11 @@ strlcpy(p->mailbox, mailbox, sizeof(p->mailbox)); /* this might need to be inside the mutex, but I doubt it */ - if(upc->streaming_hosts - && (!oldserver || strarray_find(upc->streaming_hosts, - oldserver, 0) < 0) - && (!thisserver || strarray_find(upc->streaming_hosts, - thisserver, 0) < 0)) { + if (upc->streaming_hosts + && (!oldlocation || strarray_find(upc->streaming_hosts, + oldlocation, 0) < 0) + && (!thislocation || strarray_find(upc->streaming_hosts, + thislocation, 0) < 0)) { /* No Match! Continue! */ continue; } @@ -1562,11 +1580,11 @@ static void cmd_set(struct conn *C, const char *tag, const char *mailbox, - const char *server, const char *acl, enum settype t) + const char *location, const char *acl, enum settype t) { struct mbent *m; - char *oldserver = NULL; - char *thisserver = NULL; + char *oldlocation = NULL; + char *thislocation = NULL; char *tmp; /* Hold any output that we need to do */ @@ -1605,18 +1623,18 @@ } /* otherwise do nothing (local delete on master) */ } else { - oldserver = xstrdup(m->server); + oldlocation = xstrdup(m->location); /* do the deletion */ m->t = SET_DELETE; } } else { - if(m) - oldserver = m->server; + if (m) + oldlocation = m->location; if (m && (!acl || strlen(acl) < strlen(m->acl))) { /* change what's already there -- the acl is smaller */ - m->server = xstrdup(server); + m->location = xstrdup(location); if (acl) strcpy(m->acl, acl); else m->acl[0] = '\0'; @@ -1631,7 +1649,8 @@ newm = xrealloc(m, sizeof(struct mbent) + 1); } newm->mailbox = xstrdup(mailbox); - newm->server = xstrdup(server); + newm->location = xstrdup(location); + if (acl) { strcpy(newm->acl, acl); } else { @@ -1648,24 +1667,24 @@ /* write to disk */ if (m) database_log(m, NULL); - if(oldserver) { - tmp = strchr(oldserver, '!'); - if(tmp) *tmp = '\0'; + if (oldlocation) { + tmp = strchr(oldlocation, '!'); + if (tmp) *tmp = '\0'; } - if(server) { - thisserver = xstrdup(server); - tmp = strchr(thisserver, '!'); - if(tmp) *tmp = '\0'; + if (location) { + thislocation = xstrdup(location); + tmp = strchr(thislocation, '!'); + if (tmp) *tmp = '\0'; } /* post pending changes */ - log_update(mailbox, oldserver, thisserver); + log_update(mailbox, oldlocation, thislocation); msg = ISOK; done: - if(thisserver) free(thisserver); - if(oldserver) free(oldserver); + if (thislocation) free(thislocation); + if (oldlocation) free(oldlocation); free_mbent(m); pthread_mutex_unlock(&mailboxes_mutex); /* UNLOCK */ @@ -1705,22 +1724,34 @@ pthread_mutex_unlock(&mailboxes_mutex); /* UNLOCK */ if (m && m->t == SET_ACTIVE) { - prot_printf(C->pout, "%s MAILBOX {" SIZE_T_FMT "+}\r\n%s" - " {" SIZE_T_FMT "+}\r\n%s {" SIZE_T_FMT "+}\r\n%s\r\n", - tag, - strlen(m->mailbox), m->mailbox, - strlen(m->server), m->server, - strlen(m->acl), m->acl); + prot_printf(C->pout, + "%s MAILBOX " + "{" SIZE_T_FMT "+}\r\n%s " + "{" SIZE_T_FMT "+}\r\n%s " + "{" SIZE_T_FMT "+}\r\n%s\r\n", + tag, + strlen(m->mailbox), m->mailbox, + strlen(m->location), m->location, + strlen(m->acl), m->acl + ); + } else if (m && m->t == SET_RESERVE) { - prot_printf(C->pout, "%s RESERVE {" SIZE_T_FMT "+}\r\n%s" - " {" SIZE_T_FMT "+}\r\n%s\r\n", - tag, - strlen(m->mailbox), m->mailbox, - strlen(m->server), m->server); + prot_printf(C->pout, + "%s RESERVE " + "{" SIZE_T_FMT "+}\r\n%s " + "{" SIZE_T_FMT "+}\r\n%s\r\n", + tag, + strlen(m->mailbox), m->mailbox, + strlen(m->location), m->location + ); } else if (send_delete) { /* not found, if needed, send a delete */ - prot_printf(C->pout, "%s DELETE {" SIZE_T_FMT "+}\r\n%s\r\n", - tag, strlen(mailbox), mailbox); + prot_printf(C->pout, + "%s DELETE " + "{" SIZE_T_FMT "+}\r\n%s\r\n", + tag, + strlen(mailbox), mailbox + ); } free_mbent(m); @@ -1739,42 +1770,50 @@ { struct conn *C = (struct conn *)rock; struct mbent *m; - char *server = NULL; + char *location = NULL; - if(!C) return -1; + if (!C) return -1; m = database_lookup(name, NULL); - if(!m) return -1; + if (!m) return -1; - if(!C->list_prefix || - !strncmp(m->server, C->list_prefix, C->list_prefix_len)) { + if (!C->list_prefix || + !strncmp(m->location, C->list_prefix, C->list_prefix_len)) { /* Either there is not a prefix to test, or we matched it */ char *tmp; - if(C->streaming_hosts) { - server = xstrdup(m->server); - tmp = strchr(server, '!'); - if(tmp) *tmp = '\0'; + if (C->streaming_hosts) { + location = xstrdup(m->location); + tmp = strchr(location, '!'); + if (tmp) *tmp = '\0'; } - if(!C->streaming_hosts || - strarray_find(C->streaming_hosts, server, 0) >= 0) { + if (!C->streaming_hosts || + strarray_find(C->streaming_hosts, location, 0) >= 0) { switch (m->t) { case SET_ACTIVE: prot_printf(C->pout, - "%s MAILBOX {" SIZE_T_FMT "+}\r\n%s" - " {" SIZE_T_FMT "+}\r\n%s {" SIZE_T_FMT "+}\r\n%s\r\n", - C->streaming, - strlen(m->mailbox), m->mailbox, - strlen(m->server), m->server, - strlen(m->acl), m->acl); + "%s MAILBOX " + "{" SIZE_T_FMT "+}\r\n%s " + "{" SIZE_T_FMT "+}\r\n%s " + "{" SIZE_T_FMT "+}\r\n%s\r\n", + C->streaming, + strlen(m->mailbox), m->mailbox, + strlen(m->location), m->location, + strlen(m->acl), m->acl + ); + break; case SET_RESERVE: - prot_printf(C->pout, "%s RESERVE {" SIZE_T_FMT "+}\r\n%s" - " {" SIZE_T_FMT "+}\r\n%s\r\n", - C->streaming, - strlen(m->mailbox), m->mailbox, - strlen(m->server), m->server); + prot_printf(C->pout, + "%s RESERVE " + "{" SIZE_T_FMT "+}\r\n%s " + "{" SIZE_T_FMT "+}\r\n%s\r\n", + C->streaming, + strlen(m->mailbox), m->mailbox, + strlen(m->location), m->location + ); + break; case SET_DELETE: @@ -1786,7 +1825,7 @@ } } - if(server) free(server); + if (location) free(location); free_mbent(m); return 0; } @@ -1805,7 +1844,7 @@ /* since this isn't valid when streaming, just use the same callback */ C->streaming = tag; C->list_prefix = host_prefix; - if(C->list_prefix) C->list_prefix_len = strlen(C->list_prefix); + if (C->list_prefix) C->list_prefix_len = strlen(C->list_prefix); else C->list_prefix_len = 0; mboxlist_findall(NULL, pattern, 1, NULL, @@ -1964,11 +2003,11 @@ if (result != SASL_OK) { fatal("sasl_setprop() failed: cmd_starttls()", EC_TEMPFAIL); } - if(C->saslprops.authid) { + if (C->saslprops.authid) { free(C->saslprops.authid); C->saslprops.authid = NULL; } - if(auth_id) + if (auth_id) C->saslprops.authid = xstrdup(auth_id); /* tell the prot layer about our new layers */ @@ -2053,32 +2092,32 @@ ret = sasl_server_new("mupdate", config_servername, NULL, NULL, NULL, NULL, 0, &c->saslconn); - if(ret != SASL_OK) return ret; + if (ret != SASL_OK) return ret; - if(c->saslprops.ipremoteport) + if (c->saslprops.ipremoteport) ret = sasl_setprop(c->saslconn, SASL_IPREMOTEPORT, c->saslprops.ipremoteport); - if(ret != SASL_OK) return ret; + if (ret != SASL_OK) return ret; - if(c->saslprops.iplocalport) + if (c->saslprops.iplocalport) ret = sasl_setprop(c->saslconn, SASL_IPLOCALPORT, c->saslprops.iplocalport); - if(ret != SASL_OK) return ret; + if (ret != SASL_OK) return ret; secprops = mysasl_secprops(SASL_SEC_NOANONYMOUS); ret = sasl_setprop(c->saslconn, SASL_SEC_PROPS, secprops); - if(ret != SASL_OK) return ret; + if (ret != SASL_OK) return ret; /* end of service_main initialization excepting SSF */ /* If we have TLS/SSL info, set it */ - if(c->saslprops.ssf) { + if (c->saslprops.ssf) { ret = sasl_setprop(c->saslconn, SASL_SSF_EXTERNAL, &c->saslprops.ssf); } - if(ret != SASL_OK) return ret; + if (ret != SASL_OK) return ret; - if(c->saslprops.authid) { + if (c->saslprops.authid) { ret = sasl_setprop(c->saslconn, SASL_AUTH_EXTERNAL, c->saslprops.authid); - if(ret != SASL_OK) return ret; + if (ret != SASL_OK) return ret; } /* End TLS/SSL Info */ @@ -2089,20 +2128,20 @@ const char *rock, void *context __attribute__((unused))) { struct mbent *m = NULL; - char *oldserver = NULL; - char *thisserver = NULL; + char *oldlocation = NULL; + char *thislocation = NULL; char *tmp; enum settype t = -1; int ret = 0; - if(!mdata || !rock || !mdata->mailbox) return 1; + if (!mdata || !rock || !mdata->mailbox) return 1; pthread_mutex_lock(&mailboxes_mutex); /* LOCK */ - if(!strncmp(rock, "DELETE", 6)) { + if (!strncmp(rock, "DELETE", 6)) { m = database_lookup(mdata->mailbox, NULL); - if(!m) { + if (!m) { syslog(LOG_DEBUG, "attempt to delete unknown mailbox %s", mdata->mailbox); /* Mailbox doesn't exist - this isn't as fatal as you might @@ -2112,24 +2151,24 @@ } m->t = t = SET_DELETE; - oldserver = xstrdup(m->server); + oldlocation = xstrdup(m->location); } else { m = database_lookup(mdata->mailbox, NULL); - if(m) - oldserver = m->server; + if (m) + oldlocation = m->location; if (m && (!mdata->acl || strlen(mdata->acl) < strlen(m->acl))) { /* change what's already there */ - /* old m->server freed when oldserver is freed */ - m->server = xstrdup(mdata->server); + /* old m->location freed when oldlocation is freed */ + m->location = xstrdup(mdata->location); if (mdata->acl) strcpy(m->acl, mdata->acl); else m->acl[0] = '\0'; - if(!strncmp(rock, "MAILBOX", 6)) { + if (!strncmp(rock, "MAILBOX", 6)) { m->t = t = SET_ACTIVE; - } else if(!strncmp(rock, "RESERVE", 7)) { + } else if (!strncmp(rock, "RESERVE", 7)) { m->t = t = SET_RESERVE; } else { syslog(LOG_DEBUG, @@ -2140,9 +2179,9 @@ } else { struct mbent *newm; - if(m) { + if (m) { free(m->mailbox); - /* m->server freed when oldserver freed */ + /* m->location freed when oldlocation freed */ } /* allocate new mailbox */ @@ -2153,7 +2192,7 @@ } newm->mailbox = xstrdup(mdata->mailbox); - newm->server = xstrdup(mdata->server); + newm->location = xstrdup(mdata->location); if (mdata->acl) { strcpy(newm->acl, mdata->acl); @@ -2161,9 +2200,9 @@ newm->acl[0] = '\0'; } - if(!strncmp(rock, "MAILBOX", 6)) { + if (!strncmp(rock, "MAILBOX", 6)) { newm->t = t = SET_ACTIVE; - } else if(!strncmp(rock, "RESERVE", 7)) { + } else if (!strncmp(rock, "RESERVE", 7)) { newm->t = t = SET_RESERVE; } else { syslog(LOG_DEBUG, @@ -2180,23 +2219,23 @@ /* write to disk */ database_log(m, NULL); - if(oldserver) { - tmp = strchr(oldserver, '!'); - if(tmp) *tmp = '\0'; + if (oldlocation) { + tmp = strchr(oldlocation, '!'); + if (tmp) *tmp = '\0'; } - if(mdata->server) { - thisserver = xstrdup(mdata->server); - tmp = strchr(thisserver, '!'); - if(tmp) *tmp = '\0'; + if (mdata->location) { + thislocation = xstrdup(mdata->location); + tmp = strchr(thislocation, '!'); + if (tmp) *tmp = '\0'; } /* post pending changes to anyone we are talking to */ - log_update(mdata->mailbox, oldserver, thisserver); + log_update(mdata->mailbox, oldlocation, thislocation); done: - if(oldserver) free(oldserver); - if(thisserver) free(thisserver); + if (oldlocation) free(oldlocation); + if (thislocation) free(thislocation); free_mbent(m); pthread_mutex_unlock(&mailboxes_mutex); /* UNLOCK */ @@ -2219,7 +2258,7 @@ struct mbent_queue *remote_boxes = r->boxes; struct mbent *newm = NULL; - if(!mdata || !rock || !mdata->mailbox || !remote_boxes) return 1; + if (!mdata || !rock || !mdata->mailbox || !remote_boxes) return 1; /* allocate new mailbox */ if (mdata->acl) { @@ -2229,7 +2268,7 @@ } newm->mailbox = mpool_strdup(r->pool, mdata->mailbox); - newm->server = mpool_strdup(r->pool, mdata->server); + newm->location = mpool_strdup(r->pool, mdata->location); if (mdata->acl) { strcpy(newm->acl, mdata->acl); @@ -2237,9 +2276,9 @@ newm->acl[0] = '\0'; } - if(!strncmp(rock, "MAILBOX", 6)) { + if (!strncmp(rock, "MAILBOX", 6)) { newm->t = SET_ACTIVE; - } else if(!strncmp(rock, "RESERVE", 7)) { + } else if (!strncmp(rock, "RESERVE", 7)) { newm->t = SET_RESERVE; } else { syslog(LOG_NOTICE, @@ -2265,11 +2304,11 @@ struct mbent_queue *local_boxes = (struct mbent_queue *)r->boxes; struct mbent *m; - if(!local_boxes) return 1; + if (!local_boxes) return 1; m = database_lookup(name, r->pool); /* If it doesn't exist, fine... */ - if(!m) return 0; + if (!m) return 0; m->next = NULL; *(local_boxes->tail) = m; @@ -2284,7 +2323,7 @@ { struct sync_rock rock; - if(!handle || !handle->saslcompleted) return 1; + if (!handle || !handle->saslcompleted) return 1; rock.pool = pool; @@ -2324,6 +2363,7 @@ struct txn *tid = NULL; int ret = 0; int err = 0; + char *c; rock.pool = pool; @@ -2343,7 +2383,7 @@ NULL, sync_findall_cb, (void*)&rock); /* Traverse both lists, compare the names */ - /* If they match, ensure that server and acl are correct, if so, + /* If they match, ensure that location and acl are correct, if so, move on, if not, fix them */ /* If the local is before the next remote, delete it */ /* If the next remote is before theis local, insert it and try again */ @@ -2351,10 +2391,10 @@ l = local_boxes.head, r = remote_boxes->head) { int ret = strcmp(l->mailbox, r->mailbox); - if(!ret) { + if (!ret) { /* Match */ - if(l->t != r->t || - strcmp(l->server, r->server) || + if (l->t != r->t || + strcmp(l->location, r->location) || strcmp(l->acl,r->acl)) { /* Something didn't match, replace it */ /* @@ -2362,7 +2402,7 @@ * change, just warn. */ if ((config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_UNIFIED) && - (strchr( l->server, '!' ) == NULL )) { + (strchr( l->location, '!' ) == NULL )) { syslog(LOG_ERR, "local mailbox %s wrong in mailbox list", l->mailbox ); err++; @@ -2370,7 +2410,14 @@ mbentry_t *mbentry = mboxlist_entry_create(); mbentry->name = xstrdupnull(r->mailbox); mbentry->mbtype = (r->t == SET_RESERVE ? MBTYPE_RESERVE : 0); - mbentry->server = xstrdupnull(r->server); + mbentry->server = xstrdupnull(r->location); + + c = strchr(mbentry->server, '!'); + if (c) { + *c++ = '\0'; + mbentry->partition = xstrdupnull(c); + } + mbentry->acl = xstrdupnull(r->acl); mboxlist_insertremote(mbentry, &tid); mboxlist_entry_free(&mbentry); @@ -2389,12 +2436,12 @@ * ctl_mboxlist is the right place to fix the kind * of configuration error implied. * - * A similar problem exists when the server thinks + * A similar problem exists when the location thinks * it is locally hosting a mailbox, but mupdate master * thinks it's somewhere else. */ if ((config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_UNIFIED) && - (strchr( l->server, '!' ) == NULL )) { + (strchr( l->location, '!' ) == NULL )) { syslog(LOG_ERR, "local mailbox %s not in mailbox list", l->mailbox ); err++; @@ -2407,7 +2454,14 @@ mbentry_t *mbentry = mboxlist_entry_create(); mbentry->name = xstrdupnull(r->mailbox); mbentry->mbtype = (r->t == SET_RESERVE ? MBTYPE_RESERVE : 0); - mbentry->server = xstrdupnull(r->server); + mbentry->server = xstrdupnull(r->location); + + c = strchr(mbentry->server, '!'); + if (c) { + *c++ = '\0'; + mbentry->partition = xstrdupnull(c); + } + mbentry->acl = xstrdupnull(r->acl); mboxlist_insertremote(mbentry, &tid); mboxlist_entry_free(&mbentry); @@ -2415,11 +2469,11 @@ } } - if(l && !r) { + if (l && !r) { /* we have more deletes to do */ while(l) { if ((config_mupdate_config == IMAP_ENUM_MUPDATE_CONFIG_UNIFIED) && - (strchr( l->server, '!' ) == NULL )) { + (strchr( l->location, '!' ) == NULL )) { syslog(LOG_ERR, "local mailbox %s not in mailbox list", l->mailbox ); err++; @@ -2435,7 +2489,14 @@ mbentry_t *mbentry = mboxlist_entry_create(); mbentry->name = xstrdupnull(r->mailbox); mbentry->mbtype = (r->t == SET_RESERVE ? MBTYPE_RESERVE : 0); - mbentry->server = xstrdupnull(r->server); + mbentry->server = xstrdupnull(r->location); + + c = strchr(mbentry->server, '!'); + if (c) { + *c++ = '\0'; + mbentry->partition = xstrdupnull(c); + } + mbentry->acl = xstrdupnull(r->acl); mboxlist_insertremote(mbentry, &tid); mboxlist_entry_free(&mbentry); @@ -2470,7 +2531,7 @@ { pthread_mutex_lock(&ready_for_connections_mutex); - if(ready_for_connections) { + if (ready_for_connections) { syslog(LOG_CRIT, "mupdate_ready called when already ready"); fatal("mupdate_ready called when already ready", EC_TEMPFAIL); } @@ -2496,8 +2557,8 @@ /* Used to free malloc'd mbent's (not for mpool'd mbents) */ void free_mbent(struct mbent *p) { - if(!p) return; - free(p->server); + if (!p) return; + free(p->location); free(p->mailbox); free(p); }
View file
cyrus-imapd-2.5.tar.gz/imap/mupdate.h
Changed
@@ -70,7 +70,7 @@ /* For client side mupdate_find calls */ char mailbox_buf[MAX_MAILBOX_BUFFER]; - char server_buf[MAX_MAILBOX_BUFFER]; + char location_buf[MAX_MAILBOX_BUFFER]; char *acl; struct mupdate_mailboxdata mailboxdata_buf; @@ -88,7 +88,7 @@ /* acl MUST be last, since it is what causes the variable size */ struct mbent { char *mailbox; - char *server; + char *location; enum settype t; struct mbent *next; /* used for queue */ char acl[1];
View file
cyrus-imapd.sysconfig
Changed
@@ -7,7 +7,7 @@ # In RPM install / update / upgrade %post, make sure all files in # Cyrus (meta-)partitions and configuration directories are set +S -CHATTRSYNC=1 +CHATTRSYNC=0 # Mailbox list dumps are rotated n times via cron.daily #ROTATE=6
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
.