From 5a9556bbf63d83d5e69aac0041b3f4f46b8473ab Mon Sep 17 00:00:00 2001 From: gotoyuzo Date: Sun, 28 Sep 2003 17:50:52 +0000 Subject: * lib/webrick/utils.rb (Utils::su): use setgid and setuid to set real and effective IDs. and setup group access list by initgroups. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/webrick/utils.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/webrick/utils.rb b/lib/webrick/utils.rb index d371f4989..41b54271c 100644 --- a/lib/webrick/utils.rb +++ b/lib/webrick/utils.rb @@ -26,16 +26,16 @@ module WEBrick end module_function :set_close_on_exec - def su(user, group=nil) + def su(user) if defined?(Etc) pw = Etc.getpwnam(user) - gr = group ? Etc.getgrnam(group) : pw - Process::gid = gr.gid - Process::egid = gr.gid - Process::uid = pw.uid - Process::euid = pw.uid - end - end + Process::initgroups(user, pw.gid) + Process::Sys::setgid(pw.gid) + Process::Sys::setuid(pw.uid) + else + warn("WEBrick::Utils::su doesn't work on this platform") + end + end module_function :su def getservername -- cgit