From 259f3e40c1830ba61195ffa78180cb2b16fde730 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 31 Mar 2013 20:04:09 +0200 Subject: configure: Set to run with lua5.1 in the debian preset --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index df62cc05..5c6439fc 100755 --- a/configure +++ b/configure @@ -95,6 +95,7 @@ do if [ "$OSTYPE" = "debian" ] then LUA_SUFFIX="5.1"; LUA_SUFFIX_SET=yes + RUNWITH="lua5.1" LUA_INCDIR=/usr/include/lua5.1; LUA_INCDIR_SET=yes CFLAGS="$CFLAGS -D_GNU_SOURCE" -- cgit v1.2.3 From b9c102c4b595ed1ed9f8877e97456959decf7c80 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 31 Mar 2013 20:09:14 +0200 Subject: tools/migration/Makefile: Apply Lua runtime override (see 53f741a5a73a) --- tools/migration/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/migration/Makefile b/tools/migration/Makefile index 5998a5f7..ae402bd2 100644 --- a/tools/migration/Makefile +++ b/tools/migration/Makefile @@ -29,7 +29,8 @@ clean: rm -f migrator.cfg.lua.install prosody-migrator.install: prosody-migrator.lua - sed "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|; \ + sed "1s/\blua\b/$(RUNWITH)/; \ + s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|; \ s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(INSTALLEDCONFIG)';|;" \ < prosody-migrator.lua > prosody-migrator.install -- cgit v1.2.3 From 4f1aec34615176afeecc04a368f5245ff453786d Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 31 Mar 2013 13:43:12 +0100 Subject: AUTHORS: A small update... --- AUTHORS | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 0875361d..3ead470b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,4 +1,10 @@ -== Core development team == -Matthew Wild (matthew.wild AT heavy-horse.co.uk) -Waqas Hussain (waqas20 AT gmail.com) +The Prosody project is open to contributions (see HACKERS file), but is +maintained daily by: + + - Matthew Wild (mail: matthew [at] prosody.im) + - Waqas Hussain (mail: waqas [at] prosody.im) + - Kim Alvefur (mail: zash [at] prosody.im) + +You can reach us collectively by email: developers [at] prosody.im +or in realtime in the Prosody chatroom: prosody@conference.prosody.im -- cgit v1.2.3 From 48475bcf224c977e510409603e12870916148e2e Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 31 Mar 2013 13:45:04 +0100 Subject: net.http.server: Don't overwrite existing response.headers when returning a response object from a HTTP handler (waqas says it's wrong) --- net/http/server.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/http/server.lua b/net/http/server.lua index 87d82418..20c2da3e 100644 --- a/net/http/server.lua +++ b/net/http/server.lua @@ -219,7 +219,13 @@ function handle_request(conn, request, finish_cb) body = result; elseif result_type == "table" then for k, v in pairs(result) do - response[k] = v; + if k ~= "headers" then + response[k] = v; + else + for header_name, header_value in pairs(v) do + response.headers[header_name] = header_value; + end + end end end response:send(body); -- cgit v1.2.3 From 30f282f7b87119a861ef77b5d5bdba3ed4b01161 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 31 Mar 2013 13:45:57 +0100 Subject: TODO: Remove 0.9 --- TODO | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/TODO b/TODO index 40e775a3..d22d20f4 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,5 @@ -== 0.9 == -- IPv6 -- SASL EXTERNAL -- Roster providers -- Web interface - == 1.0 == +- Roster providers - Statistics - Clustering - World domination -- cgit v1.2.3 From 1d5c18148001c64bc8105deea6b83ccd4e05a3b0 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 31 Mar 2013 13:49:33 +0100 Subject: DEPENDS: Update (LuaSec now has a rock) and add link to /doc/depends --- DEPENDS | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/DEPENDS b/DEPENDS index e7035430..ba125904 100644 --- a/DEPENDS +++ b/DEPENDS @@ -1,9 +1,11 @@ -The easiest way to install dependencies is using the luarocks tool. -Rocks: -luaexpat -luasocket -luafilesystem +For full information on our dependencies, version requirements, and +where to find them, see http://prosody.im/doc/depends + +If you have luarocks available on your platform, install the following: + + - luaexpat + - luasocket + - luafilesystem + - luasec -Non-rocks: -LuaSec for SSL connections -- cgit v1.2.3 From c50b122ecbab33c0149f160b3d1209fd1b39dbbb Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 31 Mar 2013 22:40:01 +0100 Subject: INSTALL: Update from wiki --- INSTALL | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/INSTALL b/INSTALL index 089e3133..f0fa894d 100644 --- a/INSTALL +++ b/INSTALL @@ -1,18 +1,18 @@ -(This file was created from -http://prosody.im/doc/installing_from_source on 2012-05-12) +(This file was created from +http://prosody.im/doc/installing_from_source on 2013-03-31) -===== Building ===== +====== Installing from source ====== ==== Dependencies ==== There are a couple of libraries which Prosody needs installed before you can build it. These are: - * lua5.1: The interpreter + * lua5.1: The Lua 5.1 interpreter * liblua5.1: Lua 5.1 library * libssl 0.9.8: OpenSSL * libidn11: GNU libidn library, version 1.1 -These can be installed on Debian/Ubuntu with the packages: -lua5.1 liblua5.1-dev libidn11-dev libssl-dev +These can be installed on Debian/Ubuntu with the packages: lua5.1 +liblua5.1-dev libidn11-dev libssl-dev On Mandriva try: urpmi lua liblua-devel libidn-devel libopenssl-devel @@ -33,7 +33,8 @@ accepts. You can load a preset using: ./configure --ostype=PRESET -Where PRESET can currently be one of: debian, macosx or freebsd +Where PRESET can currently be one of: 'debian', 'macosx' or (in 0.8 +and later) 'freebsd' ==== make ==== Once you have run configure successfully, then you can simply run: -- cgit v1.2.3 From 4a4f2e8b4be13b33ece64f1d33050cc56349397e Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 1 Apr 2013 14:45:59 +0100 Subject: mod_s2s: Close incoming s2s with stream error when secure and we don't trust their certificate --- plugins/mod_s2s/mod_s2s.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua index 6893d184..639f464b 100644 --- a/plugins/mod_s2s/mod_s2s.lua +++ b/plugins/mod_s2s/mod_s2s.lua @@ -632,7 +632,11 @@ function check_auth_policy(event) if must_secure and not session.cert_identity_status then module:log("warn", "Forbidding insecure connection to/from %s", host); - session:close(false); + if session.direction == "incoming" then + session:close({ condition = "not-authorized", text = "Your server's certificate is invalid, expired, or not trusted by"..session.to_host }); + else -- Close outgoing connections without warning + session:close(false); + end return false; end end -- cgit v1.2.3 From 96435e9959a699e54a2e46f71039b382feb45eb4 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 1 Apr 2013 14:51:42 +0100 Subject: prosody.cfg.lua.dist: Update with new options and comments --- prosody.cfg.lua.dist | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/prosody.cfg.lua.dist b/prosody.cfg.lua.dist index 9ca9608a..3c199f3e 100644 --- a/prosody.cfg.lua.dist +++ b/prosody.cfg.lua.dist @@ -41,6 +41,8 @@ modules_enabled = { -- Not essential, but recommended "private"; -- Private XML storage (for room bookmarks, etc.) "vcard"; -- Allow users to set vCards + + -- These are commented by default as they have a performance impact --"privacy"; -- Support privacy lists --"compression"; -- Stream compression @@ -51,7 +53,6 @@ modules_enabled = { "ping"; -- Replies to XMPP pings with pongs "pep"; -- Enables users to publish their mood, activity, playing music and more "register"; -- Allow users to register on this server using a client and change passwords - "adhoc"; -- Support for "ad-hoc commands" that can be executed with an XMPP client -- Admin interfaces "admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands @@ -71,14 +72,12 @@ modules_enabled = { --"legacyauth"; -- Legacy authentication. Only used by some old clients and bots. }; --- These modules are auto-loaded, should you --- (for some mad reason) want to disable --- them then uncomment them below +-- These modules are auto-loaded, but should you want +-- to disable them then uncomment them here: modules_disabled = { - -- "presence"; -- Route user/contact status information - -- "message"; -- Route messages - -- "iq"; -- Route info queries -- "offline"; -- Store offline messages + -- "c2s"; -- Handle client connections + -- "s2s"; -- Handle server-to-server connections }; -- Disable account creation by default, for security @@ -92,14 +91,28 @@ ssl = { certificate = "certs/localhost.crt"; } --- Only allow encrypted streams? Encryption is already used when --- available. These options will cause Prosody to deny connections that --- are not encrypted. Note that some servers do not support s2s --- encryption or have it disabled, including gmail.com and Google Apps --- domains. +-- Force clients to use encrypted connections? This option will +-- prevent clients from authenticating unless they are using encryption. + +c2s_require_encryption = false + +-- Force certificate authentication for server-to-server connections? +-- This provides ideal security, but requires servers you communicate +-- with to support encryption AND present valid, trusted certificates. +-- For more information see http://prosody.im/doc/s2s#security + +s2s_secure = true + +-- Many servers don't support encryption or have invalid or self-signed +-- certificates. You can list domains here that will not be required to +-- authenticate using certificates. They will be authenticated using DNS. + +-- s2s_insecure_domains = { "gmail.com" } + +-- Even if you leave s2s_secure disabled, you can still require it for +-- some domains by specifying a list here. ---c2s_require_encryption = false ---s2s_require_encryption = false +-- s2s_secure_domains = { "jabber.org" } -- Select the authentication backend to use. The 'internal' providers -- use Prosody's configured data storage to store the authentication data. -- cgit v1.2.3 From 2a5ae358a2fbb0968e51efaf94ba4688dfc6de63 Mon Sep 17 00:00:00 2001 From: Marco Cirillo Date: Mon, 1 Apr 2013 22:34:44 +0000 Subject: modulemanager: add function to retrieve module items from a specific host entity. --- core/modulemanager.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 35b9d0e5..48afe787 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -19,7 +19,7 @@ local prosody = prosody; local pcall, xpcall = pcall, xpcall; local setmetatable, rawget = setmetatable, rawget; -local pairs, type, tostring = pairs, type, tostring; +local pairs, type, tostring, t_insert = pairs, type, tostring, table.insert; local debug_traceback = debug.traceback; local unpack, select = unpack, select; @@ -278,6 +278,23 @@ function get_module(host, name) return modulemap[host] and modulemap[host][name]; end +function get_items(key, host) + local result = {}; + local modules = modulemap[host]; + if not key or not host or not modules then return nil; end + + for _, module in pairs(modules) do + local mod = module.module; + if mod.items and mod.items[key] then + for _, value in ipairs(mod.items[key]) do + t_insert(result, value); + end + end + end + + return result; +end + function get_modules(host) return modulemap[host]; end -- cgit v1.2.3 From bf1ce76f609162874ec87bd3dbbf81442bcd0be0 Mon Sep 17 00:00:00 2001 From: Marco Cirillo Date: Mon, 1 Apr 2013 23:41:57 +0000 Subject: modulemanager: add missing ipairs import. --- core/modulemanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 48afe787..535c227b 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -19,7 +19,7 @@ local prosody = prosody; local pcall, xpcall = pcall, xpcall; local setmetatable, rawget = setmetatable, rawget; -local pairs, type, tostring, t_insert = pairs, type, tostring, table.insert; +local ipairs, pairs, type, tostring, t_insert = ipairs, pairs, type, tostring, table.insert; local debug_traceback = debug.traceback; local unpack, select = unpack, select; -- cgit v1.2.3 From 42cb071edebdd42fa570992989658bc45d7d6bac Mon Sep 17 00:00:00 2001 From: Marco Cirillo Date: Mon, 1 Apr 2013 23:44:28 +0000 Subject: moduleapi: have get_host_items wrap on get_items from modulemanager, also add has_{feature/identity} to the API. --- core/moduleapi.lua | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/core/moduleapi.lua b/core/moduleapi.lua index f9701471..de900bf0 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -62,6 +62,20 @@ end function api:add_extension(data) self:add_item("extension", data); end +function api:has_feature(xmlns) + for _, feature in ipairs(self:get_host_items("feature")) do + if feature == xmlns then return true; end + end + return false; +end +function api:has_identity(category, type, name) + for _, id in ipairs(self:get_host_items("identity")) do + if id.category == category and id.type == type and id.name == name then + return true; + end + end + return false; +end function api:fire_event(...) return (hosts[self.host] or prosody).events.fire_event(...); @@ -271,23 +285,7 @@ function api:remove_item(key, value) end function api:get_host_items(key) - local result = {}; - for mod_name, module in pairs(modulemanager.get_modules(self.host)) do - module = module.module; - if module.items then - for _, item in ipairs(module.items[key] or NULL) do - t_insert(result, item); - end - end - end - for mod_name, module in pairs(modulemanager.get_modules("*")) do - module = module.module; - if module.items then - for _, item in ipairs(module.items[key] or NULL) do - t_insert(result, item); - end - end - end + local result = modulemanager.get_items(key, self.host) or {}; return result; end -- cgit v1.2.3 From 9778882628ef1478c084414248da1c889cd981d0 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 3 Apr 2013 08:14:55 +0100 Subject: configmanager: Some cleanup, remove unused variables and imports --- core/configmanager.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/configmanager.lua b/core/configmanager.lua index e31dbd72..9720f48a 100644 --- a/core/configmanager.lua +++ b/core/configmanager.lua @@ -7,8 +7,8 @@ -- local _G = _G; -local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table = - setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table; +local setmetatable, rawget, rawset, io, error, dofile, type, pairs, table = + setmetatable, rawget, rawset, io, error, dofile, type, pairs, table; local format, math_max = string.format, math.max; local fire_event = prosody and prosody.events.fire_event or function () end; @@ -68,7 +68,6 @@ end -- Helper function to resolve relative paths (needed by config) do - local rel_path_start = ".."..path_sep; function resolve_relative_path(parent_path, path) if path then -- Some normalization @@ -152,7 +151,7 @@ end -- Built-in Lua parser do local pcall, setmetatable = _G.pcall, _G.setmetatable; - local rawget, tostring = _G.rawget, _G.tostring; + local rawget = _G.rawget; parsers.lua = {}; function parsers.lua.load(data, config_file, config) local env; @@ -213,7 +212,7 @@ do end env.component = env.Component; - function env.Include(file, wildcard) + function env.Include(file) if file:match("[*?]") then local path_pos, glob = file:match("()([^"..path_sep.."]+)$"); local path = file:sub(1, math_max(path_pos-2,0)); -- cgit v1.2.3 From 71e3455f55f0ca9b25ba9ce3a9068f636773b555 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 3 Apr 2013 13:38:27 +0100 Subject: util.stanza: :maptags(): Fixes to make loop more robust on item removal --- util/stanza.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/stanza.lua b/util/stanza.lua index a0ab2a5a..213ed506 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -153,7 +153,7 @@ function stanza_mt:maptags(callback) local n_children, n_tags = #self, #tags; local i = 1; - while curr_tag <= n_tags do + while curr_tag <= n_tags and n_tags > 0 do if self[i] == tags[curr_tag] then local ret = callback(self[i]); if ret == nil then @@ -161,13 +161,15 @@ function stanza_mt:maptags(callback) t_remove(tags, curr_tag); n_children = n_children - 1; n_tags = n_tags - 1; + i = i - 1; + curr_tag = curr_tag - 1; else self[i] = ret; tags[i] = ret; end - i = i + 1; curr_tag = curr_tag + 1; end + i = i + 1; end return self; end -- cgit v1.2.3 From 7dd69c06bbc6afef880fdc26b64d806d88fce0ee Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 3 Apr 2013 13:39:00 +0100 Subject: util.helpers: Helper helpers to log host events --- util/helpers.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/util/helpers.lua b/util/helpers.lua index 6103a319..08b86a7c 100644 --- a/util/helpers.lua +++ b/util/helpers.lua @@ -14,6 +14,14 @@ module("helpers", package.seeall); local log = require "util.logger".init("util.debug"); +function log_host_events(host) + return log_events(prosody.hosts[host].events, host); +end + +function revert_log_host_events(host) + return revert_log_events(prosody.hosts[host].events); +end + function log_events(events, name, logger) local f = events.fire_event; if not f then -- cgit v1.2.3 From a9744cfc9999f5459021d741932018f20f53ffc9 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 3 Apr 2013 13:39:41 +0100 Subject: mod_presence: Remove some unused variables --- plugins/mod_presence.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua index b6e3fc18..8dac2d35 100644 --- a/plugins/mod_presence.lua +++ b/plugins/mod_presence.lua @@ -9,7 +9,7 @@ local log = module._log; local require = require; -local pairs, ipairs = pairs, ipairs; +local pairs = pairs; local t_concat, t_insert = table.concat, table.insert; local s_find = string.find; local tonumber = tonumber; @@ -346,7 +346,7 @@ module:hook("presence/full", function(data) end); module:hook("presence/host", function(data) -- inbound presence to the host - local origin, stanza = data.origin, data.stanza; + local stanza = data.stanza; local from_bare = jid_bare(stanza.attr.from); local t = stanza.attr.type; -- cgit v1.2.3 From 505b635f61d0d71d30d1e05ed67d5292e2cc57ce Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 3 Apr 2013 13:40:29 +0100 Subject: mod_groups: Add a public function other modules can use to determine if a JID belongs to a given group --- plugins/mod_groups.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/mod_groups.lua b/plugins/mod_groups.lua index 199925f9..9b39b16b 100644 --- a/plugins/mod_groups.lua +++ b/plugins/mod_groups.lua @@ -121,3 +121,8 @@ end function module.unload() datamanager.remove_callback(remove_virtual_contacts); end + +-- Public for other modules to access +function group_contains(group_name, jid) + return groups[group_name][jid]; +end -- cgit v1.2.3 From a84fbd90b35ec282a0864a16e20887bff32af8ce Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 3 Apr 2013 13:40:40 +0100 Subject: mod_groups: Remove unused import --- plugins/mod_groups.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_groups.lua b/plugins/mod_groups.lua index 9b39b16b..f7f632c2 100644 --- a/plugins/mod_groups.lua +++ b/plugins/mod_groups.lua @@ -13,7 +13,7 @@ local members; local groups_file; local jid, datamanager = require "util.jid", require "util.datamanager"; -local jid_bare, jid_prep = jid.bare, jid.prep; +local jid_prep = jid.prep; local module_host = module:get_host(); -- cgit v1.2.3 From 1728207c6bb7f3955535ba4a2c1c6fde8e624ed8 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 3 Apr 2013 13:51:59 +0100 Subject: mod_pubsub: Don't send current items to new subscribers (I don't know why we did) --- plugins/mod_pubsub.lua | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index fe6c0b0a..5ff3a029 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -164,16 +164,6 @@ function handlers.set_subscribe(origin, stanza, subscribe) reply = pubsub_error_reply(stanza, ret); end origin.send(reply); - if ok then - -- Send all current items - local ok, items = service:get_items(node, stanza.attr.from); - if items then - local jids = { [jid] = options or true }; - for id, item in pairs(items) do - service.config.broadcaster("items", node, jids, item); - end - end - end end function handlers.set_unsubscribe(origin, stanza, unsubscribe) -- cgit v1.2.3