Skip to content

Commit

Permalink
lmtp: Load all globally-defined mail_plugins at client connect.
Browse files Browse the repository at this point in the history
Before, this was not performed until after a user lookup was performed for a
recipient. That is not acceptable when plugins need to modify the LMTP protocol
itself.
  • Loading branch information
stephanbosch committed Dec 12, 2018
1 parent 38cbea1 commit c98c2c3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lmtp/Makefile.am
Expand Up @@ -16,6 +16,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib-storage \
-I$(top_srcdir)/src/lib-storage/index \
-I$(top_srcdir)/src/lib-storage/index/raw \
-DMODULEDIR=\""$(moduledir)"\" \
$(BINARY_CFLAGS)

lmtp_LDFLAGS = -export-dynamic \
Expand Down
20 changes: 20 additions & 0 deletions src/lmtp/lmtp-client.c
Expand Up @@ -10,6 +10,7 @@
#include "hostpid.h"
#include "process-title.h"
#include "var-expand.h"
#include "module-dir.h"
#include "master-service-ssl.h"
#include "master-service-settings.h"
#include "iostream-ssl.h"
Expand Down Expand Up @@ -74,6 +75,24 @@ static void refresh_proctitle(void)
process_title_set(str_c(title));
}

static void client_load_modules(struct client *client)
{
struct module_dir_load_settings mod_set;

i_zero(&mod_set);
mod_set.abi_version = DOVECOT_ABI_VERSION;
mod_set.require_init_funcs = TRUE;
mod_set.binary_name = "lmtp";

/* pre-load all configured mail plugins */
mail_storage_service_modules =
module_dir_load_missing(mail_storage_service_modules,
client->lmtp_set->mail_plugin_dir,
client->lmtp_set->mail_plugins,
&mod_set);
module_dir_init(mail_storage_service_modules);
}

static void client_raw_user_create(struct client *client)
{
void **sets;
Expand Down Expand Up @@ -137,6 +156,7 @@ struct client *client_create(int fd_in, int fd_out,

client_read_settings(client, conn->ssl);
client_raw_user_create(client);
client_load_modules(client);
client->my_domain = client->unexpanded_lda_set->hostname;

if (client->service_set->verbose_proctitle)
Expand Down
8 changes: 7 additions & 1 deletion src/lmtp/lmtp-settings.c
Expand Up @@ -70,6 +70,9 @@ static const struct setting_define lmtp_setting_defines[] = {
DEF(SET_STR_VARS, login_greeting),
DEF(SET_STR, login_trusted_networks),

DEF(SET_STR, mail_plugins),
DEF(SET_STR, mail_plugin_dir),

SETTING_DEFINE_LIST_END
};

Expand All @@ -83,7 +86,10 @@ static const struct lmtp_settings lmtp_default_settings = {
.lmtp_proxy_rawlog_dir = "",

.login_greeting = PACKAGE_NAME" ready.",
.login_trusted_networks = ""
.login_trusted_networks = "",

.mail_plugins = "",
.mail_plugin_dir = MODULEDIR,
};

static const struct setting_parser_info *lmtp_setting_dependencies[] = {
Expand Down
3 changes: 3 additions & 0 deletions src/lmtp/lmtp-settings.h
Expand Up @@ -24,6 +24,9 @@ struct lmtp_settings {
const char *login_greeting;
const char *login_trusted_networks;

const char *mail_plugins;
const char *mail_plugin_dir;

enum lmtp_hdr_delivery_address parsed_lmtp_hdr_delivery_address;
};

Expand Down

0 comments on commit c98c2c3

Please sign in to comment.