Skip to content

Commit 4190789

Browse files
committed
(maint) Codebase Hardening
Changes made to ensure that no malformed commands are passed through to the system.
1 parent 4d85082 commit 4190789

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

manifests/custom_config.pp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,10 @@
115115
require => Anchor['::apache::modules_set_up'],
116116
}
117117

118+
$remove_command = ['/bin/rm', shell_escape(join([$confdir, $_filename], '/'))]
118119
exec { "remove ${name} if invalid":
119-
command => "/bin/rm ${confdir}/${_filename}",
120-
unless => $verify_command,
120+
command => $remove_command,
121+
unless => [$verify_command],
121122
subscribe => File["apache_${name}"],
122123
refreshonly => true,
123124
}

manifests/init.pp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,9 @@
635635
path => '/bin:/sbin:/usr/bin:/usr/sbin',
636636
}
637637

638+
$confd_command = ['mkdir', $confd_dir]
638639
exec { "mkdir ${confd_dir}":
640+
command => $confd_command,
639641
creates => $confd_dir,
640642
require => Package['httpd'],
641643
}
@@ -660,7 +662,9 @@
660662
}
661663

662664
if ! defined(File[$mod_dir]) {
665+
$mod_command = ['mkdir', $mod_dir]
663666
exec { "mkdir ${mod_dir}":
667+
command => $mod_command,
664668
creates => $mod_dir,
665669
require => Package['httpd'],
666670
}
@@ -678,7 +682,9 @@
678682

679683
if $mod_enable_dir and ! defined(File[$mod_enable_dir]) {
680684
$mod_load_dir = $mod_enable_dir
685+
$mod_enable_command = ['mkdir', $mod_enable_dir]
681686
exec { "mkdir ${mod_enable_dir}":
687+
command => $mod_enable_command,
682688
creates => $mod_enable_dir,
683689
require => Package['httpd'],
684690
}
@@ -694,7 +700,9 @@
694700
}
695701

696702
if ! defined(File[$vhost_dir]) {
703+
$vhost_command = ['mkdir', $vhost_dir]
697704
exec { "mkdir ${vhost_dir}":
705+
command => $vhost_command,
698706
creates => $vhost_dir,
699707
require => Package['httpd'],
700708
}
@@ -709,7 +717,9 @@
709717

710718
if $vhost_enable_dir and ! defined(File[$vhost_enable_dir]) and $manage_vhost_enable_dir {
711719
$vhost_load_dir = $vhost_enable_dir
720+
$vhost_load_command = ['mkdir', $vhost_load_dir]
712721
exec { "mkdir ${vhost_load_dir}":
722+
command => $vhost_load_command,
713723
creates => $vhost_load_dir,
714724
require => Package['httpd'],
715725
}

manifests/mpm/disable_mpm_event.pp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
# @summary disable Apache-Module event
22
class apache::mpm::disable_mpm_event {
3+
$event_command = ['/usr/sbin/a2dismod', 'event']
4+
$event_onlyif = ['/usr/bin/test', '-e', shell_escape(join([$apache::mod_enable_dir, 'event.load'],'/'))]
35
exec { '/usr/sbin/a2dismod event':
4-
onlyif => "/usr/bin/test -e ${apache::mod_enable_dir}/event.load",
6+
command => $event_command,
7+
onlyif => $event_onlyif,
58
require => Package['httpd'],
69
before => Class['apache::service'],
710
}
11+
12+
$event_load_command = ['/bin/rm', shell_escape(join([$apache::mod_enable_dir, 'event_event.load'],'/'))]
13+
$event_load_onlyif = ['/usr/bin/test', '-e', shell_escape(join([$apache::mod_enable_dir, 'event_event.load'],'/'))]
814
exec { 'remove distribution event load file':
9-
command => "/bin/rm ${apache::mod_enable_dir}/mpm_event.load",
10-
onlyif => "/usr/bin/test -e ${apache::mod_enable_dir}/mpm_event.load",
15+
command => $event_load_command,
16+
onlyif => $event_load_onlyif,
1117
require => Package['httpd'],
1218
before => Class['apache::service'],
1319
}
20+
21+
$event_conf_command = ['/bin/rm', shell_escape(join([$apache::mod_enable_dir, 'event_event.conf'],'/'))]
22+
$event_conf_onlyif = ['/usr/bin/test', '-e', shell_escape(join([$apache::mod_enable_dir, 'event_event.conf'],'/'))]
1423
exec { 'remove distribution event conf file':
15-
command => "/bin/rm ${apache::mod_enable_dir}/mpm_event.conf",
16-
onlyif => "/usr/bin/test -e ${apache::mod_enable_dir}/mpm_event.conf",
24+
command => $event_conf_command,
25+
onlyif => $event_conf_onlyif,
1726
require => Package['httpd'],
1827
before => Class['apache::service'],
1928
}

manifests/mpm/disable_mpm_prefork.pp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# @summary disable Apache-Module prefork
22
class apache::mpm::disable_mpm_prefork {
3+
$prefork_command = ['/usr/sbin/a2dismod', 'prefork']
4+
$prefork_onlyif = ['/usr/bin/test', '-e', shell_escape(join([$apache::mod_enable_dir, 'prefork.load'],'/'))]
35
exec { '/usr/sbin/a2dismod prefork':
4-
onlyif => "/usr/bin/test -e ${apache::mod_enable_dir}/prefork.load",
6+
command => $prefork_command,
7+
onlyif => $prefork_onlyif,
58
require => Package['httpd'],
69
before => Class['apache::service'],
710
}

manifests/mpm/disable_mpm_worker.pp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# @summary disable Apache-Module worker
22
class apache::mpm::disable_mpm_worker {
3+
$worker_command = ['/usr/sbin/a2dismod', 'worker']
4+
$worker_onlyif = ['/usr/bin/test', '-e', shell_escape(join([$apache::mod_enable_dir, 'worker.load'],'/'))]
35
exec { '/usr/sbin/a2dismod worker':
4-
onlyif => "/usr/bin/test -e ${apache::mod_enable_dir}/worker.load",
6+
command => $worker_command,
7+
onlyif => $worker_onlyif,
58
require => Package['httpd'],
69
before => Class['apache::service'],
710
}

0 commit comments

Comments
 (0)