* lib/rubygems.rb (Gem.set_home, Gem.set_paths): should not create

directories stealthily.  [ruby-core:20990]

* lib/rubygems.rb (Gem.find_home): expand_path deals with platform
  dependent envirionments.

* lib/rdoc/ri/paths.rb (RDoc::HOMEDIR): ditto.

* instruby.rb (gem): creates gem directories at installation.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-01-04 08:07:22 +00:00
Родитель ef7057fe2f
Коммит 6754cad8e9
4 изменённых файлов: 26 добавлений и 34 удалений

Просмотреть файл

@ -1,3 +1,15 @@
Sun Jan 4 17:07:45 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rubygems.rb (Gem.set_home, Gem.set_paths): should not create
directories stealthily. [ruby-core:20990]
* lib/rubygems.rb (Gem.find_home): expand_path deals with platform
dependent envirionments.
* lib/rdoc/ri/paths.rb (RDoc::HOMEDIR): ditto.
* instruby.rb (gem): creates gem directories at installation.
Sun Jan 4 15:41:37 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Jan 4 15:41:37 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* encoding.c (rb_filesystem_encoding, rb_locale_charmap): uses * encoding.c (rb_filesystem_encoding, rb_locale_charmap): uses

Просмотреть файл

@ -409,6 +409,13 @@ install?(:local, :comm, :man) do
end end
end end
install?(:local, :comm, :gem) do
puts "creating default gem directories"
gpath = Gem.default_dir
makedirs Gem::DIRECTORIES.collect {|dir| File.join(gpath, dir)}
end
$install << :local << :ext if $install.empty? $install << :local << :ext if $install.empty?
$install.each do |inst| $install.each do |inst|
if !(procs = $install_procs[inst]) || procs.empty? if !(procs = $install_procs[inst]) || procs.empty?

Просмотреть файл

@ -31,13 +31,7 @@ module RDoc::RI::Paths
base = File.join(RbConfig::CONFIG['datadir'], "ri", VERSION) base = File.join(RbConfig::CONFIG['datadir'], "ri", VERSION)
SYSDIR = File.join(base, "system") SYSDIR = File.join(base, "system")
SITEDIR = File.join(base, "site") SITEDIR = File.join(base, "site")
homedir = ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH'] HOMEDIR = (File.expand_path("~/.rdoc") rescue nil)
if homedir then
HOMEDIR = File.join(homedir, ".rdoc")
else
HOMEDIR = nil
end
begin begin
require 'rubygems' unless defined?(Gem) and defined?(Gem::Enable) and require 'rubygems' unless defined?(Gem) and defined?(Gem::Enable) and

Просмотреть файл

@ -373,22 +373,12 @@ module Gem
# least on Win32). # least on Win32).
def self.find_home def self.find_home
['HOME', 'USERPROFILE'].each do |homekey| File.expand_path("~")
return ENV[homekey] if ENV[homekey] rescue
end if File::ALT_SEPARATOR then
"C:/"
if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then else
return "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}" "/"
end
begin
File.expand_path("~")
rescue
if File::ALT_SEPARATOR then
"C:/"
else
"/"
end
end end
end end
@ -691,7 +681,6 @@ module Gem
def self.set_home(home) def self.set_home(home)
home = home.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR home = home.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
@gem_home = home @gem_home = home
ensure_gem_subdirectories(@gem_home)
end end
private_class_method :set_home private_class_method :set_home
@ -716,16 +705,6 @@ module Gem
end end
@gem_path.uniq! @gem_path.uniq!
@gem_path.each do |path|
if 0 == File.expand_path(path).index(Gem.user_home)
next unless File.directory? Gem.user_home
unless win_platform? then
# only create by matching user
next if Etc.getpwuid.uid != File::Stat.new(Gem.user_home).uid
end
end
ensure_gem_subdirectories path
end
end end
private_class_method :set_paths private_class_method :set_paths