changeset 14058:f20b3f0d892b

Merge 13.0->trunk
author Kim Alvefur <zash@zash.se>
date Sat, 07 Feb 2026 19:12:27 +0100
parents 797f4c7e5f3e (current diff) 312542dd184d (diff)
children 6bf989c6fa3a
files prosodyctl
diffstat 3 files changed, 44 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/prosody	Tue Feb 03 11:01:03 2026 +0000
+++ b/prosody	Sat Feb 07 19:12:27 2026 +0100
@@ -18,14 +18,21 @@
 
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 
-local function is_relative(path)
-	local path_sep = package.config:sub(1,1);
-	return ((path_sep == "/" and path:sub(1,1) ~= "/")
-		or (path_sep == "\\" and (path:sub(1,1) ~= "/" and path:sub(2,3) ~= ":\\")))
+-- Check before first require, to preempt the probable failure
+if _VERSION < "Lua 5.2" then
+	io.stderr:write("Prosody is no longer compatible with Lua 5.1\n")
+	io.stderr:write("See https://prosody.im/doc/depends#lua for more information\n")
+	return os.exit(1);
 end
 
 -- Tell Lua where to find our libraries
 if CFG_SOURCEDIR then
+	-- Installed instance
+	local function is_relative(path)
+		local path_sep = package.config:sub(1,1);
+		return ((path_sep == "/" and path:sub(1,1) ~= "/")
+			or (path_sep == "\\" and (path:sub(1,1) ~= "/" and path:sub(2,3) ~= ":\\")))
+	end
 	local function filter_relative_paths(path)
 		if is_relative(path) then return ""; end
 	end
@@ -34,6 +41,11 @@
 	end
 	package.path = sanitise_paths(CFG_SOURCEDIR.."/?.lua;"..package.path);
 	package.cpath = sanitise_paths(CFG_SOURCEDIR.."/?.so;"..package.cpath);
+
+	require "prosody.loader";
+else
+	-- Not installed, e.g. running from a source checkout
+	require "loader";
 end
 
 -- Substitute ~ with path to home directory in data path
@@ -44,17 +56,6 @@
 end
 
 
--- Check before first require, to preempt the probable failure
-if _VERSION < "Lua 5.2" then
-	io.stderr:write("Prosody is no longer compatible with Lua 5.1\n")
-	io.stderr:write("See https://prosody.im/doc/depends#lua for more information\n")
-	return os.exit(1);
-end
-
-if not pcall(require, "prosody.loader") then
-	pcall(require, "loader");
-end
-
 local startup = require "prosody.util.startup";
 local async = require "prosody.util.async";
 
--- a/prosodyctl	Tue Feb 03 11:01:03 2026 +0000
+++ b/prosodyctl	Sat Feb 07 19:12:27 2026 +0100
@@ -17,14 +17,22 @@
 
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 
-local function is_relative(path)
-	local path_sep = package.config:sub(1,1);
-	return ((path_sep == "/" and path:sub(1,1) ~= "/")
-		or (path_sep == "\\" and (path:sub(1,1) ~= "/" and path:sub(2,3) ~= ":\\")))
+-- Check before first require, to preempt the probable failure
+if _VERSION < "Lua 5.2" then
+	io.stderr:write("Prosody is no longer compatible with Lua 5.1\n")
+	io.stderr:write("See https://prosody.im/doc/depends#lua for more information\n")
+	return os.exit(1);
 end
 
+
 -- Tell Lua where to find our libraries
 if CFG_SOURCEDIR then
+	-- Installed instance
+	local function is_relative(path)
+		local path_sep = package.config:sub(1,1);
+		return ((path_sep == "/" and path:sub(1,1) ~= "/")
+			or (path_sep == "\\" and (path:sub(1,1) ~= "/" and path:sub(2,3) ~= ":\\")))
+	end
 	local function filter_relative_paths(path)
 		if is_relative(path) then return ""; end
 	end
@@ -33,6 +41,11 @@
 	end
 	package.path = sanitise_paths(CFG_SOURCEDIR.."/?.lua;"..package.path);
 	package.cpath = sanitise_paths(CFG_SOURCEDIR.."/?.so;"..package.cpath);
+
+	require "prosody.loader";
+else
+	-- Not installed, e.g. running from a source checkout
+	require "loader";
 end
 
 -- Substitute ~ with path to home directory in data path
@@ -42,18 +55,6 @@
 	end
 end
 
------------
-
--- Check before first require, to preempt the probable failure
-if _VERSION < "Lua 5.2" then
-	io.stderr:write("Prosody is no longer compatible with Lua 5.1\n")
-	io.stderr:write("See https://prosody.im/doc/depends#lua for more information\n")
-	return os.exit(1);
-end
-
-if not pcall(require, "prosody.loader") then
-	pcall(require, "loader");
-end
 
 local startup = require "prosody.util.startup";
 startup.prosodyctl();
--- a/util-src/pposix.c	Tue Feb 03 11:01:03 2026 +0000
+++ b/util-src/pposix.c	Sat Feb 07 19:12:27 2026 +0100
@@ -123,9 +123,17 @@
 	}
 
 	/* Make sure accidental use of FDs 0, 1, 2 don't cause weirdness */
-	freopen("/dev/null", "r", stdin);
-	freopen("/dev/null", "w", stdout);
-	freopen("/dev/null", "w", stderr);
+	if(!freopen("/dev/null", "r", stdin)) {
+		fprintf(stderr, "Failed to redirect stdin to /dev/null");
+	}
+
+	if(!freopen("/dev/null", "w", stdout)) {
+		fprintf(stderr, "Failed to redirect stdout to /dev/null");
+	}
+
+	if(!freopen("/dev/null", "w", stderr)) {
+		fprintf(stderr, "Failed to redirect stderr to /dev/null");
+	}
 
 	/* Final fork, use it wisely */
 	if(fork()) {