From b48001d0e96ad798a5ecb8a9f311f2ac75c800bf Mon Sep 17 00:00:00 2001 From: Ken Murchison Date: Tue, 19 Mar 2024 01:50:50 -0400 Subject: [PATCH] imapd.c: add support for JMAPACCESS response code --- changes/next/imap_jmapaccess | 19 +++++++++++++++++++ docsrc/imap/rfc-support.rst | 8 ++++++-- imap/imapd.c | 11 ++++++++++- lib/imapoptions | 5 +++++ 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 changes/next/imap_jmapaccess diff --git a/changes/next/imap_jmapaccess b/changes/next/imap_jmapaccess new file mode 100644 index 0000000000..1b6a27a1d6 --- /dev/null +++ b/changes/next/imap_jmapaccess @@ -0,0 +1,19 @@ + +Description: + +Adds support for IMAP JMAPACCESS response code (draft-ietf-extra-jmapaccess). + + +Config changes: + +Adds jmapaccess_url option. + + +Upgrade instructions: + +None. + + +GitHub issue: + +None. diff --git a/docsrc/imap/rfc-support.rst b/docsrc/imap/rfc-support.rst index fb82ccc4ea..416cde263f 100644 --- a/docsrc/imap/rfc-support.rst +++ b/docsrc/imap/rfc-support.rst @@ -908,6 +908,10 @@ The following is an inventory of RFCs supported by Cyrus IMAP. IMAP4 Extension: Message Preview Generation +:rfc:`9042` + + Sieve Email Filtering: Delivery by MAILBOXID + :rfc:`9051` Internet Message Access Protocol (IMAP) - version 4rev2 @@ -931,9 +935,9 @@ draft-ietf-extra-imap-inprogress IMAP4 Response Code for Command Progress Notifications -draft-ietf-extra-sieve-mailboxid +draft-ietf-extra-jmapaccess - Sieve Email Filtering: delivery by mailboxid + The JMAPACCESS Extension for IMAP draft-ietf-extra-sieve-snooze diff --git a/imap/imapd.c b/imap/imapd.c index 4220d2e386..6cf61b4cc3 100644 --- a/imap/imapd.c +++ b/imap/imapd.c @@ -202,6 +202,7 @@ static int imapd_starttls_done = 0; /* have we done a successful starttls? */ static int imapd_tls_required = 0; /* is tls required? */ static void *imapd_tls_comp = NULL; /* TLS compression method, if any */ static int imapd_compress_done = 0; /* have we done a successful compress? */ +static const char *imapd_jmapaccess_url = NULL; static const char *plaintextloginalert = NULL; static int ignorequota = 0; static int sync_sieve_mailbox_enabled = 0; @@ -416,7 +417,7 @@ static struct capa_struct base_capabilities[] = { { .statep = &imapd_idle_enabled } }, { "IMAPSIEVE=", 0, /* not implemented */ { 0 } }, /* RFC 6785 */ { "INPROGRESS", CAPA_POSTAUTH, { 0 } }, /* draft-ietf-extra-imap-inprogress */ - { "JMAPACCESS", 0, /* not implemented */ { 0 } }, /* draft-ietf-extra-jmapaccess */ + { "JMAPACCESS", 0, /* just a respcode */ { 0 } }, /* draft-ietf-extra-jmapaccess */ { "LANGUAGE", 0, /* not implemented */ { 0 } }, /* RFC 5255 */ { "LIST-EXTENDED", CAPA_POSTAUTH, { 0 } }, /* RFC 5258 */ { "LIST-METADATA", CAPA_POSTAUTH, { 0 } }, /* draft-ietf-extra-imap-list-metadata */ @@ -1076,6 +1077,8 @@ int service_init(int argc, char **argv, char **envp) imapd_compress_allowed = 1; #endif + imapd_jmapaccess_url = config_getstring(IMAPOPT_JMAPACCESS_URL); + /* setup for sending IMAP IDLE/NOTIFY notifications */ if ((imapd_idle_enabled = idle_enabled())) { idle_sock = idle_init(); @@ -2918,6 +2921,12 @@ static void authentication_success(const char *tag, int ssf, const char *reply) /* authstate already created by mysasl_proxy_policy() */ imapd_userisadmin = global_authisa(imapd_authstate, IMAPOPT_ADMINS); + if (imapd_jmapaccess_url) { + prot_printf(imapd_out, "* OK [JMAPACCESS \"%s\"] %s\r\n", + imapd_jmapaccess_url, + "This server is also accessible via JMAP, see RFC8620"); + } + prot_printf(imapd_out, "%s OK", tag); if (!ssf) { prot_puts(imapd_out, " [CAPABILITY"); diff --git a/lib/imapoptions b/lib/imapoptions index 000e7bb442..61a7085325 100644 --- a/lib/imapoptions +++ b/lib/imapoptions @@ -1230,6 +1230,11 @@ Blank lines and lines beginning with ``#'' are ignored. the same has to be done (cyr_dbtool) for each subscription database See improved_mboxlist_sort.html.*/ +{ "jmapaccess_url", NULL, STRING, "UNRELEASED" } +/* The JMAP Session URL to advertise to sucessfully authenticated IMAP clients, + if the same credentials can be used to authenticate via JMAP + (see draft-ietf-extra-jmapaccess). */ + { "jmap_emailsearch_db_path", NULL, STRING, "3.1.6", "3.6.0" } /* The absolute path to the JMAP email search cache file. If not specified, JMAP Email/query and Email/queryChanges will not