[前][次][番号順一覧][スレッド一覧]

ruby-changes:33631

From: usa <ko1@a...>
Date: Thu, 24 Apr 2014 23:19:28 +0900 (JST)
Subject: [ruby-changes:33631] usa:r45712 (trunk): * lib/fileutils.rb (fu_get_uid, fu_get_gid): Etc.getpwnam/getgrnam may

usa	2014-04-24 23:19:21 +0900 (Thu, 24 Apr 2014)

  New Revision: 45712

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45712

  Log:
    * lib/fileutils.rb (fu_get_uid, fu_get_gid): Etc.getpwnam/getgrnam may
      returns nil.
    
    * lib/webrick/utils.rb (su): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/lib/fileutils.rb
    trunk/lib/webrick/utils.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45711)
+++ ChangeLog	(revision 45712)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Apr 24 23:17:25 2014  NAKAMURA Usaku  <usa@r...>
+
+	* 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@f...>
 
 	* bootstraptest/test_io.rb: Add etc.so to $" before require 'tmpdir'.
Index: lib/webrick/utils.rb
===================================================================
--- lib/webrick/utils.rb	(revision 45711)
+++ lib/webrick/utils.rb	(revision 45712)
@@ -41,8 +41,7 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/utils.rb#L41
     ##
     # 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)
Index: lib/fileutils.rb
===================================================================
--- lib/fileutils.rb	(revision 45711)
+++ lib/fileutils.rb	(revision 45712)
@@ -1106,7 +1106,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L1106
       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 https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L1119
       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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]