]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: Add hook for client_create().
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 3 Nov 2018 11:56:30 +0000 (12:56 +0100)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 11 Dec 2018 20:39:21 +0000 (21:39 +0100)
src/lmtp/client.c
src/lmtp/lmtp-common.h
src/lmtp/main.c

index 1d12b2225562fdca4053e902c340552958746a07..f3820d8de55aa9d74fadddbf597e3e26f5203238 100644 (file)
@@ -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;
 }
index 6da45147c47f6b6c9ce81c6980487db6e50f0aea..249797558de9fe1ae7fcd73f42840e573d318acf 100644 (file)
 #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
index e25e8bc7c0cf82a03e1fcf3dea2bdc6a21995c9c..cd6161d7f56e59eaa5e6ec3b336710dbbe5a76d0 100644 (file)
 #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)
 {