Merge pull request #6031 from iMichka/sudo3
brew: remove sudo call only in docker context
This commit is contained in:
commit
8fdd278cd3
@ -17,16 +17,6 @@ end
|
|||||||
# Also define here so we can rescue regardless of location.
|
# Also define here so we can rescue regardless of location.
|
||||||
class MissingEnvironmentVariables < RuntimeError; end
|
class MissingEnvironmentVariables < RuntimeError; end
|
||||||
|
|
||||||
def create_tap(cmd, tap_name)
|
|
||||||
tap_commands = []
|
|
||||||
if cmd == "services"
|
|
||||||
brew_uid = HOMEBREW_BREW_FILE.stat.uid
|
|
||||||
tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}] if Process.uid.zero? && !brew_uid.zero?
|
|
||||||
end
|
|
||||||
tap_commands += %W[#{HOMEBREW_BREW_FILE} tap #{tap_name}]
|
|
||||||
safe_system(*tap_commands)
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require_relative "global"
|
require_relative "global"
|
||||||
rescue MissingEnvironmentVariables => e
|
rescue MissingEnvironmentVariables => e
|
||||||
@ -123,7 +113,14 @@ begin
|
|||||||
|
|
||||||
# Unset HOMEBREW_HELP to avoid confusing the tap
|
# Unset HOMEBREW_HELP to avoid confusing the tap
|
||||||
ENV.delete("HOMEBREW_HELP") if help_flag
|
ENV.delete("HOMEBREW_HELP") if help_flag
|
||||||
create_tap(cmd, possible_tap.name)
|
tap_commands = []
|
||||||
|
cgroup = Utils.popen_read("cat", "/proc/1/cgroup")
|
||||||
|
if !cgroup.include?("azpl_job") && !cgroup.include?("docker")
|
||||||
|
brew_uid = HOMEBREW_BREW_FILE.stat.uid
|
||||||
|
tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}] if Process.uid.zero? && !brew_uid.zero?
|
||||||
|
end
|
||||||
|
tap_commands += %W[#{HOMEBREW_BREW_FILE} tap #{possible_tap.name}]
|
||||||
|
safe_system(*tap_commands)
|
||||||
ENV["HOMEBREW_HELP"] = "1" if help_flag
|
ENV["HOMEBREW_HELP"] = "1" if help_flag
|
||||||
exec HOMEBREW_BREW_FILE, cmd, *ARGV
|
exec HOMEBREW_BREW_FILE, cmd, *ARGV
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user