comparison mod_auth_dovecot/mod_auth_dovecot.lua @ 271:05ea4abb664d

mod_auth_dovecot: Load dovecot socket path form config
author Javier Torres <javitonino@gmail.com>
date Sat, 30 Oct 2010 23:39:22 +0200
parents 853ae6ae87bf
children 6b35c23664db
comparison
equal deleted inserted replaced
270:853ae6ae87bf 271:05ea4abb664d
12 local nodeprep = require "util.encodings".stringprep.nodeprep; 12 local nodeprep = require "util.encodings".stringprep.nodeprep;
13 local base64 = require "util.encodings".base64; 13 local base64 = require "util.encodings".base64;
14 local pposix = require "util.pposix"; 14 local pposix = require "util.pposix";
15 15
16 local prosody = _G.prosody; 16 local prosody = _G.prosody;
17 local socket_path = module:get_option_string("dovecot_auth_socket", "/var/run/dovecot/auth-login");
17 18
18 function new_default_provider(host) 19 function new_default_provider(host)
19 local provider = { name = "dovecot", c = nil }; 20 local provider = { name = "dovecot", c = nil };
20 log("debug", "initializing dovecot authentication provider for host '%s'", host); 21 log("debug", "initializing dovecot authentication provider for host '%s'", host);
21 22
33 provider:close(); 34 provider:close();
34 35
35 provider.c = socket.unix(); 36 provider.c = socket.unix();
36 37
37 -- Create a connection to dovecot socket 38 -- Create a connection to dovecot socket
38 local socket = "/var/run/dovecot/auth-login"; 39 local r, e = provider.c:connect(socket_path);
39 local r, e = provider.c:connect(socket);
40 if (not r) then 40 if (not r) then
41 log("warn", "error connecting to dovecot socket at '%s'. error was '%s'. check permissions", socket, e); 41 log("warn", "error connecting to dovecot socket at '%s'. error was '%s'. check permissions", socket_path, e);
42 provider:close(); 42 provider:close();
43 return false; 43 return false;
44 end 44 end
45 45
46 -- Send our handshake 46 -- Send our handshake