From: Timo Sirainen Date: Thu, 30 Aug 2012 19:05:02 +0000 (+0300) Subject: Merged changes from v2.1 tree. X-Git-Tag: 2.2.alpha1~253 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d163fac99c7ca5b2ce2edfa83a1b2922cf66aeac;p=thirdparty%2Fdovecot%2Fcore.git Merged changes from v2.1 tree. --- d163fac99c7ca5b2ce2edfa83a1b2922cf66aeac diff --cc src/auth/auth-master-connection.c index 2d10930a99,5fdfaea890..66cdb2bc14 --- a/src/auth/auth-master-connection.c +++ b/src/auth/auth-master-connection.c @@@ -342,10 -342,10 +342,10 @@@ static void pass_callback_finish(struc } if (conn->auth->set->debug) - i_debug("master out: %s", str_c(str)); + i_debug("passdb out: %s", str_c(str)); str_append_c(str, '\n'); - (void)o_stream_send(conn->output, str_data(str), str_len(str)); + o_stream_nsend(conn->output, str_data(str), str_len(str)); auth_request_unref(&auth_request); auth_master_connection_unref(&conn); diff --cc src/doveadm/doveadm-mail-copymove.c index 8705a09666,c3fd27405c..db357f47a8 --- a/src/doveadm/doveadm-mail-copymove.c +++ b/src/doveadm/doveadm-mail-copymove.c @@@ -40,11 -44,12 +44,12 @@@ cmd_copy_box(struct copy_cmd_context *c while (doveadm_mail_iter_next(iter, &mail)) { save_ctx = mailbox_save_alloc(desttrans); mailbox_save_copy_flags(save_ctx, mail); - if (mailbox_copy(&save_ctx, mail) == 0) - mail_expunge(mail); - else { + if (mailbox_copy(&save_ctx, mail) == 0) { + if (ctx->move) + mail_expunge(mail); + } else { i_error("Copying message UID %u from '%s' failed: %s", - mail->uid, info->name, + mail->uid, info->vname, mailbox_get_last_error(destbox, NULL)); doveadm_mail_failed_mailbox(&ctx->ctx, destbox); ret = -1; diff --cc src/imap/cmd-list.c index 48c09fbee7,29b5108f14..bf602ed692 --- a/src/imap/cmd-list.c +++ b/src/imap/cmd-list.c @@@ -155,6 -181,103 +155,19 @@@ parse_return_flags(struct cmd_list_cont return TRUE; } -static enum mailbox_info_flags -list_get_inbox_flags(struct cmd_list_context *ctx) -{ - struct mail_namespace *ns; - struct mailbox_list_iterate_context *list_iter; - const struct mailbox_info *info; - enum mailbox_info_flags flags = MAILBOX_UNMARKED; - - if (ctx->seen_inbox_namespace && - (ctx->ns->flags & NAMESPACE_FLAG_INBOX_USER) == 0) { - /* INBOX doesn't exist. use the default INBOX flags */ - return flags; - } - - /* find the INBOX flags */ - ns = mail_namespace_find_inbox(ctx->cmd->client->user->namespaces); - list_iter = mailbox_list_iter_init(ns->list, "INBOX", 0); - info = mailbox_list_iter_next(list_iter); - if (info != NULL) { - i_assert(strcasecmp(info->name, "INBOX") == 0); - flags = info->flags; - } - (void)mailbox_list_iter_deinit(&list_iter); - return flags; -} - -static bool list_namespace_has_children(struct cmd_list_context *ctx) -{ - enum mailbox_list_iter_flags list_flags = - MAILBOX_LIST_ITER_RETURN_NO_FLAGS; - struct mailbox_list_iterate_context *list_iter; - const struct mailbox_info *info; - bool ret = FALSE; - - if ((ctx->list_flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0) - list_flags |= MAILBOX_LIST_ITER_SELECT_SUBSCRIBED; - - list_iter = mailbox_list_iter_init(ctx->ns->list, - t_strconcat(ctx->ns->prefix, "%", NULL), list_flags); - info = mailbox_list_iter_next(list_iter); - if (info != NULL) - ret = TRUE; - if (mailbox_list_iter_deinit(&list_iter) < 0) { - /* safer to answer TRUE in error conditions */ - ret = TRUE; - } - return ret; -} - + static const char *ns_prefix_mutf7(struct mail_namespace *ns) + { + string_t *str; + + if (*ns->prefix == '\0') + return ""; + + str = t_str_new(64); + if (imap_utf8_to_utf7(ns->prefix, str) < 0) + i_panic("Namespace prefix not UTF-8: %s", ns->prefix); + return str_c(str); + } + -static const char *ns_get_listed_prefix(struct cmd_list_context *ctx) -{ - struct imap_match_glob *glob; - enum imap_match_result match; - const char *ns_prefix, *p; - bool inboxcase; - unsigned int skip_len; - - skip_len = strlen(ctx->ref); - if (strncmp(ctx->ns->prefix, ctx->ref, skip_len) != 0) - skip_len = 0; - - inboxcase = strncasecmp(ctx->ns->prefix, "INBOX", 5) == 0 && - ctx->ns->prefix[5] == mail_namespace_get_sep(ctx->ns); - glob = imap_match_init_multiple(pool_datastack_create(), - ctx->patterns, inboxcase, - mail_namespace_get_sep(ctx->ns)); - ns_prefix = ctx->ns->prefix + skip_len; - match = imap_match(glob, ns_prefix); - if (match == IMAP_MATCH_YES) { - return !ctx->cur_ns_skip_trailing_sep ? ctx->ns->prefix : - t_strndup(ctx->ns->prefix, strlen(ctx->ns->prefix)-1); - } - - while ((match & IMAP_MATCH_PARENT) != 0) { - p = strrchr(ns_prefix, mail_namespace_get_sep(ctx->ns)); - i_assert(p != NULL); - ns_prefix = t_strdup_until(ns_prefix, p); - match = imap_match(glob, ns_prefix); - } - i_assert(match == IMAP_MATCH_YES); - return t_strconcat(t_strndup(ctx->ns->prefix, skip_len), - ns_prefix, NULL); -} - static void list_reply_append_ns_sep_param(string_t *str, char sep) { str_append_c(str, '"'); @@@ -374,6 -955,10 +387,10 @@@ bool cmd_list_full(struct client_comman return TRUE; } str = t_str_new(64); - if (imap_utf7_to_utf8(ctx->ref, str) == 0) - ctx->ref = p_strdup(cmd->pool, str_c(str)); ++ if (imap_utf7_to_utf8(ref, str) == 0) ++ ref = p_strdup(cmd->pool, str_c(str)); + str_truncate(str, 0); + if (imap_arg_get_list_full(&args[1], &list_args, &arg_count)) { ctx->used_listext = TRUE; /* convert pattern list to string array */ diff --cc src/lmtp/commands.c index 77727c1ca9,ea97d39682..d904e643a6 --- a/src/lmtp/commands.c +++ b/src/lmtp/commands.c @@@ -314,16 -302,10 +314,17 @@@ static bool client_proxy_rcpt(struct cl return TRUE; } if (client->proxy == NULL) { - client->proxy = lmtp_proxy_init(client->set->hostname, - dns_client_socket_path, - client->state.session_id, - client->output); + struct lmtp_proxy_settings proxy_set; + + memset(&proxy_set, 0, sizeof(proxy_set)); + proxy_set.my_hostname = client->set->hostname; + proxy_set.dns_client_socket_path = dns_client_socket_path; ++ proxy_set.session_id = client->state.session_id; + proxy_set.source_ip = client->remote_ip; + proxy_set.source_port = client->remote_port; + proxy_set.proxy_ttl = client->proxy_ttl-1; + + client->proxy = lmtp_proxy_init(&proxy_set, client->output); if (client->state.mail_body_8bitmime) args = " BODY=8BITMIME"; else if (client->state.mail_body_7bit) diff --cc src/lmtp/lmtp-proxy.c index 2542a92e64,2128c2b5cf..9d898927e3 --- a/src/lmtp/lmtp-proxy.c +++ b/src/lmtp/lmtp-proxy.c @@@ -66,13 -66,10 +66,14 @@@ lmtp_proxy_init(const struct lmtp_proxy pool = pool_alloconly_create("lmtp proxy", 1024); proxy = p_new(pool, struct lmtp_proxy, 1); proxy->pool = pool; - proxy->my_hostname = p_strdup(pool, my_hostname); proxy->client_output = client_output; - proxy->dns_client_socket_path = p_strdup(pool, dns_client_socket_path); - proxy->session_id = p_strdup(pool, session_id); + proxy->set.my_hostname = p_strdup(pool, set->my_hostname); + proxy->set.dns_client_socket_path = + p_strdup(pool, set->dns_client_socket_path); ++ proxy->set.session_id = p_strdup(pool, set->session_id); + proxy->set.source_ip = set->source_ip; + proxy->set.source_port = set->source_port; + proxy->set.proxy_ttl = set->proxy_ttl; i_array_init(&proxy->rcpt_to, 32); i_array_init(&proxy->connections, 32); return proxy; @@@ -272,8 -265,9 +273,9 @@@ static void lmtp_proxy_conn_timeout(str const char *line; line = t_strdup_printf(ERRSTR_TEMP_REMOTE_FAILURE - " (timeout while waiting for reply to %s)", - lmtp_client_state_to_string(conn->client)); + " (timeout while waiting for reply to %s) <%s>", + lmtp_client_state_to_string(conn->client), - conn->proxy->session_id); ++ conn->proxy->set.session_id); lmtp_client_fail(conn->client, line); } diff --cc src/lmtp/lmtp-proxy.h index 3e0f2ffd3b,923d990a09..1658a513e8 --- a/src/lmtp/lmtp-proxy.h +++ b/src/lmtp/lmtp-proxy.h @@@ -4,19 -4,7 +4,20 @@@ #include "network.h" #include "lmtp-client.h" +#define LMTP_PROXY_DEFAULT_TTL 5 + struct lmtp_proxy_settings { + const char *my_hostname; + const char *dns_client_socket_path; ++ const char *session_id; + + /* the original client's IP/port that connected to the proxy */ + struct ip_addr source_ip; + unsigned int source_port; + unsigned int proxy_ttl; +}; + +struct lmtp_proxy_rcpt_settings { const char *host; unsigned int port; unsigned int timeout_msecs;