sandbox: do not assume home is inside /Users

It’s not uncommon to use `/var/${USER}` as a home directory, especially
for shared or CLI-only users.

This fixes an issue where a formula that requires `xcodebuild` is
`brew install`ed from such a shared or CLI-only user account.
In that case, `xcodebuild` would fail because it is denied writing to
`/var/${USER}/Library/Developer/Xcode`.

For details, see: https://gist.github.com/claui/17cd89f8f6b4094ac704f142ea811fd8

Suggested-by: Bo Anderson <mail@boanderson.me>
This commit is contained in:
Claudia 2020-07-03 15:39:41 +02:00
parent f1e4c4ed56
commit 23cb93ff1c
No known key found for this signature in database
GPG Key ID: 246AC3C0F10BE51F

View File

@ -47,12 +47,12 @@ class Sandbox
end
def allow_cvs
allow_write_path "/Users/#{ENV["USER"]}/.cvspass"
allow_write_path "#{ENV["HOME"]}/.cvspass"
end
def allow_fossil
allow_write_path "/Users/#{ENV["USER"]}/.fossil"
allow_write_path "/Users/#{ENV["USER"]}/.fossil-journal"
allow_write_path "#{ENV["HOME"]}/.fossil"
allow_write_path "#{ENV["HOME"]}/.fossil-journal"
end
def allow_write_cellar(formula)
@ -63,7 +63,7 @@ class Sandbox
# Xcode projects expect access to certain cache/archive dirs.
def allow_write_xcode
allow_write_path "/Users/#{ENV["USER"]}/Library/Developer"
allow_write_path "#{ENV["HOME"]}/Library/Developer"
end
def allow_write_log(formula)