aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-05-03 01:11:21 +0100
committerMatthew Wild <mwild1@gmail.com>2009-05-03 01:11:21 +0100
commit67c94f50f4dfd8d3f3de0e84bafb56d37d5cdd83 (patch)
tree7aac7e2c38a5a98eb1c3d84103800a3a9e09e9d9
parent29b41d9efd7e4a84f043b38cfdb51893a4504616 (diff)
parent7be3d9f227ff8083e396497507dbdfe9a6049ca8 (diff)
downloadprosody-67c94f50f4dfd8d3f3de0e84bafb56d37d5cdd83.tar.gz
prosody-67c94f50f4dfd8d3f3de0e84bafb56d37d5cdd83.zip
Merge with 0.4
-rw-r--r--Makefile12
-rw-r--r--core/componentmanager.lua4
-rw-r--r--core/hostmanager.lua5
-rw-r--r--core/modulemanager.lua4
-rw-r--r--net/connlisteners.lua4
-rw-r--r--net/server.lua8
-rw-r--r--plugins/mod_posix.lua9
-rwxr-xr-xprosody21
-rwxr-xr-xprosodyctl25
-rw-r--r--util/datamanager.lua2
10 files changed, 72 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index 278d260b..f030821c 100644
--- a/Makefile
+++ b/Makefile
@@ -12,14 +12,15 @@ INSTALLEDCONFIG = $(SYSCONFDIR)
INSTALLEDMODULES = $(PREFIX)/lib/prosody/modules
INSTALLEDDATA = $(DATADIR)
-all: prosody.install prosody.cfg.lua.install
+all: prosody.install prosodyctl.install prosody.cfg.lua.install
$(MAKE) -C util-src install
-install: prosody.install prosody.cfg.lua.install util/encodings.so util/encodings.so util/pposix.so util/signal.so
+install: prosody.install prosodyctl.install prosody.cfg.lua.install util/encodings.so util/encodings.so util/pposix.so util/signal.so
install -d $(BIN) $(CONFIG) $(MODULES) $(SOURCE) $(DATA)
install -d $(CONFIG)/certs
install -d $(SOURCE)/core $(SOURCE)/net $(SOURCE)/util
install ./prosody.install $(BIN)/prosody
+ install ./prosodyctl.install $(BIN)/prosodyctl
install -m644 core/* $(SOURCE)/core
install -m644 net/* $(SOURCE)/net
install -m644 util/* $(SOURCE)/util
@@ -31,6 +32,7 @@ install: prosody.install prosody.cfg.lua.install util/encodings.so util/encoding
clean:
rm -f prosody.install
+ rm -f prosodyctl.install
rm -f prosody.cfg.lua.install
$(MAKE) clean -C util-src
@@ -52,6 +54,12 @@ prosody.install: prosody
s|^CFG_DATADIR=.*;$$|CFG_DATADIR='$(INSTALLEDDATA)';|; \
s|^CFG_PLUGINDIR=.*;$$|CFG_PLUGINDIR='$(INSTALLEDMODULES)/';|;" < prosody > prosody.install
+prosodyctl.install: prosodyctl
+ sed "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|; \
+ s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(INSTALLEDCONFIG)';|; \
+ s|^CFG_DATADIR=.*;$$|CFG_DATADIR='$(INSTALLEDDATA)';|; \
+ s|^CFG_PLUGINDIR=.*;$$|CFG_PLUGINDIR='$(INSTALLEDMODULES)/';|;" < prosodyctl > prosodyctl.install
+
prosody.cfg.lua.install:
sed 's|certs/|$(INSTALLEDCONFIG)/certs/|' prosody.cfg.lua.dist > prosody.cfg.lua.install
diff --git a/core/componentmanager.lua b/core/componentmanager.lua
index 8b1cce3a..d76b7849 100644
--- a/core/componentmanager.lua
+++ b/core/componentmanager.lua
@@ -44,7 +44,7 @@ local function default_component_handler(origin, stanza)
end
end
-
+local components_loaded_once;
function load_enabled_components(config)
local defined_hosts = config or configmanager.getconfig();
@@ -56,7 +56,7 @@ function load_enabled_components(config)
if not ok then
log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err));
else
- log("info", "Activated %s component: %s", host_config.core.component_module, host);
+ log("debug", "Activated %s component: %s", host_config.core.component_module, host);
end
end
end
diff --git a/core/hostmanager.lua b/core/hostmanager.lua
index 1fec9799..97c742da 100644
--- a/core/hostmanager.lua
+++ b/core/hostmanager.lua
@@ -9,6 +9,8 @@ local pairs = pairs;
module "hostmanager"
+local hosts_loaded_once;
+
local function load_enabled_hosts(config)
local defined_hosts = config or configmanager.getconfig();
@@ -18,13 +20,14 @@ local function load_enabled_hosts(config)
end
end
eventmanager.fire_event("hosts-activated", defined_hosts);
+ hosts_loaded_once = true;
end
eventmanager.add_event_hook("server-starting", load_enabled_hosts);
function activate(host, host_config)
hosts[host] = {type = "local", connected = true, sessions = {}, host = host, s2sout = {} };
- log("info", "Activated host: %s", host);
+ log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host);
eventmanager.fire_event("host-activated", host, host_config);
end
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index cc48c2f6..2cba50ac 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -53,6 +53,10 @@ local NULL = {};
-- Load modules when a host is activated
function load_modules_for_host(host)
+ if config.get(host, "core", "modules_enable") == false then
+ return; -- Only load for hosts, not components, etc.
+ end
+
-- Load modules from global section
local modules_enabled = config.get("*", "core", "modules_enabled");
local modules_disabled = config.get(host, "core", "modules_disabled");
diff --git a/net/connlisteners.lua b/net/connlisteners.lua
index 48101752..7aaee4c0 100644
--- a/net/connlisteners.lua
+++ b/net/connlisteners.lua
@@ -21,11 +21,11 @@ local listeners = {};
function register(name, listener)
if listeners[name] and listeners[name] ~= listener then
- log("warn", "Listener %s is already registered, not registering any more", name);
+ log("debug", "Listener %s is already registered, not registering any more", name);
return false;
end
listeners[name] = listener;
- log("info", "Registered connection listener %s", name);
+ log("debug", "Registered connection listener %s", name);
return true;
end
diff --git a/net/server.lua b/net/server.lua
index fd6459e8..9e42b8ff 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -77,6 +77,7 @@ local idfalse
local addtimer
local closeall
local addserver
+local getserver
local wrapserver
local getsettings
local closesocket
@@ -670,6 +671,10 @@ addserver = function( listeners, port, addr, pattern, sslctx, maxconnections, st
return handler
end
+getserver = function ( port )
+ return _server[ port ];
+end
+
removeserver = function( port )
local handler = _server[ port ]
if not handler then
@@ -728,7 +733,7 @@ stats = function( )
return _readtraffic, _sendtraffic, _readlistlen, _sendlistlen, _timerlistlen
end
-local dontstop = true;
+local dontstop = true; -- thinking about tomorrow, ...
setquitting = function (quit)
dontstop = not quit;
@@ -844,6 +849,7 @@ return {
closeall = closeall,
addtimer = addtimer,
addserver = addserver,
+ getserver = getserver,
getsettings = getsettings,
setquitting = setquitting,
removeserver = removeserver,
diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua
index b1c7e01b..e6f17cc1 100644
--- a/plugins/mod_posix.lua
+++ b/plugins/mod_posix.lua
@@ -14,6 +14,15 @@ local logger_set = require "util.logger".setwriter;
module.host = "*"; -- we're a global module
+-- Don't even think about it!
+module:add_event_hook("server-starting", function ()
+ if pposix.getuid() == 0 and not config_get("*", "core", "run_as_root") then
+ module:log("error", "Danger, Will Robinson! Prosody doesn't need to be run as root, so don't do it!");
+ module:log("error", "For more information on running Prosody as root, see http://prosody.im/doc/root");
+ _G.prosody_shutdown("Refusing to run as root");
+ end
+ end);
+
local pidfile_written;
local function remove_pidfile()
diff --git a/prosody b/prosody
index 9bff11cc..8e85847f 100755
--- a/prosody
+++ b/prosody
@@ -114,8 +114,17 @@ end);
----------- End of out-of-place code --------------
+-- Global function to initiate prosody shutdown
+function prosody_shutdown(reason)
+ log("info", "Shutting down: %s", reason or "unknown reason");
+ eventmanager.fire_event("server-stopping", { reason = reason });
+ server.setquitting(true);
+end
+
+-- Signal to modules that we are ready to start
eventmanager.fire_event("server-starting");
+-- Load SSL settings from config, and create a ctx table
local global_ssl_ctx = ssl and config.get("*", "core", "ssl");
if global_ssl_ctx then
local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none"; };
@@ -153,13 +162,6 @@ if cl.get("console") then
cl.start("console", { interface = config.get("*", "core", "console_interface") or "127.0.0.1" })
end
--- Global function to initiate prosody shutdown
-function prosody_shutdown(reason)
- log("info", "Shutting down: %s", reason or "unknown reason");
- eventmanager.fire_event("server-stopping", { reason = reason });
- server.setquitting(true);
-end
-
-- Catch global accesses --
local locked_globals_mt = { __index = function (t, k) error("Attempt to read a non-existent global '"..k.."'", 2); end, __newindex = function (t, k, v) error("Attempt to set a global: "..tostring(k).." = "..tostring(v), 2); end }
@@ -202,8 +204,9 @@ eventmanager.fire_event("server-cleanup");
-- need to do some tidying before we go :)
server.setquitting(false);
+log("info", "Shutdown status: Closing all active sessions");
for hostname, host in pairs(hosts) do
- log("info", "Shutdown status: Closing client connections for %s", hostname)
+ log("debug", "Shutdown status: Closing client connections for %s", hostname)
if host.sessions then
for username, user in pairs(host.sessions) do
for resource, session in pairs(user.sessions) do
@@ -213,7 +216,7 @@ for hostname, host in pairs(hosts) do
end
end
- log("info", "Shutdown status: Closing outgoing s2s connections from %s", hostname);
+ log("debug", "Shutdown status: Closing outgoing s2s connections from %s", hostname);
if host.s2sout then
for remotehost, session in pairs(host.s2sout) do
if session.close then
diff --git a/prosodyctl b/prosodyctl
index db607833..098f7475 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -238,7 +238,11 @@ function commands.deluser(arg)
return 1;
end
-function commands.start()
+function commands.start(arg)
+ if arg[1] == "--help" then
+ show_usage([[start]], [[Start Prosody]]);
+ return 1;
+ end
local ok, ret = prosodyctl.isrunning();
if not ok then
show_message(error_messages[ret]);
@@ -264,7 +268,12 @@ function commands.start()
return 1;
end
-function commands.status()
+function commands.status(arg)
+ if arg[1] == "--help" then
+ show_usage([[status]], [[Reports the running status of Prosody]]);
+ return 1;
+ end
+
local ok, ret = prosodyctl.isrunning();
if not ok then
show_message(error_messages[ret]);
@@ -280,11 +289,19 @@ function commands.status()
end
show_message("Prosody is running with PID %s", ret or "(unknown)");
return 0;
+ else
+ show_message("Prosody is not running");
+ return 2
end
return 1;
end
-function commands.stop()
+function commands.stop(arg)
+ if arg[1] == "--help" then
+ show_usage([[stop]], [[Stop a running Prosody server]]);
+ return 1;
+ end
+
if not prosodyctl.isrunning() then
show_message("Prosody is not running");
return 1;
@@ -293,7 +310,7 @@ function commands.stop()
local ok, ret = prosodyctl.stop();
if ok then return 0; end
- show_message(error_messages[ret])
+ show_message(error_messages[ret]);
return 1;
end
diff --git a/util/datamanager.lua b/util/datamanager.lua
index 614f0c80..41d09f06 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -55,7 +55,7 @@ local callback;
------- API -------------
function set_data_path(path)
- log("info", "Setting data path to: %s", path);
+ log("debug", "Setting data path to: %s", path);
data_path = path;
end
function set_callback(func)