dovecot-1.2: Added support for IMAP ID extension.
dovecot at dovecot.org
dovecot at dovecot.org
Sat Jun 21 09:25:49 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/ca2ff54ee9b4
changeset: 7917:ca2ff54ee9b4
user: Timo Sirainen <tss at iki.fi>
date: Sat Jun 21 09:22:44 2008 +0300
description:
Added support for IMAP ID extension.
diffstat:
20 files changed, 273 insertions(+), 3 deletions(-)
README | 1
configure.in | 8 +
dovecot-example.conf | 8 +
src/imap-login/client.c | 26 +++++
src/imap-login/client.h | 1
src/imap/Makefile.am | 1
src/imap/client.h | 1
src/imap/cmd-id.c | 26 +++++
src/imap/commands.c | 1
src/imap/commands.h | 1
src/imap/common.h | 1
src/imap/main.c | 4
src/lib-imap/Makefile.am | 2
src/lib-imap/imap-id.c | 174 +++++++++++++++++++++++++++++++++++++
src/lib-imap/imap-id.h | 11 ++
src/master/login-process.c | 2
src/master/mail-process.c | 2
src/master/master-settings-defs.c | 2
src/master/master-settings.c | 2
src/master/master-settings.h | 2
diffs (truncated from 507 to 300 lines):
diff -r 8f3115354d14 -r ca2ff54ee9b4 README
--- a/README Sat Jun 21 09:21:51 2008 +0300
+++ b/README Sat Jun 21 09:22:44 2008 +0300
@@ -31,6 +31,7 @@ RFCs conformed
2177 - IMAP4 IDLE command
2221 - IMAP4 Login Referrals
2342 - IMAP4 Namespace
+ 2971 - IMAP4 ID extension
3348 - IMAP4 Child Mailbox Extension
3502 - IMAP4 MULTIAPPEND Extension
3691 - IMAP4 UNSELECT command
diff -r 8f3115354d14 -r ca2ff54ee9b4 configure.in
--- a/configure.in Sat Jun 21 09:21:51 2008 +0300
+++ b/configure.in Sat Jun 21 09:22:44 2008 +0300
@@ -19,7 +19,7 @@ AC_CHECK_HEADERS(strings.h stdint.h unis
sys/uio.h sys/sysmacros.h sys/resource.h sys/select.h libgen.h \
sys/quota.h sys/fs/ufs_quota.h ufs/ufs/quota.h jfs/quota.h sys/fs/quota_common.h \
mntent.h sys/mnttab.h sys/event.h sys/time.h sys/mkdev.h linux/dqblk_xfs.h \
- xfs/xqm.h sasl.h sasl/sasl.h execinfo.h ucontext.h malloc_np.h)
+ xfs/xqm.h sasl.h sasl/sasl.h execinfo.h ucontext.h malloc_np.h sys/utsname.h)
AC_ARG_ENABLE(ipv6,
[ --enable-ipv6 Enable IPv6 support (auto)],
@@ -425,9 +425,11 @@ AC_CHECK_LIB(cap, cap_init, [
])
AC_SUBST(LIBCAP)
+AC_DEFINE(PACKAGE_WEBPAGE, "http://www.dovecot.org/", Support URL)
+
dnl * after -lsocket and -lnsl tests, inet_aton() may be in them
AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \
- strcasecmp stricmp vsyslog writev pread \
+ strcasecmp stricmp vsyslog writev pread uname \
setrlimit setproctitle seteuid setreuid setegid setresgid \
strtoull strtoll strtouq strtoq \
setpriority quotactl getmntent kqueue kevent backtrace_symbols \
@@ -2183,7 +2185,7 @@ dnl ** capabilities
dnl ** capabilities
dnl **
-capability="IMAP4rev1 SASL-IR SORT THREAD=REFERENCES MULTIAPPEND UNSELECT LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS UIDPLUS LIST-EXTENDED I18NLEVEL=1 ENABLE CONDSTORE QRESYNC ESEARCH SEARCHRES WITHIN CONTEXT=SEARCH"
+capability="IMAP4rev1 SASL-IR SORT THREAD=REFERENCES MULTIAPPEND UNSELECT LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS UIDPLUS LIST-EXTENDED I18NLEVEL=1 ENABLE CONDSTORE QRESYNC ESEARCH SEARCHRES WITHIN CONTEXT=SEARCH ID"
AC_DEFINE_UNQUOTED(CAPABILITY_STRING, "$capability", IMAP capabilities)
CFLAGS="$CFLAGS $EXTRA_CFLAGS"
diff -r 8f3115354d14 -r ca2ff54ee9b4 dovecot-example.conf
--- a/dovecot-example.conf Sat Jun 21 09:21:51 2008 +0300
+++ b/dovecot-example.conf Sat Jun 21 09:22:44 2008 +0300
@@ -543,6 +543,14 @@ protocol imap {
# Override the IMAP CAPABILITY response.
#imap_capability =
+
+ # ID field names and values to send to clients. Using * as the value makes
+ # Dovecot use the default value. The following fields have default values
+ # currently: name, version, os, os-version, support-url, support-email.
+ #imap_id_send =
+
+ # ID fields sent by client to log. * means everything.
+ #imap_id_log =
# Workarounds for various client bugs:
# delay-newmail:
diff -r 8f3115354d14 -r ca2ff54ee9b4 src/imap-login/client.c
--- a/src/imap-login/client.c Sat Jun 21 09:21:51 2008 +0300
+++ b/src/imap-login/client.c Sat Jun 21 09:22:44 2008 +0300
@@ -10,11 +10,14 @@
#include "str.h"
#include "strescape.h"
#include "imap-parser.h"
+#include "imap-id.h"
#include "client.h"
#include "client-authenticate.h"
#include "auth-client.h"
#include "ssl-proxy.h"
#include "imap-proxy.h"
+
+#include <stdlib.h>
/* max. size of one parameter in line, or max reply length in SASL
authentication */
@@ -194,6 +197,27 @@ static int cmd_starttls(struct imap_clie
} else {
client_start_tls(client);
}
+ return 1;
+}
+
+static int cmd_id(struct imap_client *client, const struct imap_arg *args)
+{
+ const char *env, *value;
+
+ if (!client->id_logged) {
+ client->id_logged = TRUE;
+ env = getenv("IMAP_ID_LOG");
+ value = imap_id_args_get_log_reply(args, env);
+ if (value != NULL) {
+ client_syslog(&client->common,
+ t_strdup_printf("ID sent: %s", value));
+ }
+ }
+
+ env = getenv("IMAP_ID_SEND");
+ client_send_line(client, t_strdup_printf("* ID %s",
+ imap_id_reply_generate(env)));
+ client_send_tagline(client, "OK ID completed.");
return 1;
}
@@ -228,6 +252,8 @@ static int client_command_execute(struct
return cmd_capability(client);
if (strcmp(cmd, "STARTTLS") == 0)
return cmd_starttls(client);
+ if (strcmp(cmd, "ID") == 0)
+ return cmd_id(client, args);
if (strcmp(cmd, "NOOP") == 0)
return cmd_noop(client);
if (strcmp(cmd, "LOGOUT") == 0)
diff -r 8f3115354d14 -r ca2ff54ee9b4 src/imap-login/client.h
--- a/src/imap-login/client.h Sat Jun 21 09:21:51 2008 +0300
+++ b/src/imap-login/client.h Sat Jun 21 09:22:44 2008 +0300
@@ -31,6 +31,7 @@ struct imap_client {
unsigned int input_blocked:1;
unsigned int destroyed:1;
unsigned int greeting_sent:1;
+ unsigned int id_logged:1;
};
void client_destroy(struct imap_client *client, const char *reason);
diff -r 8f3115354d14 -r ca2ff54ee9b4 src/imap/Makefile.am
--- a/src/imap/Makefile.am Sat Jun 21 09:21:51 2008 +0300
+++ b/src/imap/Makefile.am Sat Jun 21 09:22:44 2008 +0300
@@ -49,6 +49,7 @@ cmds = \
cmd-examine.c \
cmd-expunge.c \
cmd-fetch.c \
+ cmd-id.c \
cmd-idle.c \
cmd-list.c \
cmd-logout.c \
diff -r 8f3115354d14 -r ca2ff54ee9b4 src/imap/client.h
--- a/src/imap/client.h Sat Jun 21 09:21:51 2008 +0300
+++ b/src/imap/client.h Sat Jun 21 09:22:44 2008 +0300
@@ -115,6 +115,7 @@ struct client {
unsigned int destroyed:1;
unsigned int handling_input:1;
unsigned int syncing:1;
+ unsigned int id_logged:1;
unsigned int input_skip_line:1; /* skip all the data until we've
found a new line */
unsigned int modseqs_sent_since_sync:1;
diff -r 8f3115354d14 -r ca2ff54ee9b4 src/imap/cmd-id.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/imap/cmd-id.c Sat Jun 21 09:22:44 2008 +0300
@@ -0,0 +1,26 @@
+/* Copyright (c) 2008 Dovecot authors, see the included COPYING file */
+
+#include "common.h"
+#include "imap-id.h"
+
+bool cmd_id(struct client_command_context *cmd)
+{
+ const struct imap_arg *args;
+ const char *value;
+
+ if (!client_read_args(cmd, 0, 0, &args))
+ return FALSE;
+
+ if (!cmd->client->id_logged) {
+ cmd->client->id_logged = TRUE;
+ value = imap_id_args_get_log_reply(args, imap_id_log);
+ if (value != NULL)
+ i_info("ID sent: %s", value);
+ }
+
+ client_send_line(cmd->client, t_strdup_printf(
+ "* ID %s", imap_id_reply_generate(imap_id_send)));
+ client_send_tagline(cmd, "OK ID completed.");
+ return TRUE;
+}
+
diff -r 8f3115354d14 -r ca2ff54ee9b4 src/imap/commands.c
--- a/src/imap/commands.c Sat Jun 21 09:21:51 2008 +0300
+++ b/src/imap/commands.c Sat Jun 21 09:22:44 2008 +0300
@@ -43,6 +43,7 @@ const struct command imap_ext_commands[]
const struct command imap_ext_commands[] = {
{ "CANCELUPDATE", cmd_cancelupdate,0 },
{ "ENABLE", cmd_enable, 0 },
+ { "ID", cmd_id, 0 },
{ "IDLE", cmd_idle, COMMAND_FLAG_BREAKS_SEQS },
{ "NAMESPACE", cmd_namespace, 0 },
{ "SORT", cmd_sort, COMMAND_FLAG_USES_SEQS },
diff -r 8f3115354d14 -r ca2ff54ee9b4 src/imap/commands.h
--- a/src/imap/commands.h Sat Jun 21 09:21:51 2008 +0300
+++ b/src/imap/commands.h Sat Jun 21 09:22:44 2008 +0300
@@ -83,6 +83,7 @@ bool cmd_uid(struct client_command_conte
/* IMAP extensions: */
bool cmd_cancelupdate(struct client_command_context *cmd);
bool cmd_enable(struct client_command_context *cmd);
+bool cmd_id(struct client_command_context *cmd);
bool cmd_idle(struct client_command_context *cmd);
bool cmd_namespace(struct client_command_context *cmd);
bool cmd_sort(struct client_command_context *cmd);
diff -r 8f3115354d14 -r ca2ff54ee9b4 src/imap/common.h
--- a/src/imap/common.h Sat Jun 21 09:21:51 2008 +0300
+++ b/src/imap/common.h Sat Jun 21 09:22:44 2008 +0300
@@ -31,6 +31,7 @@ extern unsigned int imap_max_line_length
extern unsigned int imap_max_line_length;
extern enum client_workarounds client_workarounds;
extern const char *logout_format;
+extern const char *imap_id_send, *imap_id_log;
extern string_t *capability_string;
diff -r 8f3115354d14 -r ca2ff54ee9b4 src/imap/main.c
--- a/src/imap/main.c Sat Jun 21 09:21:51 2008 +0300
+++ b/src/imap/main.c Sat Jun 21 09:22:44 2008 +0300
@@ -41,6 +41,7 @@ unsigned int imap_max_line_length;
unsigned int imap_max_line_length;
enum client_workarounds client_workarounds = 0;
const char *logout_format;
+const char *imap_id_send, *imap_id_log;
static struct io *log_io = NULL;
static struct module *modules = NULL;
@@ -227,6 +228,9 @@ static void main_init(void)
if (logout_format == NULL)
logout_format = "bytes=%i/%o";
+ imap_id_send = getenv("IMAP_ID_SEND");
+ imap_id_log = getenv("IMAP_ID_LOG");
+
parse_workarounds();
namespace_pool = pool_alloconly_create("namespaces", 1024);
diff -r 8f3115354d14 -r ca2ff54ee9b4 src/lib-imap/Makefile.am
--- a/src/lib-imap/Makefile.am Sat Jun 21 09:21:51 2008 +0300
+++ b/src/lib-imap/Makefile.am Sat Jun 21 09:22:44 2008 +0300
@@ -10,6 +10,7 @@ libimap_a_SOURCES = \
imap-bodystructure.c \
imap-date.c \
imap-envelope.c \
+ imap-id.c \
imap-match.c \
imap-parser.c \
imap-quote.c \
@@ -21,6 +22,7 @@ headers = \
imap-bodystructure.h \
imap-date.h \
imap-envelope.h \
+ imap-id.h \
imap-match.h \
imap-parser.h \
imap-quote.h \
diff -r 8f3115354d14 -r ca2ff54ee9b4 src/lib-imap/imap-id.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib-imap/imap-id.c Sat Jun 21 09:22:44 2008 +0300
@@ -0,0 +1,174 @@
+/* Copyright (c) 2008 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "str.h"
+#include "str-sanitize.h"
+#include "istream.h"
+#include "imap-parser.h"
+#include "imap-quote.h"
+#include "imap-id.h"
+
+#ifdef HAVE_SYS_UTSNAME_H
+# include <sys/utsname.h>
+#endif
+
+#ifdef HAVE_UNAME
+static struct utsname utsname_result;
+static bool utsname_set = FALSE;
+
+static const char *imap_id_get_uname(const char *key)
+{
+ if (!utsname_set) {
+ utsname_set = TRUE;
+ if (uname(&utsname_result) < 0) {
+ i_error("uname() failed: %m");
+ memset(&utsname_result, 0, sizeof(utsname_result));
+ }
+ }
+
+ if (strcmp(key, "os") == 0)
+ return utsname_result.sysname;
+ if (strcmp(key, "os-version") == 0)
+ return utsname_result.release;
+ return NULL;
+}
+#endif
+
+static const char *imap_id_get_default(const char *key)
+{
+ if (strcasecmp(key, "name") == 0)
+ return PACKAGE_NAME;
+ if (strcasecmp(key, "version") == 0)
+ return PACKAGE_VERSION;
More information about the dovecot-cvs
mailing list