From 27991d0a7b03692045378f083f37bbe5b8ac4cef Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 27 Feb 2010 19:46:04 +0000 Subject: prosody: Bump log message describing current connection backend to level 'info' --- prosody | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prosody b/prosody index 49580bd9..b13369a9 100755 --- a/prosody +++ b/prosody @@ -308,7 +308,7 @@ function init_data_store() end function prepare_to_start() - log("debug", "Prosody is using the %s backend for connection handling", server.get_backend()); + log("info", "Prosody is using the %s backend for connection handling", server.get_backend()); -- Signal to modules that we are ready to start eventmanager.fire_event("server-starting"); prosody.events.fire_event("server-starting"); -- cgit v1.2.3 From 969ea466e40a8e624228cc4631fb03808ac884f3 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Mon, 1 Mar 2010 18:37:47 +0500 Subject: util.sasl_cyrus: Ensure the mechanisms table is available after a failed auth attempt. --- util/sasl_cyrus.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/util/sasl_cyrus.lua b/util/sasl_cyrus.lua index 57c6ba3c..980af598 100644 --- a/util/sasl_cyrus.lua +++ b/util/sasl_cyrus.lua @@ -87,6 +87,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 -- cgit v1.2.3 From b73fce8d46e187ce41712346b49e6778cca135a9 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 1 Mar 2010 16:02:59 +0000 Subject: mod_saslauth: Unlock globals while loading cyrus --- plugins/mod_saslauth.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index 0f4c8b4b..0f809bd8 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -36,7 +36,9 @@ local xmlns_stanzas ='urn:ietf:params:xml:ns:xmpp-stanzas'; local new_sasl; if sasl_backend == "cyrus" then + prosody.unlock_globals(); local ok, cyrus = pcall(require, "util.sasl_cyrus"); + prosody.lock_globals(); if ok then local cyrus_new = cyrus.new; new_sasl = function(realm) -- cgit v1.2.3 From bd1934e306403d34aec93682f290fd06c0784348 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 1 Mar 2010 16:23:26 +0000 Subject: mod_saslauth: Add FIXME to remind myself to fix this as soon as I have time --- plugins/mod_saslauth.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index 0f809bd8..0cae5833 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -36,7 +36,8 @@ local xmlns_stanzas ='urn:ietf:params:xml:ns:xmpp-stanzas'; local new_sasl; if sasl_backend == "cyrus" then - prosody.unlock_globals(); + prosody.unlock_globals(); --FIXME: Figure out why this is needed and + -- why cyrussasl isn't caught by the sandbox local ok, cyrus = pcall(require, "util.sasl_cyrus"); prosody.lock_globals(); if ok then -- cgit v1.2.3 From f1871510b798f5dbe8fa6263fe2e9478c1cdac6d Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 1 Mar 2010 16:45:13 +0000 Subject: net.server_event: Improve and fix potential traceback in logging of new incoming connections --- net/server_event.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/server_event.lua b/net/server_event.lua index d041ae43..70435f38 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -671,16 +671,16 @@ do debug( "maximal connections reached, refuse client connection; accept delay:", delay ) return EV_TIMEOUT, delay -- delay for next accept attemp end - local ip, port = client:getpeername( ) + local client_ip, client_port = client:getpeername( ) interface._connections = interface._connections + 1 -- increase connection count - local clientinterface = handleclient( client, ip, port, interface, pattern, listener, nil, sslctx ) + local clientinterface = handleclient( client, client_ip, client_port, interface, pattern, listener, nil, sslctx ) --vdebug( "client id:", clientinterface, "startssl:", startssl ) if ssl and sslctx then clientinterface:starttls(sslctx) else clientinterface:_start_session( clientinterface.onconnect ) end - debug( "accepted incoming client connection from:", ip, port ) + debug( "accepted incoming client connection from:", client_ip or "", client_port or "", "to", port or ""); client, err = server:accept() -- try to accept again end -- cgit v1.2.3 From 9d6219b596ccf58fc409a7a84b6063b1c2955222 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 1 Mar 2010 18:06:54 +0000 Subject: net.server_select: Fix calling method of some handler.close()s --- net/server_select.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/server_select.lua b/net/server_select.lua index 685cd13e..ca8b1113 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -435,7 +435,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport local len = string_len( buffer ) if len > maxreadlen then disconnect( handler, "receive buffer exceeded" ) - handler.close( true ) + handler:close( true ) return false end local count = len * STAT_UNIT @@ -448,7 +448,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport out_put( "server.lua: client ", tostring(ip), ":", tostring(clientport), " read error: ", tostring(err) ) fatalerror = true disconnect( handler, err ) - _ = handler and handler.close( ) + _ = handler and handler:close( ) return false end end @@ -472,7 +472,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- delete socket from writelist _ = needtls and handler:starttls(nil, true) _writetimes[ handler ] = nil - _ = toclose and handler.close( ) + _ = toclose and handlerclose( ) return true elseif byte and ( err == "timeout" or err == "wantwrite" ) then -- want write buffer = string_sub( buffer, byte + 1, bufferlen ) -- new buffer @@ -485,7 +485,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport out_put( "server.lua: client ", tostring(ip), ":", tostring(clientport), " write error: ", tostring(err) ) fatalerror = true disconnect( handler, err ) - _ = handler and handler.close( ) + _ = handler and handler:close( ) return false end end -- cgit v1.2.3 From 8db085eb2976736ab1ef118b203d2832c3107334 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 1 Mar 2010 18:07:37 +0000 Subject: mod_proxy65: Fix for old-style closing of connections (another source of tracebacks with libevent enabled) --- plugins/mod_proxy65.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/mod_proxy65.lua b/plugins/mod_proxy65.lua index 2cfbe7b6..5c9ae329 100644 --- a/plugins/mod_proxy65.lua +++ b/plugins/mod_proxy65.lua @@ -91,12 +91,12 @@ function connlistener.onincoming(conn, data) conn:lock_read(true) else module:log("warn", "Neither data transfer nor initial connect of a participator of a transfer.") - conn.close(); + conn:close(); end else if data ~= nil then module:log("warn", "unknown connection with no authentication data -> closing it"); - conn.close(); + conn:close(); end end end @@ -107,9 +107,9 @@ function connlistener.ondisconnect(conn, err) if session.sha and transfers[session.sha] then local initiator, target = transfers[session.sha].initiator, transfers[session.sha].target; if initiator == conn and target ~= nil then - target.close(); + target:close(); elseif target == conn and initiator ~= nil then - initiator.close(); + initiator:close(); end transfers[session.sha] = nil; end -- cgit v1.2.3 From 52817c55177ca4ad795705a89d1d8a1a40e9688b Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 1 Mar 2010 18:46:37 +0000 Subject: net.server_event: Fix some global accesses --- net/server_event.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/server_event.lua b/net/server_event.lua index 70435f38..b767cb20 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -543,7 +543,7 @@ do local callback = function( ) interface:_close() interface.eventwritetimeout = nil - return evreturn, evtimeout + return -1; end interface.eventwritetimeout = addevent( base, nil, EV_TIMEOUT, callback, cfg.WRITE_TIMEOUT ) -- reg a new timeout event debug( "wantread during write attemp, reg it in readcallback but dont know what really happens next..." ) @@ -762,7 +762,7 @@ do local server = function( ) return nil, "this is a dummy server interface" end - local interface = wrapclient( client, ip, serverport, listeners, pattern, sslctx, startssl ) + local interface = wrapclient( client, ip, serverport, listener, pattern, sslctx, startssl ) interface:_start_connection( startssl ) debug( "new connection id:", interface.id ) return interface, err -- cgit v1.2.3 From 70e49af539d114e02baa8c7105d83e2728af18da Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 1 Mar 2010 18:47:03 +0000 Subject: net.server_select: Fix typo --- net/server_select.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/server_select.lua b/net/server_select.lua index ca8b1113..c4a1f19a 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -472,7 +472,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- delete socket from writelist _ = needtls and handler:starttls(nil, true) _writetimes[ handler ] = nil - _ = toclose and handlerclose( ) + _ = toclose and handler:close( ) return true elseif byte and ( err == "timeout" or err == "wantwrite" ) then -- want write buffer = string_sub( buffer, byte + 1, bufferlen ) -- new buffer -- cgit v1.2.3 From c91f1d749438074f54d27352a74971034e1b2a3a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 1 Mar 2010 18:52:47 +0000 Subject: certmanager: Fix global access --- core/certmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/certmanager.lua b/core/certmanager.lua index 5794ba6e..c2db63fe 100644 --- a/core/certmanager.lua +++ b/core/certmanager.lua @@ -54,7 +54,7 @@ function create_context(host, mode, config) end function reload_ssl_config() - default_ssl_config = config.get("*", "core", "ssl"); + default_ssl_config = configmanager.get("*", "core", "ssl"); end prosody.events.add_handler("config-reloaded", reload_ssl_config); -- cgit v1.2.3 From 675aab41f91a524d114f43ded53569f9496197f2 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Tue, 2 Mar 2010 00:50:54 +0500 Subject: util.stanza: Fixed nil global accesses. --- util/stanza.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/stanza.lua b/util/stanza.lua index 065888d0..ad982d42 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -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 -- cgit v1.2.3 From 29e84d0af11fad1c6091340978065b7586193228 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Tue, 2 Mar 2010 00:51:27 +0500 Subject: util.sasl: Fixed a nil global access. --- util/sasl.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/sasl.lua b/util/sasl.lua index 9c8fff78..2aa7fa1f 100644 --- a/util/sasl.lua +++ b/util/sasl.lua @@ -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); -- cgit v1.2.3 From 08ee982159bc6f4c83b9d9abef1ee39933e95a17 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Tue, 2 Mar 2010 14:08:32 +0500 Subject: mod_offline: Convert to Unix line endings. --- plugins/mod_offline.lua | 94 ++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/plugins/mod_offline.lua b/plugins/mod_offline.lua index c74d011e..24aef9ed 100644 --- a/plugins/mod_offline.lua +++ b/plugins/mod_offline.lua @@ -6,51 +6,51 @@ -- COPYING file in the source package for more information. -- - -local datamanager = require "util.datamanager"; -local st = require "util.stanza"; -local datetime = require "util.datetime"; + +local datamanager = require "util.datamanager"; +local st = require "util.stanza"; +local datetime = require "util.datetime"; local ipairs = ipairs; -local jid_split = require "util.jid".split; - -module:add_feature("msgoffline"); - -module:hook("message/offline/store", function(event) - local origin, stanza = event.origin, event.stanza; - local to = stanza.attr.to; - local node, host; - if to then - node, host = jid_split(to) - else - node, host = origin.username, origin.host; - end - - stanza.attr.stamp, stanza.attr.stamp_legacy = datetime.datetime(), datetime.legacy(); - local result = datamanager.list_append(node, host, "offline", st.preserialize(stanza)); - stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil; - - return true; -end); - -module:hook("message/offline/broadcast", function(event) - local origin = event.origin; - local node, host = origin.username, origin.host; - - local data = datamanager.list_load(node, host, "offline"); - if not data then return true; end - for _, stanza in ipairs(data) do - stanza = st.deserialize(stanza); - stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203 - stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated) - stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil; - origin.send(stanza); - end - return true; -end); - -module:hook("message/offline/delete", function(event) - local origin = event.origin; - local node, host = origin.username, origin.host; - - return datamanager.list_store(node, host, "offline", nil); -end); +local jid_split = require "util.jid".split; + +module:add_feature("msgoffline"); + +module:hook("message/offline/store", function(event) + local origin, stanza = event.origin, event.stanza; + local to = stanza.attr.to; + local node, host; + if to then + node, host = jid_split(to) + else + node, host = origin.username, origin.host; + end + + stanza.attr.stamp, stanza.attr.stamp_legacy = datetime.datetime(), datetime.legacy(); + local result = datamanager.list_append(node, host, "offline", st.preserialize(stanza)); + stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil; + + return true; +end); + +module:hook("message/offline/broadcast", function(event) + local origin = event.origin; + local node, host = origin.username, origin.host; + + local data = datamanager.list_load(node, host, "offline"); + if not data then return true; end + for _, stanza in ipairs(data) do + stanza = st.deserialize(stanza); + stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203 + stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated) + stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil; + origin.send(stanza); + end + return true; +end); + +module:hook("message/offline/delete", function(event) + local origin = event.origin; + local node, host = origin.username, origin.host; + + return datamanager.list_store(node, host, "offline", nil); +end); -- cgit v1.2.3 From 0851470da34275f60ff5c0eacf8ff53193d77500 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 5 Mar 2010 14:49:56 +0000 Subject: certmanager: Fix nil global access (thanks Marc) --- core/certmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/certmanager.lua b/core/certmanager.lua index c2db63fe..7b7d95e4 100644 --- a/core/certmanager.lua +++ b/core/certmanager.lua @@ -3,7 +3,7 @@ local log = require "util.logger".init("certmanager"); local ssl = ssl; local ssl_newcontext = ssl and ssl.newcontext; -local setmetatable = setmetatable; +local setmetatable, tostring = setmetatable, tostring; local prosody = prosody; -- cgit v1.2.3 From 1967ba02a55f3b3d326020b27c73fcab78e0262d Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 5 Mar 2010 15:00:11 +0000 Subject: certmanager: Friendlier error reporting on OpenWRT and other cases where we don't understand the OpenSSL error --- core/certmanager.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/certmanager.lua b/core/certmanager.lua index 7b7d95e4..fa920b91 100644 --- a/core/certmanager.lua +++ b/core/certmanager.lua @@ -39,8 +39,10 @@ function create_context(host, mode, config) reason = "Check that the path is correct, and the file exists."; elseif reason == "system lib" then reason = "Previous error (see logs), or other system error."; + elseif reason == "(null)" or not reason then + reason = "Check that the file exists and the permissions are correct"; else - reason = "Reason: "..tostring(reason or "unknown"):lower(); + reason = "Reason: "..tostring(reason):lower(); end log("error", "SSL/TLS: Failed to load %s: %s", file, reason); else -- cgit v1.2.3 From c071b4638d4a78d9c7e76ae973553e04cb5e22b6 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 5 Mar 2010 16:45:46 +0000 Subject: net.server_select: Fix for traceback when a read returns an error and no data (thanks dersd) --- net/server_select.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/server_select.lua b/net/server_select.lua index c4a1f19a..49cbe25d 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -430,7 +430,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport end local _readbuffer = function( ) -- this function reads data local buffer, err, part = receive( socket, pattern ) -- receive buffer with "pattern" - if not err or (err == "wantread" or err == "timeout") or string_len(part) > 0 then -- received something + if not err or (err == "wantread" or err == "timeout") or (part and string_len(part) > 0) then -- received something local buffer = buffer or part or "" local len = string_len( buffer ) if len > maxreadlen then -- cgit v1.2.3 From 322f02b17fac1dc673a1250ddbc4a954dec98696 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 5 Mar 2010 18:15:08 +0000 Subject: net.dns: More reliable parsing of resolv.conf - allow multiple nameserver IPs on one line (thanks dersd) --- net/dns.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/dns.lua b/net/dns.lua index ca5f3c62..7d1cba8e 100644 --- a/net/dns.lua +++ b/net/dns.lua @@ -538,8 +538,13 @@ function resolver:adddefaultnameservers() -- - - - - adddefaultnameservers local resolv_conf = io.open("/etc/resolv.conf"); if resolv_conf then for line in resolv_conf:lines() do - local address = line:gsub("#.*$", ""):match('^%s*nameserver%s+(%d+%.%d+%.%d+%.%d+)%s*$'); - if address then self:addnameserver(address) end + line = line:gsub("#.*$", "") + :match('^%s*nameserver%s+(.*)%s*$'); + if line then + line:gsub("%f[%d.](%d+%.%d+%.%d+%.%d+)%f[^%d.]", function (address) + self:addnameserver(address) + end); + end end end if not self.server or #self.server == 0 then -- cgit v1.2.3 From a201db970b44ac05204b19aa1c3fa973ea6e2e2a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 5 Mar 2010 18:33:28 +0000 Subject: net.dns: Trailing whitespace --- net/dns.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/dns.lua b/net/dns.lua index 7d1cba8e..8855cc61 100644 --- a/net/dns.lua +++ b/net/dns.lua @@ -532,7 +532,7 @@ function resolver:adddefaultnameservers() -- - - - - adddefaultnameservers if not self.server or #self.server == 0 then -- TODO log warning about no nameservers, adding opendns servers as fallback self:addnameserver("208.67.222.222"); - self:addnameserver("208.67.220.220") ; + self:addnameserver("208.67.220.220"); end else -- posix local resolv_conf = io.open("/etc/resolv.conf"); @@ -801,7 +801,7 @@ function resolver:feed(sock, packet) set(self.wanted, q.class, q.type, q.name, nil); end end - end + end return response; end -- cgit v1.2.3