Skip to content

Commit 6426552

Browse files
committed
Ensure mod::cgi is added when needed
1 parent 7c23338 commit 6426552

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

manifests/vhost.pp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,6 +2336,24 @@
23362336
include apache::mod::authz_groupfile
23372337
}
23382338

2339+
if 'options' in $directory {
2340+
if !('-ExecCGI' in $directory['options']) {
2341+
if 'ExecCGI' in $directory['options'] {
2342+
case $apache::mpm_module {
2343+
'prefork': {
2344+
include apache::mod::cgi
2345+
}
2346+
'worker': {
2347+
include apache::mod::cgid
2348+
}
2349+
default: {
2350+
# do nothing
2351+
}
2352+
}
2353+
}
2354+
}
2355+
}
2356+
23392357
if 'dav' in $directory {
23402358
include apache::mod::dav
23412359
if $directory['dav'] == 'On' {

spec/defines/vhost_spec.rb

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,70 @@
22752275
it { is_expected.to compile }
22762276
it { is_expected.to contain_class('apache::mod::autoindex') }
22772277
end
2278+
2279+
context 'mod_cgi is included when requested by array' do
2280+
let :params do
2281+
{
2282+
'docroot' => '/var/www/foo',
2283+
'directories' => [
2284+
{
2285+
'options' => ['ExecCGI'],
2286+
},
2287+
]
2288+
2289+
}
2290+
end
2291+
2292+
it { is_expected.to compile }
2293+
if os_facts[:os]['family'] == 'Debian'
2294+
it { is_expected.not_to contain_class('apache::mod::cgi') }
2295+
it { is_expected.to contain_class('apache::mod::cgid') }
2296+
else
2297+
it { is_expected.to contain_class('apache::mod::cgi') }
2298+
it { is_expected.not_to contain_class('apache::mod::cgid') }
2299+
end
2300+
end
2301+
2302+
context 'mod_cgi is included when requested by string' do
2303+
let :params do
2304+
{
2305+
'docroot' => '/var/www/foo',
2306+
'directories' => [
2307+
{
2308+
'options' => 'Indexes ExecCGI',
2309+
},
2310+
]
2311+
2312+
}
2313+
end
2314+
2315+
it { is_expected.to compile }
2316+
if os_facts[:os]['family'] == 'Debian'
2317+
it { is_expected.not_to contain_class('apache::mod::cgi') }
2318+
it { is_expected.to contain_class('apache::mod::cgid') }
2319+
else
2320+
it { is_expected.to contain_class('apache::mod::cgi') }
2321+
it { is_expected.not_to contain_class('apache::mod::cgid') }
2322+
end
2323+
end
2324+
2325+
context 'mod_cgi is not included when unrequested' do
2326+
let :params do
2327+
{
2328+
'docroot' => '/var/www/foo',
2329+
'directories' => [
2330+
{
2331+
'options' => '+Indexes -ExecCGI',
2332+
},
2333+
]
2334+
2335+
}
2336+
end
2337+
2338+
it { is_expected.to compile }
2339+
it { is_expected.not_to contain_class('apache::mod::cgi') }
2340+
it { is_expected.not_to contain_class('apache::mod::cgid') }
2341+
end
22782342
end
22792343
end
22802344
end

0 commit comments

Comments
 (0)