link: don't allow more openssl/libressl linkage.

This extends the approach in #597 to further prevent linkage of formulae
that conflict with the system OpenSSL and can cause the issues
described in that issue.
This commit is contained in:
Mike McQuaid 2016-07-31 18:44:24 +01:00
parent 12e7a08b7a
commit 3e5ccaf3d2

View File

@ -24,20 +24,22 @@ module Homebrew
mode.dry_run = true if ARGV.dry_run?
ARGV.kegs.each do |keg|
if HOMEBREW_PREFIX.to_s == "/usr/local" && keg.name == "openssl"
keg_only = keg_only?(keg.rack)
if HOMEBREW_PREFIX.to_s == "/usr/local" && keg_only &&
keg.name.start_with?("openssl", "libressl")
opoo <<-EOS.undent
Refusing to link: openssl
Linking keg-only OpenSSL means you may end up linking against the insecure,
deprecated system version while using the headers from the Homebrew version.
Refusing to link: #{keg.name}
Linking keg-only #{keg.name} means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's #{keg.name}.
Instead, pass the full include/library paths to your compiler e.g.:
-I#{HOMEBREW_PREFIX}/opt/openssl/include -L#{HOMEBREW_PREFIX}/opt/openssl/lib
-I#{HOMEBREW_PREFIX}/opt/#{keg.name}/include -L#{HOMEBREW_PREFIX}/opt/#{keg.name}/lib
EOS
next
elsif keg.linked?
opoo "Already linked: #{keg}"
puts "To relink: brew unlink #{keg.name} && brew link #{keg.name}"
next
elsif keg_only?(keg.rack) && !ARGV.force?
elsif keg_only && !ARGV.force?
opoo "#{keg.name} is keg-only and must be linked with --force"
puts "Note that doing so can interfere with building software."
next