Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow up to 1013: find_files() errors still occurring for apache_conf resource after 0.33.0 upgrade #1030

Closed
davidcpell opened this issue Sep 7, 2016 · 4 comments

Comments

@davidcpell
Copy link
Contributor

davidcpell commented Sep 7, 2016

Description

This is a follow-up to #1013. The find_files() failures are still occurring for me with the apache_conf resource even after updating to InSpec 0.33.0.

It seems (?) like the problem is happening the httpd is installed with the community apache2 cookbook.

InSpec and Platform Version

Windows 7 Enterprise

$ chef exec inspec version
0.33.0

Replication Case

I've created a dummy cookbook that can be used to replicate: https://github.com/davidcpell/apatchme. It tests Centos 7.2 and 6.7 using both the main apache2 community cookbook and just package 'httpd'.

  1. clone repo
  2. $ chef exec kitchen verify

See dummy cookbook README for more info

Stacktrace

For the recipe that uses the community cookbook (that installs some modules, I think), the output looks like this:

-----> Verifying <comm-ckbk-centos-67>...
       Use `C:/Users/c5249136/code/chef/cookbooks/apatchme/test/recipes/comm_ckbk` for testing
find_files(): exit 1 from `find /etc/httpd/etc/httpd/mods-enabled/*.load -maxdepth 1 -type f`
find_files(): exit 1 from `find /etc/httpd/etc/httpd/mods-enabled/*.conf -maxdepth 1 -type f`
find_files(): exit 1 from `find /etc/httpd/etc/httpd/ports.conf -maxdepth 1 -type f`
find_files(): exit 1 from `find /etc/httpd/etc/httpd/conf-enabled/*.conf -maxdepth 1 -type f`
find_files(): exit 1 from `find /etc/httpd/etc/httpd/sites-enabled/*.conf -maxdepth 1 -type f`

The /etc/httpd part of the path is being doubled.

@davidcpell
Copy link
Contributor Author

@chris-rock I found where the issue is happening for me:

https://github.com/chef/inspec/blob/master/lib/resources/apache_conf.rb#L107-L112

In this block, f is an absolute path to a set of files to check, and @conf_dir is an absolute path to the location of httpd.conf. When they are joined, the path to the httpd root is doubled. Here's some output from a binding.pry I just did:

From: /Users/david/.chefdk/gem/ruby/2.1.0/gems/inspec-0.33.0/lib/resources/apache_conf.rb @ line 110 Inspec::Resources::ApacheConf#include_files:

    102: def include_files(params)
    103:   # see if there is more config files to include
    104:   include_files = params['Include'] || []
    105:   include_files_optional = params['IncludeOptional'] || []
    106:
    107:   includes = []
    108:   (include_files + include_files_optional).each do |f|
    109:     binding.pry
 => 110:     id = File.join(@conf_dir, f)
    111:     files = find_files(id, depth: 1, type: 'file')
    112:
    113:     includes.push(files) if files
    114:   end
    115:
    116:   # [].flatten! == nil
    117:   includes.flatten! || []
    118: end

[1] pry(#<#<Class:0x007f897c1d51e8>>)> @conf_dir
=> "/etc/httpd/"
[2] pry(#<#<Class:0x007f897c1d51e8>>)> f
=> "/etc/httpd/mods-enabled/*.load"
[3] pry(#<#<Class:0x007f897c1d51e8>>)> File.join(@conf_dir, f)
=> "/etc/httpd/etc/httpd/mods-enabled/*.load"

@jeremymv2
Copy link
Contributor

@davidcpell are you using absolute paths in your httpd.conf or ones relative to ServerRoot?

http://httpd.apache.org/docs/2.4/mod/core.html#include

I believe inspec is assuming they are relative to ServerRoot.

@chris-rock
Copy link
Contributor

@davidcpell is this solved with #1042 as well?

@davidcpell
Copy link
Contributor Author

@chris-rock yes sorry! closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants