Browse Source

Configure Lua package path

Peter Colberg 3 years ago
parent
commit
0e45e32d08
2 changed files with 6 additions and 1 deletions
  1. 1
    0
      examples/antispam/dovecot.conf.in
  2. 5
    1
      src/lua_plugin.c

+ 1
- 0
examples/antispam/dovecot.conf.in View File

@@ -7,6 +7,7 @@ protocol imap {
7 7
 
8 8
 plugin {
9 9
   lua_script = CURDIR/antispam.lua
10
+  lua_path = CURDIR/?.lua;;
10 11
   antispam_program_spam = true bogofilter -l -e -d %h/.bogofilter -Ns
11 12
   antispam_program_nonspam = true bogofilter -l -e -d %h/.bogofilter -Sn
12 13
   antispam_mailbox_spam = Spam

+ 5
- 1
src/lua_plugin.c View File

@@ -13,6 +13,7 @@
13 13
 #include "mailbox_transaction_context.h"
14 14
 #include "lib_dovecot.h"
15 15
 #include "common.h"
16
+#include <stdlib.h>
16 17
 
17 18
 static MODULE_CONTEXT_DEFINE_INIT(doveL_storage_module, &mail_storage_module_register);
18 19
 static MODULE_CONTEXT_DEFINE_INIT(doveL_user_module, &mail_user_module_register);
@@ -186,7 +187,7 @@ static void doveL_user_created(struct mail_user *user)
186 187
 {
187 188
   struct mail_user_vfuncs *v = user->vlast;
188 189
   struct doveL_user_context *user_ctx;
189
-  const char *file;
190
+  const char *file, *path;
190 191
   lua_State *L = luaL_newstate();
191 192
 
192 193
   user_ctx = p_new(user->pool, struct doveL_user_context, 1);
@@ -206,6 +207,9 @@ static void doveL_user_created(struct mail_user *user)
206 207
     i_error("Missing plugin config variable 'lua_script'");
207 208
     return;
208 209
   }
210
+  if ((path = mail_user_plugin_getenv(user, "lua_path"))) {
211
+    setenv("LUA_PATH", path, 1);
212
+  }
209 213
 
210 214
   lua_gc(L, LUA_GCSTOP, 0);
211 215
   luaL_openlibs(L);

Loading…
Cancel
Save