brew.sh: Don't allow system tmp dirs as prefixes

This commit is contained in:
William Woodruff 2018-06-30 09:34:21 -04:00
parent 343a5b45a9
commit 35138dd6dd
No known key found for this signature in database
GPG Key ID: 600D68320BE45ACC

View File

@ -294,6 +294,20 @@ EOS
}
check-run-command-as-root
check-prefix-is-not-tmpdir() {
if [[ "${HOMEBREW_PREFIX}" = /tmp/* ||
"${HOMEBREW_PREFIX}" = /private/tmp/* ]]
then
odie <<EOS
Your HOMEBREW_PREFIX is in one of the system temporary directories, which Homebrew
uses to store downloads and builds. You can resolve this by installing Homebrew to
either the standard prefix (/usr/local/) or to a non-standard prefix that is not
a system temporary directory.
EOS
fi
}
check-prefix-is-not-tmpdir
if [[ "$HOMEBREW_PREFIX" = "/usr/local" &&
"$HOMEBREW_PREFIX" != "$HOMEBREW_REPOSITORY" &&
"$HOMEBREW_CELLAR" = "$HOMEBREW_REPOSITORY/Cellar" ]]