Skip to content

Commit fc2ddf5

Browse files
committed
Raise an error when the specified OpenSSL library directory doesn't exist.
OpenSSL creates the library directory to the `/path/to/openssl_dir/lib64` as a default, when it is built from the source as follow. 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 a check to prevent the case. Here is the example. ``` $ ls -l /path/to/openssl_dir/ ... drwxr-xr-x. 5 jaruga jaruga 4096 Jul 17 23:06 lib64/ ... $ bundle exec rake compile -- \ --with-openssl-dir=/path/to/openssl_dir ... ../../../../ext/openssl/extconf.rb:21:in `<main>': OpenSSL library directory could not be found in '/path/to/openssl_dir/lib'. You might want to use --with-openssl-lib=<dir> option to specify the directory. (RuntimeError) rake aborted! ... ``` To avoid this error, you can compile with the command below. ``` $ bundle exec rake compile -- \ --with-openssl-dir=/path/to/openssl \ --with-openssl-lib=/path/to/openssl/lib64 ```
1 parent e379cc0 commit fc2ddf5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ext/openssl/extconf.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@
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+
if ldir&.split(File::PATH_SEPARATOR)&.none? { |dir| File.directory?(dir) }
20+
raise "OpenSSL library directory could not be found in '#{ldir}'. " \
21+
'You might want to use --with-openssl-lib=<dir> option to specify the ' \
22+
'directory.'
23+
end
24+
1725
dir_config("kerberos")
1826

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

0 commit comments

Comments
 (0)