From: Markus Valentin Date: Mon, 9 Jan 2023 14:06:54 +0000 (+0100) Subject: welcome-plugin: Move script_execute() to welcome_create_box() X-Git-Tag: 2.4.0~3165 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fef8788e3ab26d8f42d433262200692dd674ec5a;p=thirdparty%2Fdovecot%2Fcore.git welcome-plugin: Move script_execute() to welcome_create_box() The welcome script was executed while opening the INBOX only when the same session had created it. This could have led to unexpectedly not executing welcome when not opening the mailbox right after it was created. The original code delayed the welcome script run because mailbox creation wasn't finished until the mailbox was opened. This seems to have become fixed at some point. --- diff --git a/src/plugins/welcome/welcome-plugin.c b/src/plugins/welcome/welcome-plugin.c index 60af5a45dc..1b35acfa89 100644 --- a/src/plugins/welcome/welcome-plugin.c +++ b/src/plugins/welcome/welcome-plugin.c @@ -90,27 +90,24 @@ welcome_create_box(struct mailbox *box, const struct mailbox_update *update, bool directory) { struct welcome_mailbox *wbox = WELCOME_CONTEXT(box); + const char *cmd; if (wbox->module_ctx.super.create_box(box, update, directory) < 0) return -1; - /* the mailbox isn't fully created here yet, so just mark it as created - and wait until open() time to actually run it */ - wbox->created = TRUE; + cmd = mail_user_plugin_getenv(box->storage->user, "welcome_script"); + if (cmd != NULL) { + bool wait = mail_user_plugin_getenv_bool(box->storage->user, + "welcome_wait"); + script_execute(box->storage->user, cmd, wait); + } + return 0; } static int welcome_open_box(struct mailbox *box) { struct welcome_mailbox *wbox = WELCOME_CONTEXT(box); - const char *cmd; - cmd = !wbox->created ? NULL : - mail_user_plugin_getenv(box->storage->user, "welcome_script"); - if (cmd != NULL) { - bool wait = mail_user_plugin_getenv_bool(box->storage->user, - "welcome_wait"); - script_execute(box->storage->user, cmd, wait); - } return wbox->module_ctx.super.open(box); }