|
14 | 14 | end
|
15 | 15 | end
|
16 | 16 |
|
| 17 | +mysql_hardening_file = '/etc/mysql/conf.d/hardening.cnf' |
| 18 | + |
17 | 19 | # set OS-dependent filenames and paths
|
18 | 20 | case backend.check_os[:family]
|
19 |
| -when 'Ubuntu' |
| 21 | +when 'Ubuntu', 'Debian' |
20 | 22 | mysql_config_file = '/etc/mysql/my.cnf'
|
21 |
| - mysql_hardening_file = '/etc/mysql/conf.d/hardening.cnf' |
22 | 23 | mysql_config_path = '/etc/mysql/'
|
23 | 24 | mysql_data_path = '/var/lib/mysql/'
|
24 | 25 | mysql_log_path = '/var/log/'
|
| 26 | + mysql_log_file = 'mysql.log' |
| 27 | + mysql_log_group = 'adm' |
| 28 | + os[:release] == '14.04' ? mysql_log_dir_group = 'syslog' : mysql_log_dir_group = 'root' |
25 | 29 | service_name = 'mysql'
|
26 | 30 | when 'RedHat', 'Fedora'
|
27 | 31 | mysql_config_file = '/etc/my.cnf'
|
28 |
| - mysql_hardening_file = '/etc/hardening.cnf' |
29 | 32 | mysql_config_path = '/etc/'
|
30 | 33 | mysql_data_path = '/var/lib/mysql/'
|
31 | 34 | mysql_log_path = '/var/log/'
|
| 35 | + mysql_log_file = 'mysqld.log' |
| 36 | + mysql_log_group = 'mysql' |
| 37 | + mysql_log_dir_group = 'root' |
32 | 38 | service_name = 'mysqld'
|
33 | 39 | end
|
34 | 40 |
|
|
92 | 98 |
|
93 | 99 | # Req. 299 (nur eine instanz pro server)
|
94 | 100 | describe 'Req. 299: check for multiple instances' do
|
95 |
| - describe command('ps aux | grep mysqld | grep -v grep | wc -l') do |
| 101 | + describe command('ps aux | grep mysqld | egrep -v "grep|mysqld_safe|logger" | wc -l') do |
96 | 102 | its(:stdout) { should match(/^1$/) }
|
97 | 103 | end
|
98 | 104 | end
|
|
136 | 142 |
|
137 | 143 | # Req. 316 (skip-grant-tables)
|
138 | 144 | describe file(tmp_config_file) do
|
139 |
| - its(:content) { should match(/^\s*?skip-grant-tables/) } |
| 145 | + its(:content) { should_not match(/^\s*?skip-grant-tables/) } |
140 | 146 | end
|
141 | 147 |
|
142 | 148 | # Req. 320 (kein "allow-suspicious-udfs")
|
|
151 | 157 |
|
152 | 158 | describe file(mysql_data_path) do
|
153 | 159 | it { should be_directory }
|
154 |
| - end |
155 |
| - |
156 |
| - describe file(mysql_data_path) do |
157 | 160 | it { should be_owned_by 'mysql' }
|
158 | 161 | it { should be_grouped_into 'mysql' }
|
159 | 162 | end
|
160 | 163 |
|
161 | 164 | describe file("#{mysql_data_path}/ibdata1") do
|
162 | 165 | it { should be_owned_by 'mysql' }
|
163 | 166 | it { should be_grouped_into 'mysql' }
|
| 167 | + it { should_not be_readable.by('others') } |
164 | 168 | end
|
165 | 169 |
|
166 | 170 | describe file(mysql_log_path) do
|
167 | 171 | it { should be_directory }
|
168 | 172 | it { should be_owned_by 'root' }
|
169 |
| - it { should be_grouped_into 'root' } |
| 173 | + it { should be_grouped_into mysql_log_dir_group } |
170 | 174 | end
|
171 | 175 |
|
172 |
| - describe file("#{mysql_log_path}/mysql.log") do |
| 176 | + describe file("#{mysql_log_path}/#{mysql_log_file}") do |
173 | 177 | it { should be_owned_by 'mysql' }
|
174 |
| - it { should be_grouped_into 'adm' } |
| 178 | + it { should be_grouped_into mysql_log_group } |
| 179 | + it { should_not be_readable.by('others') } |
175 | 180 | end
|
176 | 181 |
|
177 | 182 | end
|
|
190 | 195 | describe file(mysql_config_file) do
|
191 | 196 | it { should be_owned_by 'mysql' }
|
192 | 197 | it { should be_grouped_into 'mysql' }
|
| 198 | + it { should_not be_readable.by('others') } |
| 199 | + end |
| 200 | + |
| 201 | + describe file(mysql_hardening_file) do |
| 202 | + it { should be_owned_by 'mysql' } |
| 203 | + it { should be_grouped_into 'root' } |
| 204 | + it { should_not be_readable.by('others') } |
193 | 205 | end
|
194 | 206 |
|
195 | 207 | end
|
0 commit comments