From: Stephan Bosch Date: Sat, 3 Nov 2018 11:56:30 +0000 (+0100) Subject: lmtp: Add hook for client_create(). X-Git-Tag: 2.3.9~997 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2dac28f629559c49dbda5ff3f622e8a7161ef1ea;p=thirdparty%2Fdovecot%2Fcore.git lmtp: Add hook for client_create(). --- diff --git a/src/lmtp/client.c b/src/lmtp/client.c index 1d12b22255..f3820d8de5 100644 --- a/src/lmtp/client.c +++ b/src/lmtp/client.c @@ -163,8 +163,13 @@ struct client *client_create(int fd_in, int fd_out, DLLIST_PREPEND(&clients, client); clients_count++; - smtp_server_connection_start(client->conn); i_info("Connect from %s", client_remote_id(client)); + + if (hook_client_created != NULL) + hook_client_created(&client); + + smtp_server_connection_start(client->conn); + refresh_proctitle(); return client; } diff --git a/src/lmtp/lmtp-common.h b/src/lmtp/lmtp-common.h index 6da45147c4..249797558d 100644 --- a/src/lmtp/lmtp-common.h +++ b/src/lmtp/lmtp-common.h @@ -11,12 +11,21 @@ #include "client.h" #include "lmtp-settings.h" +typedef void lmtp_client_created_func_t(struct client **client); + +extern lmtp_client_created_func_t *hook_client_created; + extern char *dns_client_socket_path, *base_dir; extern struct mail_storage_service_ctx *storage_service; extern struct anvil_client *anvil; extern struct smtp_server *lmtp_server; +/* Sets the hook_client_created and returns the previous hook, + which the new_hook should call if it's non-NULL. */ +lmtp_client_created_func_t * +lmtp_client_created_hook_set(lmtp_client_created_func_t *new_hook); + void lmtp_anvil_init(void); #endif diff --git a/src/lmtp/main.c b/src/lmtp/main.c index e25e8bc7c0..cd6161d7f5 100644 --- a/src/lmtp/main.c +++ b/src/lmtp/main.c @@ -23,11 +23,22 @@ #define IS_STANDALONE() \ (getenv(MASTER_IS_PARENT_ENV) == NULL) +struct smtp_server *lmtp_server = NULL; + char *dns_client_socket_path, *base_dir; struct mail_storage_service_ctx *storage_service; struct anvil_client *anvil; -struct smtp_server *lmtp_server; +lmtp_client_created_func_t *hook_client_created = NULL; + +lmtp_client_created_func_t * +lmtp_client_created_hook_set(lmtp_client_created_func_t *new_hook) +{ + lmtp_client_created_func_t *old_hook = hook_client_created; + + hook_client_created = new_hook; + return old_hook; +} void lmtp_anvil_init(void) {