Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensure mod::cgi is added when needed
  • Loading branch information
gcoxmoz committed Jun 26, 2025
commit bbf3d3277fc4b63c87c33530684cd2e323b04a8d
18 changes: 18 additions & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,24 @@
include apache::mod::authz_groupfile
}

if 'options' in $directory {
if !('-ExecCGI' in $directory['options']) {
if 'ExecCGI' in $directory['options'] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you combine these 2 statements?

Suggested change
if !('-ExecCGI' in $directory['options']) {
if 'ExecCGI' in $directory['options'] {
if !('-ExecCGI' in $directory['options']) and 'ExecCGI' in $directory['options'] {

And I forgot if this is valid or I'm confusing Python

Suggested change
if !('-ExecCGI' in $directory['options']) {
if 'ExecCGI' in $directory['options'] {
if '-ExecCGI' not in $directory['options'] and 'ExecCGI' in $directory['options'] {

case $apache::mpm_module {
'prefork': {
include apache::mod::cgi
}
'worker': {
include apache::mod::cgid
}
default: {
# do nothing
}
}
}
}
}

if 'dav' in $directory {
include apache::mod::dav
if $directory['dav'] == 'On' {
Expand Down
64 changes: 64 additions & 0 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,70 @@
it { is_expected.to compile }
it { is_expected.to contain_class('apache::mod::autoindex') }
end

context 'mod_cgi is included when requested by array' do
let :params do
{
'docroot' => '/var/www/foo',
'directories' => [
{
'options' => ['ExecCGI'],
},
]

}
end

it { is_expected.to compile }
if os_facts[:os]['family'] == 'Debian'
it { is_expected.not_to contain_class('apache::mod::cgi') }
it { is_expected.to contain_class('apache::mod::cgid') }
else
it { is_expected.to contain_class('apache::mod::cgi') }
it { is_expected.not_to contain_class('apache::mod::cgid') }
end
end

context 'mod_cgi is included when requested by string' do
let :params do
{
'docroot' => '/var/www/foo',
'directories' => [
{
'options' => 'Indexes ExecCGI',
},
]

}
end

it { is_expected.to compile }
if os_facts[:os]['family'] == 'Debian'
it { is_expected.not_to contain_class('apache::mod::cgi') }
it { is_expected.to contain_class('apache::mod::cgid') }
else
it { is_expected.to contain_class('apache::mod::cgi') }
it { is_expected.not_to contain_class('apache::mod::cgid') }
end
end

context 'mod_cgi is not included when unrequested' do
let :params do
{
'docroot' => '/var/www/foo',
'directories' => [
{
'options' => '+Indexes -ExecCGI',
},
]

}
end

it { is_expected.to compile }
it { is_expected.not_to contain_class('apache::mod::cgi') }
it { is_expected.not_to contain_class('apache::mod::cgid') }
end
end
end
end
Expand Down