aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMax Howell2011-07-29 16:39:32 +0100
committerMax Howell2011-07-30 11:03:34 +0100
commite354b70db36030c24b4385cf1477bfc6bec3313a (patch)
tree82bac269d60e951a0f0e860855feb992ab710252 /bin
parent81c7ec993394a6b33eb5056f8863e8c4b1f9ed3e (diff)
downloadbrew-e354b70db36030c24b4385cf1477bfc6bec3313a.tar.bz2
If brew is installed non-root refuse to `sudo brew`
Rationale: people break their installs by mixing sudo and non-sudo usage. They are used to having to `sudo port install` and shit like that, so I understand why the mixing happens.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/brew5
1 files changed, 5 insertions, 0 deletions
diff --git a/bin/brew b/bin/brew
index 5fe19cc89..b7c5ff98c 100755
--- a/bin/brew
+++ b/bin/brew
@@ -26,6 +26,11 @@ when '-v'
end
end
+if Process.uid.zero? and not File.stat(HOMEBREW_BREW_FILE).uid.zero?
+ # note we only abort if Homebrew is *not* uninstalled sudo and the user
+ # calls brew as root. The fix is to chown brew to root.
+ abort "Cowardly refusing to `sudo brew'"
+end
case HOMEBREW_PREFIX.to_s when '/', '/usr'
# it may work, but I only see pain this route and don't want to support it
abort "Cowardly refusing to continue at this prefix: #{HOMEBREW_PREFIX}"