Comparison

plugins/mod_posix.lua @ 6874:e011f289ec77

mod_posix: Normalize indentation
author Kim Alvefur <zash@zash.se>
date Sat, 26 Sep 2015 21:39:26 +0200
parent 6367:769a3577dd85
child 6875:12d68f7b1be0
comparison
equal deleted inserted replaced
6870:d5b416070f70 6874:e011f289ec77
29 local umask = module:get_option("umask") or "027"; 29 local umask = module:get_option("umask") or "027";
30 pposix.umask(umask); 30 pposix.umask(umask);
31 31
32 -- Allow switching away from root, some people like strange ports. 32 -- Allow switching away from root, some people like strange ports.
33 module:hook("server-started", function () 33 module:hook("server-started", function ()
34 local uid = module:get_option("setuid"); 34 local uid = module:get_option("setuid");
35 local gid = module:get_option("setgid"); 35 local gid = module:get_option("setgid");
36 if gid then 36 if gid then
37 local success, msg = pposix.setgid(gid); 37 local success, msg = pposix.setgid(gid);
38 if success then 38 if success then
39 module:log("debug", "Changed group to %s successfully.", gid); 39 module:log("debug", "Changed group to %s successfully.", gid);
40 else 40 else
41 module:log("error", "Failed to change group to %s. Error: %s", gid, msg); 41 module:log("error", "Failed to change group to %s. Error: %s", gid, msg);
42 prosody.shutdown("Failed to change group to %s", gid); 42 prosody.shutdown("Failed to change group to %s", gid);
43 end
44 end 43 end
45 if uid then 44 end
46 local success, msg = pposix.setuid(uid); 45 if uid then
47 if success then 46 local success, msg = pposix.setuid(uid);
48 module:log("debug", "Changed user to %s successfully.", uid); 47 if success then
49 else 48 module:log("debug", "Changed user to %s successfully.", uid);
50 module:log("error", "Failed to change user to %s. Error: %s", uid, msg); 49 else
51 prosody.shutdown("Failed to change user to %s", uid); 50 module:log("error", "Failed to change user to %s. Error: %s", uid, msg);
52 end 51 prosody.shutdown("Failed to change user to %s", uid);
53 end 52 end
54 end); 53 end
54 end);
55 55
56 -- Don't even think about it! 56 -- Don't even think about it!
57 if not prosody.start_time then -- server-starting 57 if not prosody.start_time then -- server-starting
58 local suid = module:get_option("setuid"); 58 local suid = module:get_option("setuid");
59 if not suid or suid == 0 or suid == "root" then 59 if not suid or suid == 0 or suid == "root" then