Patches item #29269, was opened at 2011-06-11 01:33
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=577&aid=29269&group_id=126

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Jorge Jimenez (jjimenez)
Assigned to: Nobody (None)
Summary: Gem.set_paths fails on Etc.getpwuid.uid when running chrooted

Initial Comment:
In a chrooted environment with less privileges for /etc/passwd, method 
set_paths fails on Etc.getpwuid.uid call because current user is not allowed to 
read /etc/passwd file (for security matters). Changing Etc.getpwuid.uid by 
Process.uid solve this issue.
I know this is not a bug, because /etc/passwd file must be readable by all 
users, but Etc.getpwuid.uid must first call getuid() function prior to call 
getpwuid() function and finally get the uid from the returned data, which is 
the same uid that Process.uid returns. So I suggest the following change in 
rubygems.rb:

@@ -720,7 +720,7 @@
       if 0 == File.expand_path(path).index(Gem.user_home)
         unless win_platform? then
           # only create by matching user
-          next if Etc.getpwuid.uid != File::Stat.new(Gem.user_home).uid
+          next if Process.uid != File::Stat.new(Gem.user_home).uid
         end
       end
       ensure_gem_subdirectories path

Thus we can get the same behaviour, but using Process instead of Etc.getpwuid.


Regards


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=577&aid=29269&group_id=126
_______________________________________________
Rubygems-developers mailing list
http://rubyforge.org/projects/rubygems
Rubygems-developers@rubyforge.org
http://rubyforge.org/mailman/listinfo/rubygems-developers

Reply via email to