cyrus-imapd30: integrated patch to enable CalDAV/CardDAV auto-discovery for shared resources

This commit is contained in:
Matthias Petermann 2020-03-18 22:44:10 +01:00
parent 558dfecee8
commit deb96029de
4 changed files with 99 additions and 4 deletions

View File

@ -1,7 +1,7 @@
# $NetBSD: $
DISTNAME= cyrus-imapd-3.0.13
REVISION= 1
REVISION= 2
CATEGORIES= mail
MASTER_SITES= ${MASTER_SITE_GITHUB:=cyrusimap/}
GITHUB_RELEASE= ${PKGNAME_NOREV}

View File

@ -23,15 +23,27 @@ Done:
- Integrated documentation from source package into the package
- Possibly create further patches for cyrus-imap 3 (especially with
regard to the newly added functions CalDAV / CardDAV), if necessary
Next steps:
- regenerate documentation at build time using Sphinx
- Possibly create further patches for cyrus-imap 3 (especially with
regard to the newly added functions CalDAV / CardDAV), if necessary
Bugs:
- The way how the Dav-Patch is integrated. It is not a security patch
nor a patch that would be necessary to ensure the build.
In principle, it eliminates a functional deficiency, which may
not be a deficiency at all, but simply an implementation gap.
pkgsrc is therefore not the right place to deal with this problem,
I'm almost sure of that. Without this patch, the CalDAV / CardDAV
functionality cannot be used meaningfully for me, and in my
experience it will also be for most other users who want to
maintain a shared calendar, for example. I will definitely keep
an eye on what is going on upstream. In the meantime, I would like
to keep the patch here if there are no important reasons why.
- Kerberos support, PostgreSQL and MySQL are currently not tested
For questions, tips or offers of help you can contact me at mp@petermann-it.de

View File

@ -4,3 +4,4 @@ SHA1 (cyrus-imapd-3.0.13.tar.gz) = 69d29e09ae4e4f3c8ae0c49a1024b7ec4dffbf57
RMD160 (cyrus-imapd-3.0.13.tar.gz) = b789c903620e83160fce4de3e06bbe0c842f7957
SHA512 (cyrus-imapd-3.0.13.tar.gz) = 5cd066916797efb975cdb97720f65edc72d3fe82afbd78a26aa8369d95ae4ca09c0593dd4bec5521156c64ea38af7a13065f3b35447a76267dec93feb0ac6ac6
Size (cyrus-imapd-3.0.13.tar.gz) = 10840005 bytes
SHA1 (patch-imap_http__dav.c) = dfbac5c379dce8977b28376692b8de7621caeca3

View File

@ -0,0 +1,82 @@
$NetBSD$
The CalDAV / CardDAV functionality of Cyrus IMAP supports the
auto-discovery mechanism, which is used by many clients to find out
the calendars and address books available for the respective user.
At the moment this does not work for shared calendars and address
books from other users.
There was a discussion on this topic on Github:
https://github.com/cyrusimap/cyrus-imapd/issues/2373
As part of the discussion, Дилян Палаузов provided a patch that
solves this problem. Unfortunately, it has not yet been included
in an official release because it may not yet be the complete solution
that covers all scenarios.
Anyway - the patch is included here because, in my opinion, sharing
calendars and address books is an essential functionality of a
groupware. Without this patch, this will not work on clients that only
offer auto-discovery - i.e. most mobile devices.
--- imap/http_dav.c.orig 2020-03-18 20:29:25.102243914 +0000
+++ imap/http_dav.c
@@ -5455,7 +5455,7 @@ int propfind_by_collection(const mbentry
if (!fctx->req_tgt->resource) {
len = make_collection_url(&writebuf, fctx->req_tgt->namespace->prefix,
- mboxname, fctx->req_tgt->userid, NULL);
+ mboxname, mbname_userid(mbname_from_intname(mboxname)), NULL);
/* copy it all back into place... in theory we should check against
* 'last' and make sure it doesn't change from the original request.
@@ -5483,6 +5483,12 @@ int propfind_by_collection(const mbentry
return r;
}
+static int wrapper_propfind_by_collection(struct findall_data *data, void* rock) {
+ if (!data || !data->mbentry) return 0;
+ struct propfind_ctx *fctx = (struct propfind_ctx *) rock;
+ if ((httpd_myrights(httpd_authstate, data->mbentry) & DACL_READ != DACL_READ)) return 0;
+ return propfind_by_collection(data->mbentry, fctx);
+}
/* Perform a PROPFIND request */
EXPORTED int meth_propfind(struct transaction_t *txn, void *params)
@@ -5746,12 +5752,13 @@ EXPORTED int meth_propfind(struct transa
else if (txn->req_tgt.mbentry) {
/* Add responses for all contained collections */
fctx.prefer &= ~PREFER_NOROOT;
- mboxlist_mboxtree(txn->req_tgt.mbentry->name,
- propfind_by_collection, &fctx,
- MBOXTREE_SKIP_ROOT);
switch (txn->req_tgt.namespace->id) {
case URL_NS_DRIVE:
+ mboxlist_mboxtree(txn->req_tgt.mbentry->name,
+ propfind_by_collection, &fctx,
+ MBOXTREE_SKIP_ROOT);
+
if (txn->req_tgt.flags == TGT_DRIVE_ROOT) {
/* Add a response for 'user' hierarchy */
buf_setcstr(&fctx.buf, txn->req_tgt.namespace->prefix);
@@ -5772,11 +5779,16 @@ EXPORTED int meth_propfind(struct transa
/* Fall through */
case URL_NS_ADDRESSBOOK:
+ {
/* Add responses for shared collections */
- mboxlist_usersubs(txn->req_tgt.userid,
- propfind_by_collection, &fctx,
- MBOXTREE_SKIP_PERSONAL);
+ const char *conf_str = txn->req_tgt.namespace->id == URL_NS_CALENDAR ?
+ config_getstring(IMAPOPT_CALENDARPREFIX) : config_getstring(IMAPOPT_ADDRESSBOOKPREFIX);
+ char *pat = malloc(5 + strlen(conf_str));
+ sprintf(pat, "*%s%c*", conf_str, httpd_namespace.hier_sep);
+ mboxlist_findall(&httpd_namespace, pat, httpd_userisadmin, txn->req_tgt.userid, httpd_authstate, wrapper_propfind_by_collection, &fctx);
+ free(pat);
break;
+ }
}
}