aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2016-09-23 08:26:49 +0100
committerMike McQuaid2016-09-23 08:29:05 +0100
commit536c48e804407a99c9fe750ca31cd42c7c1fd55a (patch)
tree6cb748a9388ed5e3ba20cbf0b0e25e13f4cb3b36 /Library
parent5cf3838f4292f3c47bc6a66e6d532fa290bcc5e0 (diff)
downloadbrew-536c48e804407a99c9fe750ca31cd42c7c1fd55a.tar.bz2
sandbox: tweak HOMEBREW_REPOSITORY handling.
If we have a HOMEBREW_REPOSITORY and HOMEBREW_PREFIX mismatch (now the default) then we can block access to the whole of HOMEBREW_REPOSITORY rather than just the HOMEBREW_LIBRARY and `.git`.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/postinstall.rb2
-rw-r--r--Library/Homebrew/sandbox.rb10
2 files changed, 8 insertions, 4 deletions
diff --git a/Library/Homebrew/cmd/postinstall.rb b/Library/Homebrew/cmd/postinstall.rb
index 71b71b3f5..e0bd8e31b 100644
--- a/Library/Homebrew/cmd/postinstall.rb
+++ b/Library/Homebrew/cmd/postinstall.rb
@@ -36,7 +36,7 @@ module Homebrew
sandbox.allow_write_cellar(formula)
sandbox.allow_write_xcode
sandbox.allow_write_path HOMEBREW_PREFIX
- sandbox.deny_write_homebrew_library
+ sandbox.deny_write_homebrew_repository
sandbox.exec(*args)
else
exec(*args)
diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb
index a7fc99d4a..4d0709cb4 100644
--- a/Library/Homebrew/sandbox.rb
+++ b/Library/Homebrew/sandbox.rb
@@ -84,10 +84,14 @@ class Sandbox
allow_write_path formula.logs
end
- def deny_write_homebrew_library
- deny_write_path HOMEBREW_LIBRARY
- deny_write_path HOMEBREW_REPOSITORY/".git"
+ def deny_write_homebrew_repository
deny_write HOMEBREW_BREW_FILE
+ if HOMEBREW_PREFIX.to_s != HOMEBREW_REPOSITORY.to_s
+ deny_write_path HOMEBREW_REPOSITORY
+ else
+ deny_write_path HOMEBREW_LIBRARY
+ deny_write_path HOMEBREW_REPOSITORY/".git"
+ end
end
def exec(*args)