# HG changeset patch # User Matthew Wild # Date 1297646855 0 # Node ID 5d306466f3f68ef9fefcb05d3df7213591c9ab51 # Parent 5aa8229e88151ef1ae6d8f073dd053e18424ffdd mod_auth_dovecot: Use hash of vhost as PID to pass to dovecot - the ID must be unique per process, whereas we make a connection per vhost. diff -r 5aa8229e8815 -r 5d306466f3f6 mod_auth_dovecot/mod_auth_dovecot.lua --- a/mod_auth_dovecot/mod_auth_dovecot.lua Sun Feb 13 23:30:11 2011 +0100 +++ b/mod_auth_dovecot/mod_auth_dovecot.lua Mon Feb 14 01:27:35 2011 +0000 @@ -12,7 +12,7 @@ local new_sasl = require "util.sasl".new; local nodeprep = require "util.encodings".stringprep.nodeprep; local base64 = require "util.encodings".base64; -local pposix = require "util.pposix"; +local sha1 = require "util.hashes".sha1; local prosody = prosody; local socket_path = module:get_option_string("dovecot_auth_socket", "/var/run/dovecot/auth-login"); @@ -22,6 +22,8 @@ log("debug", "initializing dovecot authentication provider for host '%s'", host); local conn; + -- Generate an id for this connection (must be a 31-bit number, unique per process) + local pid = tonumber(sha1(host, true):sub(1, 6), 16); -- Closes the socket function provider.close(self) @@ -48,7 +50,6 @@ end -- Send our handshake - local pid = pposix.getpid(); log("debug", "sending handshake to dovecot. version 1.1, cpid '%d'", pid); if not provider:send("VERSION\t1\t1\n") then return false