diff options
| author | Xu Cheng | 2016-01-14 16:07:11 +0800 |
|---|---|---|
| committer | Xu Cheng | 2016-01-14 19:32:07 +0800 |
| commit | c4dcf8b7b28988bde1dfc0d045a9992ccaba757e (patch) | |
| tree | 5dc672fc9e6fe4af4f0f445f6505cf546540be40 | |
| parent | 31da9b266a5eab3bc349d62e7f5cd7cb67741375 (diff) | |
| download | brew-c4dcf8b7b28988bde1dfc0d045a9992ccaba757e.tar.bz2 | |
brew: tap missing tap as normal user
Before this, `sudo brew cask` will auto install Homebrew cask as root
user. This will cause permission problem for files in `Tap` directory.
Therefore, let's check process uid and switch to normal user for tap.
As result, `sudo brew cask` will work as the same before, except tap
files will have the correct permission attributes.
Closes Homebrew/homebrew#48059.
Signed-off-by: Xu Cheng <xucheng@me.com>
| -rwxr-xr-x | Library/brew.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Library/brew.rb b/Library/brew.rb index 94fa33207..df83df120 100755 --- a/Library/brew.rb +++ b/Library/brew.rb @@ -160,7 +160,13 @@ begin end if possible_tap && !possible_tap.installed? - possible_tap.install + brew_uid = File.stat(HOMEBREW_BREW_FILE).uid + tap_commands = [] + if Process.uid.zero? && !brew_uid.zero? + tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}] + end + tap_commands += %W[#{HOMEBREW_BREW_FILE} tap #{possible_tap}] + safe_system *tap_commands exec HOMEBREW_BREW_FILE, cmd, *ARGV else onoe "Unknown command: #{cmd}" |
