Top Level Namespace

Defined Under Namespace

Modules: Rodsec

Constant Summary collapse

MODSECURITY_LIB_NAME =
'modsecurity'
SO_FUNC =
'msc_init'
STANDARD_DIRS =
[
%w[/usr/local/include /usr/local/lib],
%w[/usr/include       /usr/lib],

Instance Method Summary collapse

Instance Method Details

#confirm_include_lib(include_dir, lib_dir) ⇒ Object

raise an exception if one of the paths doesn’t exist



15
16
17
18
# File 'ext/msc_intervention/extconf.rb', line 15

def confirm_include_lib include_dir, lib_dir
  File.realpath(File.join include_dir, intervention_header_name)
  File.realpath(File.join lib_dir, so_name)
end

#create_modsec_lib_rb(so_lib_path, dst_ruby_file: 'modsec_lib.rb') ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'ext/msc_intervention/extconf.rb', line 20

def create_modsec_lib_rb so_lib_path, dst_ruby_file: 'modsec_lib.rb'
  puts "runtime loads #{so_lib_path}"

  # create a direct path to the library, because it's often in a nonstandard location
  ruby_lib_dir = File.join CONFIG['srcdir'], '..', '..', 'lib', 'rodsec'
  File.open File.join(ruby_lib_dir,dst_ruby_file), 'w' do |io|
    io.write <<~EOS
      # Generated by extconf.rb
      module Rodsec
        MODSECURITY_SO_PATH = '#{so_lib_path}'
      end
    EOS
  end
end

#find_header_and_library(include_dir, lib_dir) ⇒ Object



35
36
37
38
39
40
# File 'ext/msc_intervention/extconf.rb', line 35

def find_header_and_library include_dir, lib_dir
  ok = true
  ok &&= find_header intervention_header_name, include_dir
  ok &&= find_library MODSECURITY_LIB_NAME, SO_FUNC, lib_dir
  ok or abort
end

#intervention_header_nameObject



10
11
12
# File 'ext/msc_intervention/extconf.rb', line 10

def intervention_header_name
  @intervention_header_name ||= 'modsecurity/intervention.h'
end

#so_nameObject



6
7
8
# File 'ext/msc_intervention/extconf.rb', line 6

def so_name
  @so_name ||= "lib#{MODSECURITY_LIB_NAME}.#{CONFIG['DLEXT']}"
end