1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/fileutils.rb (fu_get_uid, fu_get_gid): Etc.getpwnam/getgrnam may

returns nil.

* lib/webrick/utils.rb (su): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2014-04-24 14:19:21 +00:00
parent a87c3b4869
commit 3c00fe9f41
3 changed files with 10 additions and 4 deletions

View file

@ -41,8 +41,7 @@ module WEBrick
##
# Changes the process's uid and gid to the ones of +user+
def su(user)
if defined?(Etc)
pw = Etc.getpwnam(user)
if defined?(Etc) && (pw = Etc.getpwnam(user))
Process::initgroups(user, pw.gid)
Process::Sys::setgid(pw.gid)
Process::Sys::setuid(pw.uid)