Skip to content
New issue

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

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

Already on GitHub? # to your account

unpack_strategy/dmg: fix UID handling #18040

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions Library/Homebrew/unpack_strategy/dmg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,10 @@ def extract_to_dir(unpack_dir, basename:, verbose:)

bomfile_path = T.must(bomfile.path)

# Ditto will try to write as the UID, not the EUID and the Tempfile has 0700 permissions.
if Process.euid != Process.uid
FileUtils.chown(nil, Process.gid, bomfile_path)
FileUtils.chmod "g+rw", bomfile_path
end

system_command!("ditto",
args: ["--bom", bomfile_path, "--", path, unpack_dir],
verbose:)
args: ["--bom", bomfile_path, "--", path, unpack_dir],
verbose:,
reset_uid: true)

FileUtils.chmod "u+w", Pathname.glob(unpack_dir/"**/*", File::FNM_DOTMATCH).reject(&:symlink?)
end
Expand Down