Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Copy openssl.cnf to the default path for test-all #120

Closed
wants to merge 1 commit into from

4 participants

@shirosaki
Collaborator

The default path of openssl.cnf is determined when openssl configure.

Here are openssl configure options for configration file path.

  --prefix=DIR  Install in DIR/bin, DIR/lib, DIR/include/openssl.
                Configuration files used by OpenSSL will be in DIR/ssl
                or the directory specified by --openssldir.

  --openssldir=DIR Directory for OpenSSL files. If no prefix is specified,
                the library files and binaries are also installed there.

Copying openssl.cnf to the path will fix a failure of ruby test-all
OpenSSL::TestConfig#test_constants.

Related post:
https://groups.google.com/d/msg/rubyinstaller/CjP3BMpoEpE/fRE2gYC4jZ0J

Now openssl.cnf path of knapsack is C:\Users\Luis\Projects\oss\knapsack.old\knap-build\var\knapsack\software\x86-windows\openssl\1.0.0j\ssl\openssl.cnf.
Perhaps it might be nice if the path were more general path name like C:\OpenSSL\ssl\openssl.cnf.

@shirosaki shirosaki Copy openssl.cnf to the default path for test-all
The default path of openssl.cnf is determined when openssl configure.

Here are openssl configure options for configration file path.

  --prefix=DIR  Install in DIR/bin, DIR/lib, DIR/include/openssl.
                Configuration files used by OpenSSL will be in DIR/ssl
                or the directory specified by --openssldir.

  --openssldir=DIR Directory for OpenSSL files. If no prefix is specified,
                the library files and binaries are also installed there.

Copying openssl.cnf to the path will fix a failure of ruby test-all
OpenSSL::TestConfig#test_constants.

Related post:
https://groups.google.com/d/msg/rubyinstaller/CjP3BMpoEpE/fRE2gYC4jZ0J
13dcbc7
@Azolo
Owner

I'm not gonna lie, I'm super confused over the whole process with openssl.

My only request is instead of using a conditional in knapsack.rb can we throw this in a separate file? Then let rake handle the build dependencies.

Basically like this https://gist.github.com/3004693

Thanks you so much! Fixing means I don't have to think of a fish market every time I see knapsack.old

@luislavena
Owner

I'm actually more inclined to patch OpenSSL and have relative paths than putting files on different directories.

For example, OpenSSL was built from an old project folder under user Luis

But today I build RubyInstaller on a worker machine under user Worker, there is no Luis folder.

Attempting to create a folder at the level of C:/Users will result on access denied:

C:\Users\Luis>ripl
>> require "fileutils"
=> true
>> FileUtils.mkdir_p "C:/Users/FooBar/something/other/whatever"
Errno::EACCES: Permission denied - C:/Users/FooBar

The alternative is set OPENSSL_CONF environment variable:

>> require "openssl/config"
=> false
>> OpenSSL::Config::DEFAULT_CONFIG_FILE
=> "C:/Users/Luis/Projects/oss/knapsack.old/knap-build/var/knapsack/software/x86-windows/openssl/1.0.0j/ssl/openssl.cnf"

C:\Users\Luis>set OPENSSL_CONF=C:\Knapsack\x86-windows\ssl\openssl.cnf

C:\Users\Luis>ripl
>> require "openssl"
=> true
>> require "openssl/config"
=> false
>> OpenSSL::Config::DEFAULT_CONFIG_FILE
=> "C:\\Knapsack\\x86-windows\\ssl\\openssl.cnf"
@Azolo
Owner

Hmmm, Why not just set the OPENSSL_CONF environment variable to the temporary cnf file created during the test setup?

The test is for the OpenSSL constants, but makes assumptions about system configuration.

@shirosaki
Collaborator

Fixing OpenSSL::TestConfig#test_constants to use OPENSSL_CONF environment variable would be good if it's acceptable to ruby-core. It would be rare case that default config file path doesn't exist.

Before running test-all, I usually do rake devkit:sh.
Another idea is setting OPENSSL_CONF environment variable when rake devkit:sh.

@luislavena
Owner

@shirosaki @Azolo sorry for not being more clear

Just by setting OPENSSL_CONF before running tests (perhaps as part of the activate action of openssl recipe) will be enough to fix OpenSSL::Config::DEFAULT_CONFIG_FILE

As I shown above, just by setting that variable it changes the default directory DEFAULT_CONFIG_FILE returns.

I think the only acceptable option for the test is to skip it if the default configuration file is not valid, that will be my only recommendation to Ruby-Core.

When you run rake ruby19:dependencies devkit:sh, OpenSSL dependency should get activated and thus, OPENSSL_CONF environment variable enabled.

@shirosaki
Collaborator

@luislavena Thank you for clarification.

I'll create another pull request for setting OPENSSL_CONF in OpenSSL dependency.

I didn't know rake ruby19:dependencies devkit:sh will work.

A bit off topic, I think the command looks long. Can I add task rake ruby19:sh like the following?

diff --git a/recipes/interpreter/ruby19.rake b/recipes/interpreter/ruby19.rake
index 561140c..83ccddc 100644
--- a/recipes/interpreter/ruby19.rake
+++ b/recipes/interpreter/ruby19.rake
@@ -211,6 +211,10 @@ task :ruby19 => [
 namespace :ruby19 do
   task :dependencies => ['interpreter:ruby19:dependencies']
   task :clean => ['interpreter:ruby19:clean']
+
+  task :sh => ['interpreter:ruby19:dependencies'] do
+    Rake::Task['devkit:sh'].invoke
+  end
 end

 unless ENV["NOGEMS"]
@shirosaki shirosaki closed this
@Azolo
Owner

Setting OPENSSL_CONF during the test doesn't work anyway. The OpenSSL::Config::DEFAULT_CONFIG_FILE is set when the OpenSSL library is required. So changing environment during the test doesn't work.

Also I wonder how other static packages like Tokaido handle this.

@luislavena
Owner

@Azolo needs to be set before openssl is loaded, it has no effect since the constant is defined at Init_ and not when requested the first time.

@Azolo
Owner

@luislavena Yeah I figured that out the hard way. :smiley:

@shirosaki patch fixes it quickly and in the least intrusive way, which really was the goal of the project.

I feel like there is a better way to test to see if the Constant is correct. But I don't know how to do it, so I'm just creating noise.

Either way there are more important things to do, but thanks for the verification.

@luislavena
Owner

I feel like there is a better way to test to see if the Constant is correct. But I don't know how to do it, so I'm just creating noise.

skip "config file missing" unless File.exists?(OpenSSL::Config::DEFAULT_CONFIG_FILE)

That should be inside the test after the check if the constant has been defined.

I've asked to @emboss to check and let me know if that sound reasonable. The thing is that hardcoded paths are a real bummer :cry:

@emboss

Luis has discussed the issue with me, I hope to find a convenient way for getting rid of the hardcoded paths there soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 27, 2012
  1. @shirosaki

    Copy openssl.cnf to the default path for test-all

    shirosaki authored
    The default path of openssl.cnf is determined when openssl configure.
    
    Here are openssl configure options for configration file path.
    
      --prefix=DIR  Install in DIR/bin, DIR/lib, DIR/include/openssl.
                    Configuration files used by OpenSSL will be in DIR/ssl
                    or the directory specified by --openssldir.
    
      --openssldir=DIR Directory for OpenSSL files. If no prefix is specified,
                    the library files and binaries are also installed there.
    
    Copying openssl.cnf to the path will fix a failure of ruby test-all
    OpenSSL::TestConfig#test_constants.
    
    Related post:
    https://groups.google.com/d/msg/rubyinstaller/CjP3BMpoEpE/fRE2gYC4jZ0J
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 1 deletion.
  1. +18 −1 recipes/dependencies/knapsack.rake
View
19 recipes/dependencies/knapsack.rake
@@ -29,7 +29,24 @@ dependencies.each do |dependency_key, dependency|
end
task :extract => [:extract_utils, :download, dependency.target, et]
- task :activate => [:extract] do
+ task :patch => [:extract] do
+ if dependency_key == 'openssl'
+ openssl_base = File.join(RubyInstaller::ROOT, dependency.target)
+ conf_file = File.join(openssl_base, "include/openssl/opensslconf.h")
+ content = File.open(conf_file, "rb") { |f| f.read }
+
+ if content
+ ssl_dir = content.sub(/.*\n#define OPENSSLDIR "([^\n]*)"\n.*/m, '\1')
+ end
+
+ if ssl_dir && !File.exist?(File.join(ssl_dir, "openssl.cnf"))
+ mkdir_p ssl_dir
+ cp File.join(openssl_base, "ssl/openssl.cnf"), ssl_dir
+ end
+ end
+ end
+
+ task :activate => [:extract, :patch] do
puts "Activating #{dependency.human_name} version #{dependency.version}"
activate(dependency.target)
end
Something went wrong with that request. Please try again.