# HG changeset patch # User Waqas Hussain # Date 1348803087 -18000 # Node ID c9e2beec4ef6333f5e8f9de166a398cad45ef13e # Parent 0ef11dee70509bf8ab9264a8056ba85ea507a233 mod_auth_dovecot: Improved error reporting. diff -r 0ef11dee7050 -r c9e2beec4ef6 mod_auth_dovecot/auth_dovecot/mod_auth_dovecot.lua --- a/mod_auth_dovecot/auth_dovecot/mod_auth_dovecot.lua Sat Sep 22 02:06:21 2012 +0200 +++ b/mod_auth_dovecot/auth_dovecot/mod_auth_dovecot.lua Fri Sep 28 08:31:27 2012 +0500 @@ -37,7 +37,10 @@ end do - local s = new_sasl(module.host) + local s, err = new_sasl(module.host) + if not s then + log("error", "%s", tostring(err)); + end assert(s, "Could not create a new SASL object"); assert(s.mechanisms, "SASL object has no mechanims method"); local m, _m = {}, s:mechanisms(); diff -r 0ef11dee7050 -r c9e2beec4ef6 mod_auth_dovecot/auth_dovecot/sasl_dovecot.lib.lua --- a/mod_auth_dovecot/auth_dovecot/sasl_dovecot.lib.lua Sat Sep 22 02:06:21 2012 +0200 +++ b/mod_auth_dovecot/auth_dovecot/sasl_dovecot.lib.lua Fri Sep 28 08:31:27 2012 +0500 @@ -62,27 +62,29 @@ end if not ok then - log("error", "error connecting to dovecot %s socket at '%s'. error was '%s'", socket_type, socket_path or socket_info, err); - return false; + return false, "error connecting to dovecot "..tostring(socket_type).." socket at '" + ..tostring(socket_path or socket_info).."'. error was '"..tostring(err).."'"; end -- Send our handshake pid = tonumber(tostring(conn):match("0x%x*$")); log("debug", "sending handshake to dovecot. version 1.1, cpid '%d'", pid); - if not conn:send("VERSION\t1\t1\n") then - return false + local success,err = conn:send("VERSION\t1\t1\n"); + if not success then + return false, "Unable to send version data to socket: "..tostring(err); end - if not conn:send("CPID\t" .. pid .. "\n") then - return false + local success,err = conn:send("CPID\t" .. pid .. "\n"); + if not success then + return false, "Unable to send PID to socket: "..tostring(err); end -- Parse Dovecot's handshake local done = false; supported_mechs = {}; while (not done) do - local line = conn:receive(); + local line, err = conn:receive(); if not line then - return false; + return false, "No data read from socket: "..tostring(err); end --log("debug", "dovecot handshake: '%s'", line); @@ -93,9 +95,8 @@ local major_version = parts(); if major_version ~= "1" then - log("error", "dovecot server version is not 1.x. it is %s.x", major_version); conn:close(); - return false; + return false, "dovecot server version is not 1.x. it is "..tostring(major_version)..".x"; end elseif first == "MECH" then local mech = parts(); @@ -118,7 +119,7 @@ if not conn then conn, mechs = connect(socket_info); if not conn then - return nil, "Socket connection failure"; + return nil, "Dovecot connection failure: "..tostring(mechs); end end sasl_i.conn, sasl_i.mechs = conn, mechs;