Skip to content

Commit c428080

Browse files
committed
Raise an error when the specified OpenSSL library directory doesn't exist.
OpenSSL built from the source creates the library directory to the `/path/to/openssl_dir/lib64` as a default. In the case, the `bundle exec rake compile -- --with-openssl-dir=<openssl_dir>` cannot compile with the lib64 directory, and may compile with system OpenSSL's libraries unintentionally. This commit is to check this case to avoid linking with an unintentional library directory.
1 parent ee03210 commit c428080

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ext/openssl/extconf.rb

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@
1313

1414
require "mkmf"
1515

16+
ssl_dirs = nil
1617
if defined?(::TruffleRuby)
1718
# Always respect the openssl prefix chosen by truffle/openssl-prefix
1819
require 'truffle/openssl-prefix'
19-
dir_config_given = dir_config("openssl", ENV["OPENSSL_PREFIX"]).any?
20+
ssl_dirs = dir_config("openssl", ENV["OPENSSL_PREFIX"])
2021
else
21-
dir_config_given = dir_config("openssl").any?
22+
ssl_dirs = dir_config("openssl")
23+
end
24+
dir_config_given = ssl_dirs.any?
25+
26+
_, ssl_ldir = ssl_dirs
27+
if ssl_ldir&.split(File::PATH_SEPARATOR)&.none? { |dir| File.directory?(dir) }
28+
msg = "OpenSSL library directory could not be found in '#{ssl_ldir}'. " \
29+
'See <link> to fix this error.'
30+
raise msg
2231
end
2332

2433
dir_config("kerberos")

0 commit comments

Comments
 (0)