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:
parent
a87c3b4869
commit
3c00fe9f41
3 changed files with 10 additions and 4 deletions
|
@ -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>
|
Thu Apr 24 22:55:22 2014 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* bootstraptest/test_io.rb: Add etc.so to $" before require 'tmpdir'.
|
* bootstraptest/test_io.rb: Add etc.so to $" before require 'tmpdir'.
|
||||||
|
|
|
@ -1106,7 +1106,7 @@ module FileUtils
|
||||||
when /\A\d+\z/
|
when /\A\d+\z/
|
||||||
user.to_i
|
user.to_i
|
||||||
else
|
else
|
||||||
Etc.getpwnam(user).uid
|
Etc.getpwnam(user) ? Etc.getpwnam(user).uid : nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private_module_function :fu_get_uid
|
private_module_function :fu_get_uid
|
||||||
|
@ -1119,7 +1119,7 @@ module FileUtils
|
||||||
when /\A\d+\z/
|
when /\A\d+\z/
|
||||||
group.to_i
|
group.to_i
|
||||||
else
|
else
|
||||||
Etc.getgrnam(group).gid
|
Etc.getgrnam(group) ? Etc.getgrnam(group).gid : nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private_module_function :fu_get_gid
|
private_module_function :fu_get_gid
|
||||||
|
|
|
@ -41,8 +41,7 @@ module WEBrick
|
||||||
##
|
##
|
||||||
# Changes the process's uid and gid to the ones of +user+
|
# Changes the process's uid and gid to the ones of +user+
|
||||||
def su(user)
|
def su(user)
|
||||||
if defined?(Etc)
|
if defined?(Etc) && (pw = Etc.getpwnam(user))
|
||||||
pw = Etc.getpwnam(user)
|
|
||||||
Process::initgroups(user, pw.gid)
|
Process::initgroups(user, pw.gid)
|
||||||
Process::Sys::setgid(pw.gid)
|
Process::Sys::setgid(pw.gid)
|
||||||
Process::Sys::setuid(pw.uid)
|
Process::Sys::setuid(pw.uid)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue