]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: MAIL_STORAGE_SERVICE_FLAG_NO_PLUGINS wasn't working correctly
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 30 Jul 2017 06:39:18 +0000 (09:39 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 31 Jul 2017 07:44:20 +0000 (10:44 +0300)
Especially with "doveadm user" it still triggered running the plugins,
because doveadm loads all the plugins early.

src/lib-storage/mail-storage-service.c

index edfc6dd7c274cde8d5017554e1ad27052c148759..2f83c81e48b1402a19f118c5d77573070451d717 100644 (file)
@@ -1296,6 +1296,19 @@ mail_storage_service_lookup_real(struct mail_storage_service_ctx *ctx,
                        ret = -2;
                }
        }
+       if ((ctx->flags & MAIL_STORAGE_SERVICE_FLAG_NO_PLUGINS) != 0 &&
+           user_set->mail_plugins[0] != '\0') {
+               /* mail_storage_service_load_modules() already avoids loading
+                  plugins when the _NO_PLUGINS flag is set. However, it's
+                  possible that the plugins are already loaded, because the
+                  plugin loading is a global state. This is especially true
+                  with doveadm, which loads the mail_plugins immediately at
+                  startup so it can find commands registered by plugins. It's
+                  fine that extra plugins are loaded - we'll just need to
+                  prevent any of their hooks from being called. One easy way
+                  to do this is just to clear out the mail_plugins setting: */
+               (void)settings_parse_line(user->set_parser, "mail_plugins=");
+       }
 
        *user_r = user;
        return ret;