summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--lib/webrick/utils.rb16
2 files changed, 14 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index a6f6fec91f..6dd6c77138 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Sep 29 02:31:44 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/utils.rb (Utils::su): use setgid and setuid to
+ set real and effective IDs. and setup group access list by
+ initgroups.
+
Mon Sep 27 18:25:13 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/xsd/charset.rb: XSD::Charset.is_ces did return always true under
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