From 467666c8b33dc8cf4de41c95da440216656abfa4 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Tue, 13 Aug 2024 17:49:37 +0100 Subject: [PATCH] unpack_strategy/dmg: fix UID handling --- Library/Homebrew/unpack_strategy/dmg.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/unpack_strategy/dmg.rb b/Library/Homebrew/unpack_strategy/dmg.rb index 2c302146b0bc2..ad2fe5f3873d1 100644 --- a/Library/Homebrew/unpack_strategy/dmg.rb +++ b/Library/Homebrew/unpack_strategy/dmg.rb @@ -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