Skip to content

Commit

Permalink
Merge pull request #393 from oneclick/avoid-etc
Browse files Browse the repository at this point in the history
Update operating_system.rb to avoid early load of etc.so
  • Loading branch information
larskanis authored Oct 18, 2024
2 parents 704d7a4 + 714c8e4 commit 62a4d0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions resources/files/operating_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def operating_system_defaults
end

begin
config_fname = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE
unless File.exist?(config_fname)
config_dir = ENV['ProgramData']
if config_dir && !File.exist?(config_fname = File.join(config_dir, "gemrc"))
File.open(config_fname, File::CREAT | File::EXCL | File::WRONLY) do |fd|
fd.write <<-EOT
# This is the system wide config file for Rubygems.
Expand Down
10 changes: 10 additions & 0 deletions test/test_gemrc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#frozen_string_literal: true
require "minitest/autorun"
require "yaml"

class TestGemrc < Minitest::Test
def test_gemrc
y = YAML.load_file(Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE)
assert_kind_of Hash, y, "a default gemrc file should have been generated at the very first rubygems call for security reasons"
end
end

0 comments on commit 62a4d0d

Please sign in to comment.