diff options
author | Tobias Markmann <tm@ayena.de> | 2009-08-15 12:17:27 +0200 |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2009-08-15 12:17:27 +0200 |
commit | 6a260eaa2cdffb9105c31a6967dfae78d6738a26 (patch) | |
tree | 3e44c01614efab933c03f21402e3d21fc7fad4e4 | |
parent | 8162f0368b15af6fee854087b264ddac15a05ab5 (diff) | |
download | prosody-6a260eaa2cdffb9105c31a6967dfae78d6738a26.tar.gz prosody-6a260eaa2cdffb9105c31a6967dfae78d6738a26.zip |
Add setuid and setgid support.
-rw-r--r-- | plugins/mod_posix.lua | 14 |
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 |