diff options
author | Matthew Wild <mwild1@gmail.com> | 2011-04-05 13:26:43 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2011-04-05 13:26:43 +0100 |
commit | 1cfb734e0ecde10fcd5f457c1394ecb3b7a28e2a (patch) | |
tree | 35cdd4996c2ba4c67a4805bd01e3830d1dc171f5 | |
parent | 272ca5fce11d42d9cd3b50c0f3baa03729583443 (diff) | |
parent | ca74173a8221e9cd93db30c7bb89c8b181f8b60b (diff) | |
download | prosody-1cfb734e0ecde10fcd5f457c1394ecb3b7a28e2a.tar.gz prosody-1cfb734e0ecde10fcd5f457c1394ecb3b7a28e2a.zip |
Merge 0.8->trunk
-rw-r--r-- | core/sessionmanager.lua | 15 | ||||
-rw-r--r-- | core/usermanager.lua | 2 | ||||
-rw-r--r-- | net/httpserver.lua | 1 | ||||
-rw-r--r-- | plugins/mod_dialback.lua | 3 | ||||
-rw-r--r-- | plugins/mod_privacy.lua | 26 | ||||
-rw-r--r-- | prosody.cfg.lua.dist | 9 | ||||
-rw-r--r-- | tools/migration/Makefile | 6 | ||||
-rw-r--r-- | tools/migration/migrator/prosody_sql.lua | 6 | ||||
-rw-r--r-- | tools/migration/prosody-migrator.lua (renamed from tools/migration/main.lua) | 35 | ||||
-rw-r--r-- | util/dependencies.lua | 13 |
10 files changed, 67 insertions, 49 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index d36591bf..426763f5 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -108,16 +108,23 @@ function destroy_session(session, err) -- Remove session/resource from user's session list if session.full_jid then - hosts[session.host].sessions[session.username].sessions[session.resource] = nil; + local host_session = hosts[session.host]; + + -- Allow plugins to prevent session destruction + if host_session.events.fire_event("pre-resource-unbind", {session=session, error=err}) then + return; + end + + host_session.sessions[session.username].sessions[session.resource] = nil; full_sessions[session.full_jid] = nil; - if not next(hosts[session.host].sessions[session.username].sessions) then + if not next(host_session.sessions[session.username].sessions) then log("debug", "All resources of %s are now offline", session.username); - hosts[session.host].sessions[session.username] = nil; + host_session.sessions[session.username] = nil; bare_sessions[session.username..'@'..session.host] = nil; end - hosts[session.host].events.fire_event("resource-unbind", {session=session, error=err}); + host_session.events.fire_event("resource-unbind", {session=session, error=err}); end retire_session(session); diff --git a/core/usermanager.lua b/core/usermanager.lua index 5e2e41fc..0152afd7 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -96,6 +96,8 @@ function get_provider(host) end function is_admin(jid, host) + if host and not hosts[host] then return false; end + local is_admin; jid = jid_bare(jid); host = host or "*"; diff --git a/net/httpserver.lua b/net/httpserver.lua index e0fd3f86..74f61c56 100644 --- a/net/httpserver.lua +++ b/net/httpserver.lua @@ -136,7 +136,6 @@ local function request_reader(request, data, startpos) call_callback(request); end local function error_cb(r) - log("error", "Error in HTTP server handler: %s", r or "connection-closed"); call_callback(request, r or "connection-closed"); destroy_request(request); end diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index a8923e27..c1c5d920 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -12,7 +12,6 @@ local send_s2s = require "core.s2smanager".send_to_host; local s2s_make_authenticated = require "core.s2smanager".make_authenticated; local s2s_initiate_dialback = require "core.s2smanager".initiate_dialback; local s2s_verify_dialback = require "core.s2smanager".verify_dialback; -local s2s_destroy_session = require "core.s2smanager".destroy_session; local log = module._log; @@ -126,7 +125,7 @@ module:hook("stanza/jabber:server:dialback:result", function(event) if stanza.attr.type == "valid" then s2s_make_authenticated(origin, attr.from); else - s2s_destroy_session(origin) + origin:close("not-authorized", "dialback authentication failed"); end return true; end diff --git a/plugins/mod_privacy.lua b/plugins/mod_privacy.lua index d5842e26..2d696154 100644 --- a/plugins/mod_privacy.lua +++ b/plugins/mod_privacy.lua @@ -45,28 +45,6 @@ function isAnotherSessionUsingDefaultList(origin) end end -function sendUnavailable(origin, to, from) ---[[ example unavailable presence stanza -<presence from="node@host/resource" type="unavailable" to="node@host" > - <status>Logged out</status> -</presence> -]]-- - local presence = st.presence({from=from, type="unavailable"}); - presence:tag("status"):text("Logged out"); - - local node, host = jid_bare(to); - local bare = node .. "@" .. host; - - local user = bare_sessions[bare]; - if user then - for resource, session in pairs(user.sessions) do - presence.attr.to = session.full_jid; - module:log("debug", "send unavailable to: %s; from: %s", tostring(presence.attr.to), tostring(presence.attr.from)); - origin.send(presence); - end - end -end - function declineList(privacy_lists, origin, stanza, which) if which == "default" then if isAnotherSessionUsingDefaultList(origin) then @@ -123,7 +101,7 @@ function deleteList(privacy_lists, origin, stanza, name) return {"modify", "bad-request", "Not existing list specifed to be deleted."}; end -function createOrReplaceList (privacy_lists, origin, stanza, name, entries, roster) +function createOrReplaceList (privacy_lists, origin, stanza, name, entries) local bare_jid = origin.username.."@"..origin.host; if privacy_lists.lists == nil then @@ -323,7 +301,6 @@ function checkIfNeedToBeBlocked(e, session) return; -- from one of a user's resource to another => HANDS OFF! end - local item; local listname = session.activePrivacyList; if listname == nil then listname = privacy_lists.default; -- no active list selected, use default list @@ -414,7 +391,6 @@ function preCheckIncoming(e) end if resource == nil then local prio = 0; - local session_; if bare_sessions[node.."@"..host] ~= nil then for resource, session_ in pairs(bare_sessions[node.."@"..host].sessions) do if session_.priority ~= nil and session_.priority > prio then diff --git a/prosody.cfg.lua.dist b/prosody.cfg.lua.dist index d1bd7d67..e513b116 100644 --- a/prosody.cfg.lua.dist +++ b/prosody.cfg.lua.dist @@ -99,6 +99,15 @@ ssl = { --c2s_require_encryption = false --s2s_require_encryption = false +-- Select the authentication backend to use. The 'internal' providers +-- use Prosody's configured data storage to store the authentication data. +-- To allow Prosody to offer secure authentication mechanisms to clients, the +-- default provider stores passwords in plaintext. If you do not trust your +-- server please see http://prosody.im/doc/modules/mod_auth_internal_hashed +-- for information about using the hashed backend. + +authentication = "internal_plain" + -- Select the storage backend to use. By default Prosody uses flat files -- in its configured data directory, but it also supports more backends -- through modules. An "sql" backend is included by default, but requires diff --git a/tools/migration/Makefile b/tools/migration/Makefile index adceafd4..5998a5f7 100644 --- a/tools/migration/Makefile +++ b/tools/migration/Makefile @@ -14,7 +14,7 @@ INSTALLEDDATA = $(DATADIR) SOURCE_FILES = migrator/*.lua -all: prosody-migrator.install migrator.cfg.lua.install main.lua $(SOURCE_FILES) +all: prosody-migrator.install migrator.cfg.lua.install prosody-migrator.lua $(SOURCE_FILES) install: prosody-migrator.install migrator.cfg.lua.install install -d $(BIN) $(CONFIG) $(SOURCE) $(SOURCE)/migrator @@ -28,10 +28,10 @@ clean: rm -f prosody-migrator.install rm -f migrator.cfg.lua.install -prosody-migrator.install: main.lua +prosody-migrator.install: prosody-migrator.lua sed "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|; \ s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(INSTALLEDCONFIG)';|;" \ - < main.lua > prosody-migrator.install + < prosody-migrator.lua > prosody-migrator.install migrator.cfg.lua.install: migrator.cfg.lua sed "s|^local data_path = .*;$$|local data_path = '$(INSTALLEDDATA)';|;" \ diff --git a/tools/migration/migrator/prosody_sql.lua b/tools/migration/migrator/prosody_sql.lua index 3a9172ff..b1f836be 100644 --- a/tools/migration/migrator/prosody_sql.lua +++ b/tools/migration/migrator/prosody_sql.lua @@ -1,6 +1,6 @@ local assert = assert; -local DBI = require "DBI"; +local have_DBI, DBI = pcall(require,"DBI"); local print = print; local type = type; local next = next; @@ -11,6 +11,10 @@ local mtools = require "migrator.mtools"; local tostring = tostring; local tonumber = tonumber; +if not have_DBI then + error("LuaDBI (required for SQL support) was not found, please see http://prosody.im/doc/depends#luadbi", 0); +end + module "prosody_sql" local function create_table(connection, params) diff --git a/tools/migration/main.lua b/tools/migration/prosody-migrator.lua index 82eeab9d..20631fb1 100644 --- a/tools/migration/main.lua +++ b/tools/migration/prosody-migrator.lua @@ -71,21 +71,30 @@ if not config[to_store] then have_err = true; print("Error: Output store '"..to_store.."' not found in the config file."); end -if not config[from_store].type then - have_err = true; - print("Error: Input store type not specified in the config file"); -elseif not pcall(require, "migrator."..config[from_store].type) then - have_err = true; - print("Error: Unrecognised store type for '"..from_store.."': "..config[from_store].type); -end -if not config[to_store].type then - have_err = true; - print("Error: Output store type not specified in the config file"); -elseif not pcall(require, "migrator."..config[to_store].type) then - have_err = true; - print("Error: Unrecognised store type for '"..to_store.."': "..config[to_store].type); + +function load_store_handler(name) + local store_type = config[name].type; + if not store_type then + print("Error: "..name.." store type not specified in the config file"); + return false; + else + local ok, err = pcall(require, "migrator."..store_type); + if not ok then + if package.loaded["migrator."..store_type] then + print(("Error: Failed to initialize '%s' store:\n\t%s") + :format(name, err)); + else + print(("Error: Unrecognised store type for '%s': %s") + :format(from_store, store_type)); + end + return false; + end + end + return true; end +have_err = have_err or not(load_store_handler(from_store, "input") and load_store_handler(to_store, "output")); + if have_err then print(""); print("Usage: "..arg[0].." FROM_STORE TO_STORE"); diff --git a/util/dependencies.lua b/util/dependencies.lua index 9371521c..5baea942 100644 --- a/util/dependencies.lua +++ b/util/dependencies.lua @@ -35,6 +35,19 @@ function missingdep(name, sources, msg) print(""); end +-- COMPAT w/pre-0.8 Debian: The Debian config file used to use +-- util.ztact, which has been removed from Prosody in 0.8. This +-- is to log an error for people who still use it, so they can +-- update their configs. +package.preload["util.ztact"] = function () + if not package.loaded["core.loggingmanager"] then + error("util.ztact has been removed from Prosody and you need to fix your config " + .."file. More information can be found at http://prosody.im/doc/packagers#ztact", 0); + else + error("module 'util.ztact' has been deprecated in Prosody 0.8."); + end +end; + function check_dependencies() local fatal; |