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

@ -1,3 +1,10 @@
Thu Apr 24 23:17:25 2014 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/fileutils.rb (fu_get_uid, fu_get_gid): Etc.getpwnam/getgrnam may
returns nil.
* lib/webrick/utils.rb (su): ditto.
Thu Apr 24 22:55:22 2014 Tanaka Akira <akr@fsij.org>
* bootstraptest/test_io.rb: Add etc.so to $" before require 'tmpdir'.

View file

@ -1106,7 +1106,7 @@ module FileUtils
when /\A\d+\z/
user.to_i
else
Etc.getpwnam(user).uid
Etc.getpwnam(user) ? Etc.getpwnam(user).uid : nil
end
end
private_module_function :fu_get_uid
@ -1119,7 +1119,7 @@ module FileUtils
when /\A\d+\z/
group.to_i
else
Etc.getgrnam(group).gid
Etc.getgrnam(group) ? Etc.getgrnam(group).gid : nil
end
end
private_module_function :fu_get_gid

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)