aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/array.lua4
-rw-r--r--util/broadcast.lua4
-rw-r--r--util/dataforms.lua4
-rw-r--r--util/datamanager.lua4
-rw-r--r--util/datetime.lua4
-rw-r--r--util/dependencies.lua4
-rw-r--r--util/events.lua4
-rw-r--r--util/helpers.lua4
-rw-r--r--util/hmac.lua4
-rw-r--r--util/import.lua4
-rw-r--r--util/iterators.lua4
-rw-r--r--util/jid.lua4
-rw-r--r--util/logger.lua4
-rw-r--r--util/multitable.lua4
-rw-r--r--util/pluginloader.lua4
-rw-r--r--util/prosodyctl.lua4
-rw-r--r--util/sasl.lua4
-rw-r--r--util/sasl/digest-md5.lua2
-rw-r--r--util/sasl/scram.lua1
-rw-r--r--util/sasl_cyrus.lua36
-rw-r--r--util/serialization.lua4
-rw-r--r--util/set.lua4
-rw-r--r--util/stanza.lua10
-rw-r--r--util/termcolours.lua4
-rw-r--r--util/timer.lua9
-rw-r--r--util/uuid.lua6
-rw-r--r--util/xmlrpc.lua4
-rw-r--r--util/ztact.lua4
28 files changed, 80 insertions, 72 deletions
diff --git a/util/array.lua b/util/array.lua
index 686f55b1..98c0ebe8 100644
--- a/util/array.lua
+++ b/util/array.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/broadcast.lua b/util/broadcast.lua
index 8f6af2fd..c74bf4e1 100644
--- a/util/broadcast.lua
+++ b/util/broadcast.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/dataforms.lua b/util/dataforms.lua
index 56671347..5a3b1fb5 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/datamanager.lua b/util/datamanager.lua
index a2da0aa3..01c7aab2 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/datetime.lua b/util/datetime.lua
index c582a424..cf00e4c3 100644
--- a/util/datetime.lua
+++ b/util/datetime.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/dependencies.lua b/util/dependencies.lua
index baa0cee2..6024dd63 100644
--- a/util/dependencies.lua
+++ b/util/dependencies.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/events.lua b/util/events.lua
index ef8fc30a..363d2ac6 100644
--- a/util/events.lua
+++ b/util/events.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/helpers.lua b/util/helpers.lua
index e69f1d98..11356176 100644
--- a/util/helpers.lua
+++ b/util/helpers.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/hmac.lua b/util/hmac.lua
index 18c559b2..66dd41d8 100644
--- a/util/hmac.lua
+++ b/util/hmac.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/import.lua b/util/import.lua
index d5e72eb9..81401e8b 100644
--- a/util/import.lua
+++ b/util/import.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/iterators.lua b/util/iterators.lua
index ba33bc80..318c1a96 100644
--- a/util/iterators.lua
+++ b/util/iterators.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/jid.lua b/util/jid.lua
index b43247cc..ba9730fa 100644
--- a/util/jid.lua
+++ b/util/jid.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/logger.lua b/util/logger.lua
index a73c7eec..fb0bc37b 100644
--- a/util/logger.lua
+++ b/util/logger.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/multitable.lua b/util/multitable.lua
index 49659605..66b9bd8a 100644
--- a/util/multitable.lua
+++ b/util/multitable.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/pluginloader.lua b/util/pluginloader.lua
index 8c22c204..90138a3e 100644
--- a/util/pluginloader.lua
+++ b/util/pluginloader.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/prosodyctl.lua b/util/prosodyctl.lua
index 0776fc76..04d58d1d 100644
--- a/util/prosodyctl.lua
+++ b/util/prosodyctl.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/sasl.lua b/util/sasl.lua
index 9c8fff78..eb71956b 100644
--- a/util/sasl.lua
+++ b/util/sasl.lua
@@ -1,5 +1,5 @@
-- sasl.lua v0.4
--- Copyright (C) 2008-2009 Tobias Markmann
+-- Copyright (C) 2008-2010 Tobias Markmann
--
-- All rights reserved.
--
@@ -143,7 +143,7 @@ function method:process(message)
end
-- load the mechanisms
-load_mechs = {"plain", "digest-md5", "anonymous", "scram"}
+local load_mechs = {"plain", "digest-md5", "anonymous", "scram"}
for _, mech in ipairs(load_mechs) do
local name = "util.sasl."..mech;
local m = require(name);
diff --git a/util/sasl/digest-md5.lua b/util/sasl/digest-md5.lua
index 5b8f5c8a..04acf04d 100644
--- a/util/sasl/digest-md5.lua
+++ b/util/sasl/digest-md5.lua
@@ -35,8 +35,6 @@ local function digest(self, message)
local function serialize(message)
local data = ""
- if type(message) ~= "table" then error("serialize needs an argument of type table.") end
-
-- testing all possible values
if message["realm"] then data = data..[[realm="]]..message.realm..[[",]] end
if message["nonce"] then data = data..[[nonce="]]..message.nonce..[[",]] end
diff --git a/util/sasl/scram.lua b/util/sasl/scram.lua
index 4f800529..103e8a90 100644
--- a/util/sasl/scram.lua
+++ b/util/sasl/scram.lua
@@ -15,7 +15,6 @@ local s_match = string.match;
local type = type
local string = string
local base64 = require "util.encodings".base64;
-local xor = require "bit".bxor
local hmac_sha1 = require "util.hmac".sha1;
local sha1 = require "util.hashes".sha1;
local generate_uuid = require "util.uuid".generate;
diff --git a/util/sasl_cyrus.lua b/util/sasl_cyrus.lua
index 57c6ba3c..b5f505eb 100644
--- a/util/sasl_cyrus.lua
+++ b/util/sasl_cyrus.lua
@@ -39,24 +39,37 @@ local function init(service_name)
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
-- create a new SASL object which can be used to authenticate clients
-function new(realm, service_name)
+function new(realm, service_name, app_name)
local sasl_i = {};
- init(service_name);
+ init(app_name or service_name);
sasl_i.realm = realm;
sasl_i.service_name = service_name;
- sasl_i.cyrus = cyrussasl.server_new(service_name, nil, nil, nil, nil)
- if sasl_i.cyrus == 0 then
- log("error", "got NULL return value from server_new")
+
+ 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)
+ local node = s_match(user, "^([^@]+)");
+ log("debug", "Canonicalizing username %s to %s", user, node)
+ return node
+ end
+ cyrussasl.set_canon_cb(sasl_i.cyrus, c14n_cb);
+ end
+
cyrussasl.setssf(sasl_i.cyrus, 0, 0xffffffff)
local s = setmetatable(sasl_i, method);
return s;
@@ -69,7 +82,7 @@ end
-- set the forbidden mechanisms
function method:forbidden( restrict )
- log("debug", "Called method:forbidden. NOT IMPLEMENTED.")
+ log("warn", "Called method:forbidden. NOT IMPLEMENTED.")
return {}
end
@@ -87,6 +100,7 @@ end
-- select a mechanism to use
function method:select(mechanism)
self.mechanism = mechanism;
+ if not self.mechs then self:mechanisms(); end
return self.mechs[mechanism];
end
@@ -109,16 +123,12 @@ function method:process(message)
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
diff --git a/util/serialization.lua b/util/serialization.lua
index 7071d3f7..bad2fe43 100644
--- a/util/serialization.lua
+++ b/util/serialization.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/set.lua b/util/set.lua
index 5f7a9ae2..ee154ece 100644
--- a/util/set.lua
+++ b/util/set.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/stanza.lua b/util/stanza.lua
index 065888d0..08ef2c9a 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
@@ -247,14 +247,14 @@ function deserialize(stanza)
for i=1,#attr do attr[i] = nil; end
local attrx = {};
for att in pairs(attr) do
- if s_find(att, "|", 1, true) and not s_find(k, "\1", 1, true) then
- local ns,na = s_match(k, "^([^|]+)|(.+)$");
+ if s_find(att, "|", 1, true) and not s_find(att, "\1", 1, true) then
+ local ns,na = s_match(att, "^([^|]+)|(.+)$");
attrx[ns.."\1"..na] = attr[att];
attr[att] = nil;
end
end
for a,v in pairs(attrx) do
- attr[x] = v;
+ attr[a] = v;
end
setmetatable(stanza, stanza_mt);
for _, child in ipairs(stanza) do
diff --git a/util/termcolours.lua b/util/termcolours.lua
index 905b70a6..4e267bee 100644
--- a/util/termcolours.lua
+++ b/util/termcolours.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/timer.lua b/util/timer.lua
index c52d9c68..fa1dd7c5 100644
--- a/util/timer.lua
+++ b/util/timer.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
@@ -55,11 +55,12 @@ if not event then
else
local EVENT_LEAVE = (event.core and event.core.LEAVE) or -1;
function _add_task(delay, func)
- event_base:addevent(nil, 0, function ()
+ local event_handle;
+ event_handle = event_base:addevent(nil, 0, function ()
local ret = func();
if ret then
return 0, ret;
- else
+ elseif event_handle then
return EVENT_LEAVE;
end
end
diff --git a/util/uuid.lua b/util/uuid.lua
index 19bf2234..796c8ee4 100644
--- a/util/uuid.lua
+++ b/util/uuid.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
@@ -32,7 +32,7 @@ local function _seed(x)
buffer = new_random(buffer..x);
end
local function get_nibbles(n)
- if #buffer < n then seed(uniq_time()); end
+ if #buffer < n then _seed(uniq_time()); end
local r = buffer:sub(0, n);
buffer = buffer:sub(n+1);
return r;
diff --git a/util/xmlrpc.lua b/util/xmlrpc.lua
index 4855b323..29815b0d 100644
--- a/util/xmlrpc.lua
+++ b/util/xmlrpc.lua
@@ -1,6 +1,6 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
diff --git a/util/ztact.lua b/util/ztact.lua
index 35902ba1..2507bf8e 100644
--- a/util/ztact.lua
+++ b/util/ztact.lua
@@ -114,7 +114,7 @@ function tohex (s) -- - - - - - - - - - - - - - - - - - - - - - - - - tohex
function tostring_r (d, indent, tab0) -- - - - - - - - - - - - - tostring_r
- tab1 = tab0 or {}
+ local tab1 = tab0 or {}
local rep = string.rep (' ', indent or 0)
if type (d) == 'table' then
for k,v in pairs (d) do
@@ -210,7 +210,7 @@ function enqueue (queue, element) -- - - - - - - - - - - - - - - - - enqueue
local function test_queue ()
- t = {}
+ local t = {}
enqueue (t, 1)
enqueue (t, 2)
enqueue (t, 3)