--- a/plugins/mod_c2s.lua Mon May 13 12:00:28 2019 +0200
+++ b/plugins/mod_c2s.lua Sun May 26 19:41:58 2019 +0200
@@ -245,7 +245,6 @@
--- Port listener
function listener.onconnect(conn)
local session = sm_new_session(conn);
- sessions[conn] = session;
session.log("info", "Client connected");
@@ -306,6 +305,8 @@
end
session.dispatch_stanza = stream_callbacks.handlestanza;
+
+ sessions[conn] = session;
end
function listener.onincoming(conn, data)
--- a/plugins/mod_storage_sql.lua Mon May 13 12:00:28 2019 +0200
+++ b/plugins/mod_storage_sql.lua Sun May 26 19:41:58 2019 +0200
@@ -472,13 +472,23 @@
else
args[#args+1] = query.truncate;
local unlimited = "ALL";
- if engine.params.driver == "SQLite3" then
- sql_query = [[
- DELETE FROM "prosodyarchive"
+ sql_query = [[
+ DELETE FROM "prosodyarchive"
+ WHERE "sort_id" IN (
+ SELECT "sort_id" FROM "prosodyarchive"
WHERE %s
ORDER BY "sort_id" %s
- LIMIT %s OFFSET ?;
- ]];
+ LIMIT %s OFFSET ?
+ );]];
+ if engine.params.driver == "SQLite3" then
+ if engine._have_delete_limit then
+ sql_query = [[
+ DELETE FROM "prosodyarchive"
+ WHERE %s
+ ORDER BY "sort_id" %s
+ LIMIT %s OFFSET ?;
+ ]];
+ end
unlimited = "-1";
elseif engine.params.driver == "MySQL" then
sql_query = [[
@@ -489,15 +499,6 @@
LIMIT %s OFFSET ?
) AS limiter on result.sort_id = limiter.sort_id;]];
unlimited = "18446744073709551615";
- else
- sql_query = [[
- DELETE FROM "prosodyarchive"
- WHERE "sort_id" IN (
- SELECT "sort_id" FROM "prosodyarchive"
- WHERE %s
- ORDER BY "sort_id" %s
- LIMIT %s OFFSET ?
- );]];
end
sql_query = string.format(sql_query, t_concat(where, " AND "),
query.reverse and "ASC" or "DESC", unlimited);
@@ -718,6 +719,13 @@
module:log("error", "Old database format detected. Please run: prosodyctl mod_%s upgrade", module.name);
return false, "database upgrade needed";
end
+ if engine.params.driver == "SQLite3" then
+ for row in engine:select("PRAGMA compile_options") do
+ if row[1] == "ENABLE_UPDATE_DELETE_LIMIT" then
+ engine._have_delete_limit = true;
+ end
+ end
+ end
end
end);
engines[sql.db2uri(params)] = engine;
--- a/util/random.lua Mon May 13 12:00:28 2019 +0200
+++ b/util/random.lua Sun May 26 19:41:58 2019 +0200
@@ -12,7 +12,15 @@
local urandom, urandom_err = io.open("/dev/urandom", "r");
local function bytes(n)
- return urandom:read(n);
+ local data, err = urandom:read(n);
+ if not data then
+ if err then
+ error("Unable to retrieve data from secure random number generator (/dev/urandom): "..tostring(err));
+ else
+ error("Secure random number generator (/dev/urandom) returned an end-of-file condition");
+ end
+ end
+ return data;
end
if not urandom then