aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_posix.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mod_posix.lua')
-rw-r--r--plugins/mod_posix.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua
index 0f46888d..a0830d82 100644
--- a/plugins/mod_posix.lua
+++ b/plugins/mod_posix.lua
@@ -24,6 +24,20 @@ local prosody = _G.prosody;
module.host = "*"; -- we're a global module
+-- Allow switching away from root, some people like strange ports.
+module:add_event_hook("server-started", function ()
+ local uid = config_get("*", "core", "setuid");
+ local gid = config_get("*", "core", "setgid");
+ if gid then
+ pposix.setgid(gid);
+ module:log("debug", "Change group to "..gid..".");
+ end
+ if uid then
+ pposix.setuid(uid);
+ module:log("debug", "Change user to "..uid..".");
+ end
+ end);
+
-- 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