Skip to content

Commit cdaa839

Browse files
committed
Harden service class
Prior to this commit the variable `mysqlsocket` was passed to the `exec` resource 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 the `command` and `unless` parameters of the `exec` resource. The variable is also wrapped with a `shell_escape` for good measure.
1 parent 1469fbf commit cdaa839

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

manifests/server/service.pp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@
5252
$mysqlsocket = $options['mysqld']['socket']
5353
}
5454

55+
$test_command = ['test', '-S', shell_escape($mysqlsocket)]
5556
if $service_ensure != 'stopped' {
5657
exec { 'wait_for_mysql_socket_to_open':
57-
command => "test -S ${mysqlsocket}",
58-
unless => "test -S ${mysqlsocket}",
58+
command => $test_command,
59+
unless => [$test_command],
5960
tries => '3',
6061
try_sleep => '10',
6162
require => Service['mysqld'],

0 commit comments

Comments
 (0)