# HG changeset patch # User Matthew Wild # Date 1376433400 -3600 # Node ID ae1767b549641536a2003ba63c3424104017a390 # Parent a7d0d129df6f67191955292200ccc1cf9019f3bb mod_auth_external: Fix logging of errors diff -r a7d0d129df6f -r ae1767b54964 mod_auth_external/mod_auth_external.lua --- a/mod_auth_external/mod_auth_external.lua Tue Aug 13 21:37:05 2013 +0100 +++ b/mod_auth_external/mod_auth_external.lua Tue Aug 13 23:36:40 2013 +0100 @@ -58,19 +58,17 @@ query = query..'\n'; end - local response = send_query(query); - if (script_type == "ejabberd" and response == "\0\2\0\0") or + local response, err = send_query(query); + if not response then + log("warn", "Error while waiting for result from auth process: %s", err or "unknown error"); + elseif (script_type == "ejabberd" and response == "\0\2\0\0") or (script_type == "generic" and response:gsub("\r?\n$", "") == "0") then return nil, "not-authorized"; elseif (script_type == "ejabberd" and response == "\0\2\0\1") or (script_type == "generic" and response:gsub("\r?\n$", "") == "1") then return true; else - if response then - log("warn", "Unable to interpret data from auth process, %s", (response:match("^error:") and response) or ("["..#response.." bytes]")); - else - log("warn", "Error while waiting for result from auth process: %s", response or "unknown error"); - end + log("warn", "Unable to interpret data from auth process, %s", (response:match("^error:") and response) or ("["..#response.." bytes]")); return nil, "internal-server-error"; end end