download_strategy: fix UID handling for Git submodules
Source builds that use Git checkouts with submodules can choke when the process UID does not match its EUID. We can fix this by using the `reset_uid` option added in #17782.
This commit is contained in:
parent
f84b8ebf69
commit
49b27767aa
@ -1040,13 +1040,15 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
||||
sig { params(timeout: T.nilable(Time)).void }
|
||||
def update_submodules(timeout: nil)
|
||||
command! "git",
|
||||
args: ["submodule", "foreach", "--recursive", "git submodule sync"],
|
||||
chdir: cached_location,
|
||||
timeout: Utils::Timer.remaining(timeout)
|
||||
args: ["submodule", "foreach", "--recursive", "git submodule sync"],
|
||||
chdir: cached_location,
|
||||
timeout: Utils::Timer.remaining(timeout),
|
||||
reset_uid: true
|
||||
command! "git",
|
||||
args: ["submodule", "update", "--init", "--recursive"],
|
||||
chdir: cached_location,
|
||||
timeout: Utils::Timer.remaining(timeout)
|
||||
args: ["submodule", "update", "--init", "--recursive"],
|
||||
chdir: cached_location,
|
||||
timeout: Utils::Timer.remaining(timeout),
|
||||
reset_uid: true
|
||||
fix_absolute_submodule_gitdir_references!
|
||||
end
|
||||
|
||||
@ -1059,8 +1061,9 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
||||
# See https://github.com/Homebrew/homebrew-core/pull/1520 for an example.
|
||||
def fix_absolute_submodule_gitdir_references!
|
||||
submodule_dirs = command!("git",
|
||||
args: ["submodule", "--quiet", "foreach", "--recursive", "pwd"],
|
||||
chdir: cached_location).stdout
|
||||
args: ["submodule", "--quiet", "foreach", "--recursive", "pwd"],
|
||||
chdir: cached_location,
|
||||
reset_uid: true).stdout
|
||||
|
||||
submodule_dirs.lines.map(&:chomp).each do |submodule_dir|
|
||||
work_dir = Pathname.new(submodule_dir)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user