Skip to content

Commit 57adf56

Browse files
committed
Harden config class
Prior to this commit the variables `dir` and `mysql::server::package_name` were passed to `exec` resources in such a way that could allow unsafe executions on the remote host. This commit fixes the above by properly parameterizing the arguments passed to each `exec` resource. Additionally the variables been sanitized with `shell_escape` for good measure.
1 parent 1469fbf commit 57adf56

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

manifests/server/config.pp

+8-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@
3939
if $managed_dirs {
4040
$managed_dirs.each | $entry | {
4141
$dir = $options['mysqld']["${entry}"]
42+
4243
if ( $dir and $dir != '/usr' and $dir != '/tmp' ) {
44+
$clean_dir = shell_escape($dir)
45+
$clean_package_name = shell_escape($mysql::server::package_name)
46+
4347
exec { "${entry}-managed_dir-mkdir":
44-
command => "/bin/mkdir -p ${dir}",
45-
unless => "/usr/bin/dpkg -s ${mysql::server::package_name}",
48+
command => ['/bin/mkdir', '-p', $clean_dir],
49+
unless => ['/usr/bin/dpkg', '-s', $clean_package_name],
4650
notify => Exec["${entry}-managed_dir-chmod"],
4751
}
52+
4853
exec { "${entry}-managed_dir-chmod":
49-
command => "/bin/chmod 777 ${dir}",
54+
command => ['/bin/chmod', '777', $clean_dir],
5055
refreshonly => true,
5156
}
5257
}

0 commit comments

Comments
 (0)