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? mode.dry_run = true if ARGV.dry_run?
ARGV.kegs.each do |keg| 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 opoo <<-EOS.undent
Refusing to link: openssl Refusing to link: #{keg.name}
Linking keg-only OpenSSL means you may end up linking against the insecure, Linking keg-only #{keg.name} means you may end up linking against the insecure,
deprecated system version while using the headers from the Homebrew version. deprecated system OpenSSL while using the headers from Homebrew's #{keg.name}.
Instead, pass the full include/library paths to your compiler e.g.: 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 EOS
next next
elsif keg.linked? elsif keg.linked?
opoo "Already linked: #{keg}" opoo "Already linked: #{keg}"
puts "To relink: brew unlink #{keg.name} && brew link #{keg.name}" puts "To relink: brew unlink #{keg.name} && brew link #{keg.name}"
next 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" opoo "#{keg.name} is keg-only and must be linked with --force"
puts "Note that doing so can interfere with building software." puts "Note that doing so can interfere with building software."
next next