Changeset

1680:f3d241915429

Add setuid and setgid support.
author Tobias Markmann <tm@ayena.de>
date Sat, 15 Aug 2009 12:17:27 +0200
parents 1679:e2eb0eaf2544
children 1681:e76e2fb26fca
files plugins/mod_posix.lua
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_posix.lua	Thu Aug 13 13:58:49 2009 +0200
+++ b/plugins/mod_posix.lua	Sat Aug 15 12:17:27 2009 +0200
@@ -24,6 +24,20 @@
 
 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