From cb9c562f0bd2fa155d9e0155248675d3d6874593 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 7 Mar 2018 16:01:58 +0100 Subject: MUC: Abort module loading if unable to get list of persistent rooms from storage (fixes #1091) --- plugins/muc/mod_muc.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua index 8c223cb2..bccd8915 100644 --- a/plugins/muc/mod_muc.lua +++ b/plugins/muc/mod_muc.lua @@ -37,7 +37,11 @@ local hosts = prosody.hosts; rooms = {}; local rooms = rooms; local persistent_rooms_storage = module:open_store("persistent"); -local persistent_rooms = persistent_rooms_storage:get() or {}; +local persistent_rooms, err = persistent_rooms_storage:get(); +if not persistent_rooms then + assert(not err, err); + persistent_rooms = {}; +end local room_configs = module:open_store("config"); -- Configurable options -- cgit v1.2.3 From fdfa7a51fa63176198c5edd355ab8de75cf375a6 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 9 Mar 2018 02:10:44 +0100 Subject: MUC: Prevent creation of room that could not be loaded from storage (see #1091) --- plugins/muc/mod_muc.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua index bccd8915..b32515e8 100644 --- a/plugins/muc/mod_muc.lua +++ b/plugins/muc/mod_muc.lua @@ -112,15 +112,21 @@ end local persistent_errors = false; for jid in pairs(persistent_rooms) do local node = jid_split(jid); - local data = room_configs:get(node); + local data, err = room_configs:get(node); if data then local room = create_room(jid); room._data = data._data; room._affiliations = data._affiliations; - else -- missing room data + elseif not err then -- missing room data persistent_rooms[jid] = nil; module:log("error", "Missing data for room '%s', removing from persistent room list", jid); persistent_errors = true; + else -- error + module:log("error", "Error loading data for room '%s', locking it until service restart. Error was: %s", jid, err); + local room = muc_new_room(jid); + room.locked = true; + room._affiliations = { [muc_host] = "owner" }; -- To prevent unlocking + rooms[jid] = room; end end if persistent_errors then persistent_rooms_storage:set(nil, persistent_rooms); end -- cgit v1.2.3 From 4dbe36a6a0a07bba210e80326a6a87229f5767bf Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 12 Mar 2018 16:05:08 +0100 Subject: MUC: Say something about storage failure before aborting (see #1091) --- plugins/muc/mod_muc.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua index b32515e8..0aa7fcee 100644 --- a/plugins/muc/mod_muc.lua +++ b/plugins/muc/mod_muc.lua @@ -39,6 +39,7 @@ local rooms = rooms; local persistent_rooms_storage = module:open_store("persistent"); local persistent_rooms, err = persistent_rooms_storage:get(); if not persistent_rooms then + module:log("error", "Error loading list of persistent rooms from storage. Reload mod_muc or restart to recover."); assert(not err, err); persistent_rooms = {}; end -- cgit v1.2.3 From ae1e3a1930fc2953e81868ee6ae3e88de0a511b1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 28 Mar 2018 18:11:09 +0200 Subject: MUC: Don't reply to errors with more errors (fixes #1122) --- plugins/muc/mod_muc.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua index 0aa7fcee..7304b5b1 100644 --- a/plugins/muc/mod_muc.lua +++ b/plugins/muc/mod_muc.lua @@ -171,7 +171,9 @@ function stanza_handler(event) local room = rooms[bare]; if not room then if stanza.name ~= "presence" or stanza.attr.type ~= nil then - origin.send(st.error_reply(stanza, "cancel", "item-not-found")); + if stanza.attr.type ~= "error" then + origin.send(st.error_reply(stanza, "cancel", "item-not-found")); + end return true; end if not(restrict_room_creation) or -- cgit v1.2.3 From 0e4c35dd868723eb1bf99dc72484fd076fffb9f6 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 4 Apr 2018 18:27:44 +0100 Subject: net.http: Fix parameter order to http request callbacks Commit e3b9dc9dd940 changed the parameter order in 2013, but did not update the names of the parameters in the callback function. Due to this inconsistency, 12df41a5a4b1 accidentally reversed the order when fixing the variable names without fixing where they are used. Additionally the documentation was incorrect (since 2013), and this has also now been fixed. --- net/http.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/http.lua b/net/http.lua index 8364a104..cc67a45c 100644 --- a/net/http.lua +++ b/net/http.lua @@ -238,7 +238,7 @@ local function request(self, u, ex, callback) end log("debug", "Request '%s': Calling callback, status %s", req.id, code or "---"); - return log_if_failed(req.id, xpcall(function () return callback(content, code, request, response) end, handleerr)); + return log_if_failed(req.id, xpcall(function () return callback(content, code, response, request) end, handleerr)); end req.reader = request_reader; req.state = "status"; -- cgit v1.2.3