Upon thinking, the variable names may not be descriptive enough as
`host` is a bit ambiguous and `deleted_count` may refer to a different
command than expunge in imap and may be valid to track at some point
so I have changed `host` to `client_ip` and `deleted_count` in imap to
`expunged_count`, below is the modified diff for version 1.2.11.
diff -crB dovecot-1.2.11.orig/src/imap/client.c dovecot-1.2.11/src/imap/client.c
*** dovecot-1.2.11.orig/src/imap/client.c 2010-01-24 16:14:17.000000000 -0700
--- dovecot-1.2.11/src/imap/client.c 2010-05-20 09:30:47.170407921 -0600
***************
*** 42,47 ****
--- 42,48 ----
client->fd_out = fd_out;
client->input = i_stream_create_fd(fd_in, imap_max_line_length, FALSE);
client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE);
+ client->expunged = 0;
o_stream_set_flush_callback(client->output, client_output, client);
***************
*** 105,110 ****
--- 106,113 ----
static struct var_expand_table static_tab[] = {
{ 'i', NULL, "input" },
{ 'o', NULL, "output" },
+ { 'c', NULL, "client_ip" },
+ { 'e', NULL, "expunged_count" },
{ '\0', NULL, NULL }
};
struct var_expand_table *tab;
***************
*** 115,120 ****
--- 118,125 ----
tab[0].value = dec2str(client->input->v_offset);
tab[1].value = dec2str(client->output->offset);
+ tab[2].value = getenv("IP") ? getenv("IP") :
"Unknown";
+ tab[3].value = dec2str(client->expunged);
str = t_str_new(128);
var_expand(str, logout_format, tab);
diff -crB dovecot-1.2.11.orig/src/imap/client.h dovecot-1.2.11/src/imap/client.h
*** dovecot-1.2.11.orig/src/imap/client.h 2009-06-26 22:49:34.000000000 -0600
--- dovecot-1.2.11/src/imap/client.h 2010-05-19 16:26:31.529833893 -0600
***************
*** 133,138 ****
--- 133,139 ----
unsigned int destroyed:1;
unsigned int handling_input:1;
unsigned int syncing:1;
+ unsigned int expunged;
unsigned int id_logged:1;
unsigned int mailbox_examined:1;
unsigned int input_skip_line:1; /* skip all the data until we've
diff -crB dovecot-1.2.11.orig/src/imap/cmd-close.c
dovecot-1.2.11/src/imap/cmd-close.c
*** dovecot-1.2.11.orig/src/imap/cmd-close.c 2010-01-24 16:14:17.000000000 -0700
--- dovecot-1.2.11/src/imap/cmd-close.c 2010-05-19 16:26:31.529833893 -0600
***************
*** 18,24 ****
client->mailbox = NULL;
storage = mailbox_get_storage(mailbox);
! if ((ret = imap_expunge(mailbox, NULL)) < 0)
client_send_untagged_storage_error(client, storage);
if (mailbox_sync(mailbox, 0, 0, NULL) < 0)
client_send_untagged_storage_error(client, storage);
--- 18,24 ----
client->mailbox = NULL;
storage = mailbox_get_storage(mailbox);
! if ((ret = imap_expunge(client, NULL)) < 0)
client_send_untagged_storage_error(client, storage);
if (mailbox_sync(mailbox, 0, 0, NULL) < 0)
client_send_untagged_storage_error(client, storage);
diff -crB dovecot-1.2.11.orig/src/imap/cmd-expunge.c
dovecot-1.2.11/src/imap/cmd-expunge.c
*** dovecot-1.2.11.orig/src/imap/cmd-expunge.c 2010-01-24
16:14:17.000000000 -0700
--- dovecot-1.2.11/src/imap/cmd-expunge.c 2010-05-19 16:26:31.529833893 -0600
***************
*** 24,30 ****
{
struct client *client = cmd->client;
! if (imap_expunge(client->mailbox, search_args == NULL ? NULL :
search_args->args) < 0) {
client_send_storage_error(cmd,
mailbox_get_storage(client->mailbox));
--- 24,30 ----
{
struct client *client = cmd->client;
! if (imap_expunge(client, search_args == NULL ? NULL :
search_args->args) < 0) {
client_send_storage_error(cmd,
mailbox_get_storage(client->mailbox));
diff -crB dovecot-1.2.11.orig/src/imap/imap-expunge.c
dovecot-1.2.11/src/imap/imap-expunge.c
*** dovecot-1.2.11.orig/src/imap/imap-expunge.c 2010-01-24
16:14:17.000000000 -0700
--- dovecot-1.2.11/src/imap/imap-expunge.c 2010-05-19 16:26:31.529833893 -0600
***************
*** 5,18 ****
#include "mail-search-build.h"
#include "imap-expunge.h"
! int imap_expunge(struct mailbox *box, struct mail_search_arg *next_search_arg)
{
struct mail_search_context *ctx;
struct mailbox_transaction_context *t;
struct mail *mail;
struct mail_search_args *search_args;
bool expunges = FALSE;
if (mailbox_is_readonly(box)) {
/* silently ignore */
return 0;
--- 5,21 ----
#include "mail-search-build.h"
#include "imap-expunge.h"
! int imap_expunge(struct client *client, struct mail_search_arg
*next_search_arg)
{
struct mail_search_context *ctx;
struct mailbox_transaction_context *t;
struct mail *mail;
+ struct mailbox *box;
struct mail_search_args *search_args;
bool expunges = FALSE;
+ box = client->mailbox;
+
if (mailbox_is_readonly(box)) {
/* silently ignore */
return 0;
diff -crB dovecot-1.2.11.orig/src/imap/imap-expunge.h
dovecot-1.2.11/src/imap/imap-expunge.h
*** dovecot-1.2.11.orig/src/imap/imap-expunge.h 2008-06-08
21:14:46.000000000 -0600
--- dovecot-1.2.11/src/imap/imap-expunge.h 2010-05-19 16:26:31.529833893 -0600
***************
*** 3,8 ****
struct mail_search_arg;
! int imap_expunge(struct mailbox *box, struct mail_search_arg
*next_search_arg);
#endif
--- 3,8 ----
struct mail_search_arg;
! int imap_expunge(struct client *client, struct mail_search_arg
*next_search_arg);
#endif
Only in dovecot-1.2.11.orig/src/lib-sql: sql-drivers-register.c
diff -crB dovecot-1.2.11.orig/src/pop3/client.c dovecot-1.2.11/src/pop3/client.c
*** dovecot-1.2.11.orig/src/pop3/client.c 2010-01-24 16:14:17.000000000 -0700
--- dovecot-1.2.11/src/pop3/client.c 2010-05-20 09:31:01.400409195 -0600
***************
*** 238,243 ****
--- 238,244 ----
{ 's', NULL, "message_bytes" },
{ 'i', NULL, "input" },
{ 'o', NULL, "output" },
+ { 'c', NULL, "client_ip" },
{ '\0', NULL, NULL }
};
struct var_expand_table *tab;
***************
*** 255,260 ****
--- 256,262 ----
tab[6].value = dec2str(client->total_size);
tab[7].value = dec2str(client->input->v_offset);
tab[8].value = dec2str(client->output->offset);
+ tab[9].value = getenv("IP") ? getenv("IP") :
"Unknown";
str = t_str_new(128);
var_expand(str, logout_format, tab);