]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
welcome-plugin: Move script_execute() to welcome_create_box()
authorMarkus Valentin <markus.valentin@open-xchange.com>
Mon, 9 Jan 2023 14:06:54 +0000 (15:06 +0100)
committermarkus.valentin <markus.valentin@open-xchange.com>
Wed, 25 Jan 2023 12:01:46 +0000 (12:01 +0000)
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.

src/plugins/welcome/welcome-plugin.c

index 60af5a45dcf8214a2f14f55cc306e22f41bc7705..1b35acfa89a0635382a702c1106e544380eef943 100644 (file)
@@ -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);
 }