diff options
author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-09-28 17:50:52 +0000 |
---|---|---|
committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-09-28 17:50:52 +0000 |
commit | b2cf59aa1cbfb8109f0f2579427159c47f93e6eb (patch) | |
tree | b519f7d96b9110d8606ce90c2d8e451a4967c1ea /lib/webrick | |
parent | eb8ee5e401cf49a31d4dc5ba2c8e74f379bb2408 (diff) |
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@4616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick')
-rw-r--r-- | lib/webrick/utils.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/webrick/utils.rb b/lib/webrick/utils.rb index d371f4989f..41b54271c7 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 |