Software /
code /
prosody
Comparison
util/sasl_cyrus.lua @ 2901:5f3ccf7dd3f1
util.sasl_cyrus: Protect the call to cyrussasl.server_new properly.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 17 Mar 2010 18:57:19 -0700 |
parent | 2899:6e57f5e0cc91 |
child | 2902:c405486f289c |
comparison
equal
deleted
inserted
replaced
2899:6e57f5e0cc91 | 2901:5f3ccf7dd3f1 |
---|---|
50 | 50 |
51 init(service_name); | 51 init(service_name); |
52 | 52 |
53 sasl_i.realm = realm; | 53 sasl_i.realm = realm; |
54 sasl_i.service_name = service_name; | 54 sasl_i.service_name = service_name; |
55 sasl_i.cyrus = cyrussasl.server_new(service_name, nil, realm, nil, nil) | 55 |
56 local st, ret = pcall(cyrussasl.server_new, service_name, nil, realm, nil, nil) | |
57 if st then | |
58 sasl_i.cyrus = ret; | |
59 else | |
60 log("error", "server_new failed: %s", ret); | |
61 return nil; | |
62 end | |
56 | 63 |
57 if cyrussasl.set_canon_cb then | 64 if cyrussasl.set_canon_cb then |
58 local c14n_cb = function (user) | 65 local c14n_cb = function (user) |
59 local node = s_match(user, "^([^@]+)"); | 66 local node = s_match(user, "^([^@]+)"); |
60 log("debug", "Canonicalizing username %s to %s", user, node) | 67 log("debug", "Canonicalizing username %s to %s", user, node) |
61 return node | 68 return node |
62 end | 69 end |
63 cyrussasl.set_canon_cb(sasl_i.cyrus, c14n_cb); | 70 cyrussasl.set_canon_cb(sasl_i.cyrus, c14n_cb); |
64 end | 71 end |
65 | 72 |
66 if sasl_i.cyrus == 0 then | |
67 log("error", "got NULL return value from server_new") | |
68 return nil; | |
69 end | |
70 cyrussasl.setssf(sasl_i.cyrus, 0, 0xffffffff) | 73 cyrussasl.setssf(sasl_i.cyrus, 0, 0xffffffff) |
71 local s = setmetatable(sasl_i, method); | 74 local s = setmetatable(sasl_i, method); |
72 return s; | 75 return s; |
73 end | 76 end |
74 | 77 |