aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2012-03-04 02:47:53 +0000
committerMax Howell2012-03-04 02:47:53 +0000
commitf7d7fb1e812d443ec739938956ebb1452a262387 (patch)
tree9cffa094bf0cc7e51fe43f1f3bc6d6baec1ecc16 /Library
parent6898eadcc570cc7842efe5c377bda591d867db89 (diff)
downloadbrew-f7d7fb1e812d443ec739938956ebb1452a262387.tar.bz2
Don't allow `brew link` to be run as sudo
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/link.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/link.rb b/Library/Homebrew/cmd/link.rb
index d222f3d25..df3445aa5 100644
--- a/Library/Homebrew/cmd/link.rb
+++ b/Library/Homebrew/cmd/link.rb
@@ -2,6 +2,12 @@ module Homebrew extend self
def link
raise KegUnspecifiedError if ARGV.named.empty?
+ 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 link'"
+ end
+
ARGV.kegs.each do |keg|
print "Linking #{keg}... "
puts if ARGV.verbose?