diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-17 15:02:50 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-17 15:02:50 +0000 |
commit | 86ae4bc2d9d472ac6309742392218a9b3d015cf4 (patch) | |
tree | c86bfe2eba48ca358863fb25e3b737925ca09e24 /lib | |
parent | 3e3f03461b83e8cb3bd6c9033d5f3619ee18bb92 (diff) |
merge revision(s) 39607: [Backport #7713]
* lib/rubygems.rb: Allow specification of directory permissions.
[ruby-trunk - Bug #7713]
* test/rubygems/test_gem.rb: Test for the above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@39798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb index ac992d09d6..80e6a1ff74 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -375,20 +375,28 @@ module Gem end ## - # Quietly ensure the named Gem directory contains all the proper + # Quietly ensure the Gem directory +dir+ contains all the proper # subdirectories. If we can't create a directory due to a permission # problem, then we will silently continue. + # + # If +mode+ is given, missing directories are created with this mode. + # + # World-writable directories will never be created. - def self.ensure_gem_subdirectories dir = Gem.dir + def self.ensure_gem_subdirectories dir = Gem.dir, mode = nil old_umask = File.umask File.umask old_umask | 002 require 'fileutils' + options = {} + + options[:mode] = mode if mode + REPOSITORY_SUBDIRECTORIES.each do |name| subdir = File.join dir, name next if File.exist? subdir - FileUtils.mkdir_p subdir rescue nil # in case of perms issues -- lame + FileUtils.mkdir_p subdir, options rescue nil end ensure File.umask old_umask |