From fa211588ac214372fa127c6cdc62663c26752bc8 Mon Sep 17 00:00:00 2001
From: Kim Alvefur <zash@zash.se>
Date: Sun, 10 Jan 2016 23:21:34 +0100
Subject: util.uuid: Open /dev/urandom read-only, make seed() a noop

---
 util/uuid.lua | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/util/uuid.lua b/util/uuid.lua
index 58f792fd..3576be8f 100644
--- a/util/uuid.lua
+++ b/util/uuid.lua
@@ -8,7 +8,7 @@
 
 local error = error;
 local round_up = math.ceil;
-local urandom, urandom_err = io.open("/dev/urandom", "r+");
+local urandom, urandom_err = io.open("/dev/urandom", "r");
 
 module "uuid"
 
@@ -30,9 +30,7 @@ function generate()
 	return get_nibbles(8).."-"..get_nibbles(4).."-4"..get_nibbles(3).."-"..(get_twobits())..get_nibbles(3).."-"..get_nibbles(12);
 end
 
-function seed(x)
-	urandom:write(x);
-	urandom:flush();
+function seed()
 end
 
 return _M;
-- 
cgit v1.2.3


From 14d035cf4351540c4b8751fa47db1c1f421eb7ce Mon Sep 17 00:00:00 2001
From: Kim Alvefur <zash@zash.se>
Date: Sun, 10 Jan 2016 23:25:00 +0100
Subject: core: Increase default read size to "all of it", in practice 8K (size
 of LuaSockets buffer)

---
 core/portmanager.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/portmanager.lua b/core/portmanager.lua
index 421d7fc6..37442a31 100644
--- a/core/portmanager.lua
+++ b/core/portmanager.lua
@@ -29,7 +29,7 @@ if socket.tcp6 and config.get("*", "use_ipv6") ~= false then
 	table.insert(default_local_interfaces, "::1");
 end
 
-local default_mode = config.get("*", "network_default_read_size") or 4096;
+local default_mode = config.get("*", "network_default_read_size") or "*a";
 
 --- Private state
 
-- 
cgit v1.2.3


From 3c9b6a4a8d98570eafdfcf388fd1f51fe97a5425 Mon Sep 17 00:00:00 2001
From: Kim Alvefur <zash@zash.se>
Date: Mon, 11 Jan 2016 15:35:51 +0100
Subject: mod_blocklist: Clear second level cache correctly on user deletion

---
 plugins/mod_blocklist.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/mod_blocklist.lua b/plugins/mod_blocklist.lua
index e2ed626b..8efbfd96 100644
--- a/plugins/mod_blocklist.lua
+++ b/plugins/mod_blocklist.lua
@@ -221,7 +221,7 @@ module:hook("iq-set/self/urn:xmpp:blocking:unblock", edit_blocklist);
 -- Cache invalidation, solved!
 module:hook_global("user-deleted", function (event)
 	if event.host == module.host then
-		cache:set(event.username, nil);
+		cache2:set(event.username, nil);
 		cache[event.username] = nil;
 	end
 end);
-- 
cgit v1.2.3


From 5cf7f85a081fcf56c44bca7bc5738cf3af25d630 Mon Sep 17 00:00:00 2001
From: Kim Alvefur <zash@zash.se>
Date: Tue, 12 Jan 2016 01:13:57 +0100
Subject: prosodyctl check: Fix traceback if the global modules_enabled is
 unset

---
 prosodyctl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/prosodyctl b/prosodyctl
index 0c80aca7..e08c9dd2 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -1080,8 +1080,8 @@ function commands.check(arg)
 				target_hosts:remove("localhost");
 			end
 			
-			local modules = set.new(it.to_array(it.values(host_options.modules_enabled)))
-			                + set.new(it.to_array(it.values(config.get("*", "modules_enabled"))))
+			local modules = set.new(it.to_array(it.values(host_options.modules_enabled or {})))
+			                + set.new(it.to_array(it.values(config.get("*", "modules_enabled") or {})))
 			                + set.new({ config.get(host, "component_module") });
 
 			if modules:contains("proxy65") then
-- 
cgit v1.2.3


From ec70d377702ca8d0053fc652489d2dd43637e061 Mon Sep 17 00:00:00 2001
From: Matthew Wild <mwild1@gmail.com>
Date: Fri, 15 Jan 2016 00:51:01 +0000
Subject: prosody: Allow prosody.shutdown() to take an exit code for the
 process (thanks daurnimator)

---
 prosody | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/prosody b/prosody
index a2cb0e6c..6a3b50db 100755
--- a/prosody
+++ b/prosody
@@ -272,10 +272,14 @@ function init_global_state()
 	end
 
 	-- Function to initiate prosody shutdown
-	function prosody.shutdown(reason)
+	function prosody.shutdown(reason, code)
 		log("info", "Shutting down: %s", reason or "unknown reason");
 		prosody.shutdown_reason = reason;
-		prosody.events.fire_event("server-stopping", {reason = reason});
+		prosody.shutdown_code = code;
+		prosody.events.fire_event("server-stopping", {
+			reason = reason;
+			code = code;
+		});
 		server.setquitting(true);
 	end
 end
@@ -418,3 +422,4 @@ cleanup();
 prosody.events.fire_event("server-stopped");
 log("info", "Shutdown complete");
 
+os.exit(prosody.shutdown_code)
-- 
cgit v1.2.3


From 78ab7365489a289f91459839f635411afc65a94c Mon Sep 17 00:00:00 2001
From: Kim Alvefur <zash@zash.se>
Date: Tue, 12 Jan 2016 23:47:30 +0100
Subject: prosodyctl: check config: Suggest moving modules enabled on all hosts
 to a global_modules enabled if that is unset

---
 prosodyctl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/prosodyctl b/prosodyctl
index e08c9dd2..1a487fb5 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -877,6 +877,20 @@ function commands.check(arg)
 				print("    All hosts are disabled. Remove enabled = false from at least one VirtualHost section")
 			end
 		end
+		if not config["*"].modules_enabled then
+			print("    No global modules_enabled is set?");
+			local suggested_global_modules;
+			for host, options in enabled_hosts() do
+				if not options.component_module and options.modules_enabled then
+					suggested_global_modules = set.intersection(suggested_global_modules or set.new(options.modules_enabled), set.new(options.modules_enabled));
+				end
+			end
+			if not suggested_global_modules:empty() then
+				print("    Consider moving these modules into modules_enabled in the global section:")
+				print("    "..tostring(suggested_global_modules / function (x) return ("%q"):format(x) end));
+			end
+			print();
+		end
 		-- Check for global options under hosts
 		local global_options = set.new(it.to_array(it.keys(config["*"])));
 		local deprecated_global_options = set.intersection(global_options, deprecated);
-- 
cgit v1.2.3


From f1d3d688b0104093cbee37b089a193753275b40d Mon Sep 17 00:00:00 2001
From: Kim Alvefur <zash@zash.se>
Date: Tue, 12 Jan 2016 23:48:16 +0100
Subject: util.random: Open /dev/urandom read-only, make seed() a noop

---
 util/random.lua | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/util/random.lua b/util/random.lua
index 4963e98c..05f36aba 100644
--- a/util/random.lua
+++ b/util/random.lua
@@ -6,11 +6,9 @@
 -- COPYING file in the source package for more information.
 --
 
-local urandom = assert(io.open("/dev/urandom", "r+"));
+local urandom = assert(io.open("/dev/urandom", "r"));
 
-local function seed(x)
-	urandom:write(x);
-	urandom:flush();
+local function seed()
 end
 
 local function bytes(n)
-- 
cgit v1.2.3


From 83e7c91e0130f27720406b87996c4c74b7cc0afe Mon Sep 17 00:00:00 2001
From: Kim Alvefur <zash@zash.se>
Date: Sat, 16 Jan 2016 22:43:11 +0100
Subject: net.http.server: Return from listen_on() whatever
 net.server.addserver() returns

---
 net/http/server.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/http/server.lua b/net/http/server.lua
index 9649d0e8..aeaa7416 100644
--- a/net/http/server.lua
+++ b/net/http/server.lua
@@ -294,7 +294,7 @@ function _M.remove_handler(event, handler)
 end
 
 function _M.listen_on(port, interface, ssl)
-	addserver(interface or "*", port, listener, "*a", ssl);
+	return addserver(interface or "*", port, listener, "*a", ssl);
 end
 function _M.add_host(host)
 	hosts[host] = true;
-- 
cgit v1.2.3