Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix directory permissions when unpacking. #4532

Merged
merged 2 commits into from
Jul 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions Library/Homebrew/test/unpack_strategy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@
strategy.extract(to: unpack_dir)
expect(unpack_dir/"symlink").to be_a_symlink
end

it "preserves permissions of contained files" do
FileUtils.chmod 0644, path/"file"

strategy.extract(to: unpack_dir)
expect((unpack_dir/"file").stat.mode & 0777).to eq 0644
end

it "preserves the permissions of the destination directory" do
FileUtils.chmod 0700, path
FileUtils.chmod 0755, unpack_dir

strategy.extract(to: unpack_dir)
expect(unpack_dir.stat.mode & 0777).to eq 0755
end
end

describe UncompressedUnpackStrategy do
Expand Down
4 changes: 3 additions & 1 deletion Library/Homebrew/unpack_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def self.can_extract?(path:, magic_number:)
private

def extract_to_dir(unpack_dir, basename:, verbose:)
FileUtils.cp_r File.join(path, "."), unpack_dir, preserve: true, verbose: verbose
path.children.each do |child|
FileUtils.copy_entry child, unpack_dir/child.basename, true, false
end
end
end

Expand Down