aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2012-03-07 12:50:15 +0000
committerMax Howell2012-03-07 12:50:15 +0000
commit6988a75b84179fa9d7b22f2b7172c4f8fa3805a4 (patch)
tree88869e52b39f9b07d968d556b28bc9e4babfe8c6 /Library
parenta13ff43886f5255694ead2789a65bda3b97dd6b9 (diff)
downloadbrew-6988a75b84179fa9d7b22f2b7172c4f8fa3805a4.tar.bz2
Don't allow `sudo brew upgrade` if not sensible
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/upgrade.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb
index f27357764..215ae3d14 100644
--- a/Library/Homebrew/cmd/upgrade.rb
+++ b/Library/Homebrew/cmd/upgrade.rb
@@ -9,6 +9,12 @@ end
module Homebrew extend self
def upgrade
+ if Process.uid.zero? and not File.stat(HOMEBREW_BREW_FILE).uid.zero?
+ # note we only abort if Homebrew is *not* installed as sudo and the user
+ # calls brew as root. The fix is to chown brew to root.
+ abort "Cowardly refusing to `sudo brew upgrade'"
+ end
+
Homebrew.perform_preinstall_checks
outdated = if ARGV.named.empty?