Software /
code /
prosody
Comparison
plugins/mod_posix.lua @ 1680:f3d241915429
Add setuid and setgid support.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Sat, 15 Aug 2009 12:17:27 +0200 |
parent | 1579:95698f021c5d |
child | 1681:e76e2fb26fca |
comparison
equal
deleted
inserted
replaced
1679:e2eb0eaf2544 | 1680:f3d241915429 |
---|---|
21 local logger_set = require "util.logger".setwriter; | 21 local logger_set = require "util.logger".setwriter; |
22 | 22 |
23 local prosody = _G.prosody; | 23 local prosody = _G.prosody; |
24 | 24 |
25 module.host = "*"; -- we're a global module | 25 module.host = "*"; -- we're a global module |
26 | |
27 -- Allow switching away from root, some people like strange ports. | |
28 module:add_event_hook("server-started", function () | |
29 local uid = config_get("*", "core", "setuid"); | |
30 local gid = config_get("*", "core", "setgid"); | |
31 if gid then | |
32 pposix.setgid(gid); | |
33 module:log("debug", "Change group to "..gid.."."); | |
34 end | |
35 if uid then | |
36 pposix.setuid(uid); | |
37 module:log("debug", "Change user to "..uid.."."); | |
38 end | |
39 end); | |
26 | 40 |
27 -- Don't even think about it! | 41 -- Don't even think about it! |
28 module:add_event_hook("server-starting", function () | 42 module:add_event_hook("server-starting", function () |
29 if pposix.getuid() == 0 and not config_get("*", "core", "run_as_root") then | 43 if pposix.getuid() == 0 and not config_get("*", "core", "run_as_root") then |
30 module:log("error", "Danger, Will Robinson! Prosody doesn't need to be run as root, so don't do it!"); | 44 module:log("error", "Danger, Will Robinson! Prosody doesn't need to be run as root, so don't do it!"); |