[Dovecot] Patch: New event "mailbox_create" for the mail_log plugin

Tobias Joch tobias.joch at inovex.de
Thu Jul 29 14:28:44 EEST 2010


Hello,

the following patch for the mail_log plugin (source version = 1.2.13) adds a new logging event "mailbox_create". 
Perhaps this is also of interest to other people except me ;)

Best regards,
Tobias


Index: src/plugins/mail-log/mail-log-plugin.c
===================================================================
--- src/plugins/mail-log/mail-log-plugin.c	(revision 571)
+++ src/plugins/mail-log/mail-log-plugin.c	(working copy)
@@ -43,12 +43,14 @@
	MAIL_LOG_EVENT_MAILBOX_DELETE	= 0x10,
	MAIL_LOG_EVENT_MAILBOX_RENAME	= 0x20,
	MAIL_LOG_EVENT_FLAG_CHANGE	= 0x40,
-	MAIL_LOG_EVENT_APPEND		= 0x80
+	MAIL_LOG_EVENT_APPEND		= 0x80,
+	MAIL_LOG_EVENT_MAILBOX_CREATE	= 0x100
};
#define MAIL_LOG_DEFAULT_EVENTS \
	(MAIL_LOG_EVENT_DELETE | MAIL_LOG_EVENT_UNDELETE | \
	 MAIL_LOG_EVENT_EXPUNGE | MAIL_LOG_EVENT_COPY | \
-	 MAIL_LOG_EVENT_MAILBOX_DELETE | MAIL_LOG_EVENT_MAILBOX_RENAME)
+	 MAIL_LOG_EVENT_MAILBOX_DELETE | MAIL_LOG_EVENT_MAILBOX_RENAME | \
+	 MAIL_LOG_EVENT_MAILBOX_CREATE)

static const char *field_names[] = {
	"uid",
@@ -71,6 +73,7 @@
	"mailbox_rename",
	"flag_change",
	"append",
+	"mailbox_create",
	NULL
};

@@ -597,6 +600,22 @@
	return 0;
}

+static int
+mail_log_mailbox_create(struct mail_storage *storage, const char *name,
+		      bool directory)
+{
+	union mail_storage_module_context *lstorage = MAIL_LOG_CONTEXT(storage);
+
+	if (lstorage->super.mailbox_create(storage, name, directory) < 0)
+		return -1;
+
+	if ((mail_log_set.events & MAIL_LOG_EVENT_MAILBOX_CREATE) == 0)
+			return 0;
+
+	i_info("Mailbox created: %s", str_sanitize(name, MAILBOX_NAME_LOG_LEN));
+	return 0;
+}
+
static void mail_log_mail_storage_created(struct mail_storage *storage)
{
	union mail_storage_module_context *lstorage;
@@ -604,6 +623,7 @@
	lstorage = p_new(storage->pool, union mail_storage_module_context, 1);
	lstorage->super = storage->v;
	storage->v.mailbox_open = mail_log_mailbox_open;
+	storage->v.mailbox_create = mail_log_mailbox_create;

	MODULE_CONTEXT_SET_SELF(storage, mail_log_storage_module, lstorage);


-- 
Tobias Joch
Dipl.-Informatiker (FH)

Head of Solution Development

inovex GmbH
Karlsruher Straße 71
D-75179 Pforzheim
Tel.      +49 7231 - 31 91 71
Fax      +49 7231 - 31 91 91
Mobil   +49 173 - 31 81 004
tobias.joch at inovex.de
www.inovex.de

Sitz der Gesellschaft: Pforzheim
AG Mannheim, HRB 502126
Geschäftsführer: Stephan Müller


More information about the dovecot mailing list