plugins/mod_posix.lua

changeset 1682
883cf1f516a0
parent 1681
e76e2fb26fca
child 1712
45a81d6d8777
equal deleted inserted replaced
1681:e76e2fb26fca 1682:883cf1f516a0
27 -- Allow switching away from root, some people like strange ports. 27 -- Allow switching away from root, some people like strange ports.
28 module:add_event_hook("server-started", function () 28 module:add_event_hook("server-started", function ()
29 local uid = config_get("*", "core", "setuid"); 29 local uid = config_get("*", "core", "setuid");
30 local gid = config_get("*", "core", "setgid"); 30 local gid = config_get("*", "core", "setgid");
31 if gid then 31 if gid then
32 pposix.setgid(gid); 32 local success, msg = pposix.setgid(gid);
33 module:log("debug", "Change group to "..gid.."."); 33 if success then
34 module:log("debug", "Changed group to "..gid.." successfully.");
35 else
36 module:log("error", "Failed to change group to "..gid..". Error: "..msg);
37 prosody.shutdown("Failed to change group to "..gid);
38 end
34 end 39 end
35 if uid then 40 if uid then
36 pposix.setuid(uid); 41 local success, msg = pposix.setuid(uid);
37 module:log("debug", "Change user to "..uid.."."); 42 if success then
43 module:log("debug", "Changed user to "..uid.." successfully.");
44 else
45 module:log("error", "Failed to change user to "..uid..". Error: "..msg);
46 prosody.shutdown("Failed to change user to "..uid);
47 end
38 end 48 end
39 end); 49 end);
40 50
41 -- Don't even think about it! 51 -- Don't even think about it!
42 module:add_event_hook("server-starting", function () 52 module:add_event_hook("server-starting", function ()

mercurial