Skip to content

Commit 8f7e326

Browse files
committed
Check a OpenSSL library directory existence.
Add a logic to check a OpenSSL library directory existence on the given `--with-openssl-dir=<dir>` option. OpenSSL creates the library directory to the `/path/to/openssl_dir/lib64` as a default, when it is built from the source as follow. OpenSSL ``` $ ./Configure \ --prefix=/path/to/openssl $ make $ make install ``` In the case of the following command, the `dir_config("openssl")` returns `["/path/to/openssl/include", "/path/to/openssl/lib"]`. And this causes the Ruby OpenSSL binding is unintentionally built with the system OpenSSL's library directory, because the `/path/to/openssl/lib` doesn't exist. The logic to check the OpenSSL library directory's existence is to avoid building in this case. ruby/openssl ``` $ bundle exec rake compile -- \ --with-openssl-dir=/path/to/openssl ``` In the case of the following command, the `dir_config("openssl")` returns `["/path/to/openssl/include", "/path/to/openssl/lib64:/path/to/openssl/lib64:/path/to/openssl/lib"]`. The returned library directory string is a set of the directories with the path separator ":". ``` $ bundle exec rake compile -- \ --with-openssl-dir=/path/to/openssl \ --with-openssl-lib=/path/to/openssl/lib64 ```
1 parent 037c181 commit 8f7e326

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ext/openssl/extconf.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@
1313

1414
require "mkmf"
1515

16-
dir_config_given = dir_config("openssl").any?
16+
openssl_dirs = dir_config("openssl")
17+
dir_config_given = openssl_dirs.any?
18+
_, ldir = openssl_dirs
19+
20+
if ldir&.split(File::PATH_SEPARATOR)&.none? { |dir| File.directory?(dir) }
21+
raise "OpenSSL library directory could not be found in '#{ldir}'. " \
22+
'You might want to use --with-openssl-lib=<dir> option to specify the ' \
23+
'directory.'
24+
end
25+
1726
dir_config("kerberos")
1827

1928
Logging::message "=== OpenSSL for Ruby configurator ===\n"

0 commit comments

Comments
 (0)