Skip to content

Commit

Permalink
[rubygems/rubygems] Respect global umask when writing regular files
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and matzbot committed Mar 22, 2024
1 parent 7b3ef37 commit 8ef923d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rubygems/package.rb
Expand Up @@ -454,7 +454,7 @@ def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:

if entry.file?
File.open(destination, "wb") {|out| copy_stream(entry, out) }
FileUtils.chmod file_mode(entry.header.mode), destination
FileUtils.chmod file_mode(entry.header.mode) & ~File.umask, destination
end

verbose destination
Expand Down
6 changes: 3 additions & 3 deletions test/rubygems/test_gem.rb
Expand Up @@ -133,7 +133,7 @@ def test_self_install_permissions_umask_0

def test_self_install_permissions_umask_077
umask = File.umask(0o077)
assert_self_install_permissions
assert_self_install_permissions(data_mode: 0o600)
ensure
File.umask(umask)
end
Expand All @@ -151,12 +151,12 @@ def test_self_install_permissions_with_format_executable_and_non_standard_ruby_i
Gem::Installer.exec_format = nil
end

def assert_self_install_permissions(format_executable: false)
def assert_self_install_permissions(format_executable: false, data_mode: 0o640)
mask = Gem.win_platform? ? 0o700 : 0o777
options = {
dir_mode: 0o500,
prog_mode: Gem.win_platform? ? 0o410 : 0o510,
data_mode: 0o640,
data_mode: data_mode,
wrappers: true,
format_executable: format_executable,
}
Expand Down

0 comments on commit 8ef923d

Please sign in to comment.