aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--lib/fileutils.rb4
-rw-r--r--lib/webrick/utils.rb3
3 files changed, 10 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ac6a27621b..3f7ab2004f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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'.
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 1b7bb11b18..0dfbf41d6c 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -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
diff --git a/lib/webrick/utils.rb b/lib/webrick/utils.rb
index a6b5cc6a9c..185b1723f3 100644
--- a/lib/webrick/utils.rb
+++ b/lib/webrick/utils.rb
@@ -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)