# HG changeset patch # User Matthew Wild # Date 1268907071 0 # Node ID 3e06b0f523630d11ef2d213a0aa3bbe45bae9fc7 # Parent 5b8411968a053c3242c6a53b17f15c0b33181d8e# Parent d6da8f8e35025c52978cf6ce6f6713435f69c18b Merge 0.7->trunk diff -r 5b8411968a05 -r 3e06b0f52363 util/sasl_cyrus.lua --- a/util/sasl_cyrus.lua Thu Mar 18 01:44:55 2010 +0000 +++ b/util/sasl_cyrus.lua Thu Mar 18 10:11:11 2010 +0000 @@ -39,7 +39,7 @@ if st then initialized = true; else - log("error", "Failed to initialize CyrusSASL: %s", errmsg); + log("error", "Failed to initialize Cyrus SASL: %s", errmsg); end end end @@ -52,7 +52,14 @@ sasl_i.realm = realm; sasl_i.service_name = service_name; - sasl_i.cyrus = cyrussasl.server_new(service_name, nil, realm, nil, nil) + + local st, ret = pcall(cyrussasl.server_new, service_name, nil, realm, nil, nil) + if st then + sasl_i.cyrus = ret; + else + log("error", "Creating SASL server connection failed: %s", ret); + return nil; + end if cyrussasl.set_canon_cb then local c14n_cb = function (user) @@ -63,10 +70,6 @@ cyrussasl.set_canon_cb(sasl_i.cyrus, c14n_cb); end - if sasl_i.cyrus == 0 then - log("error", "got NULL return value from server_new") - return nil; - end cyrussasl.setssf(sasl_i.cyrus, 0, 0xffffffff) local s = setmetatable(sasl_i, method); return s; @@ -79,7 +82,7 @@ -- set the forbidden mechanisms function method:forbidden( restrict ) - log("debug", "Called method:forbidden. NOT IMPLEMENTED.") + log("warn", "Called method:forbidden. NOT IMPLEMENTED.") return {} end @@ -120,16 +123,12 @@ return "challenge", data elseif (err == -4) then -- SASL_NOMECH log("debug", "SASL mechanism not available from remote end") - return "failure", - "undefined-condition", - "SASL mechanism not available" + return "failure", "invalid-mechanism", "SASL mechanism not available" elseif (err == -13) then -- SASL_BADAUTH return "failure", "not-authorized", cyrussasl.get_message( self.cyrus ) else log("debug", "Got SASL error condition %d", err) - return "failure", - "undefined-condition", - cyrussasl.get_message( self.cyrus ) + return "failure", "undefined-condition", cyrussasl.get_message( self.cyrus ) end end