Commit cb0711d4 by Alexander Popov

Fix the check against multiple options in config file

parent aaa3826a
...@@ -198,19 +198,21 @@ def check_config_file(fname): ...@@ -198,19 +198,21 @@ def check_config_file(fname):
print('[+] Checking "{}" against hardening preferences...'.format(fname)) print('[+] Checking "{}" against hardening preferences...'.format(fname))
for line in f.readlines(): for line in f.readlines():
line = line.strip() line = line.strip()
option = None
value = None
if opt_is_on.match(line): if opt_is_on.match(line):
config, value = line[7:].split('=', 1) option, value = line[7:].split('=', 1)
parsed_options[config] = value
elif opt_is_off.match(line): elif opt_is_off.match(line):
config, value = line[9:].split(' ', 1) option, value = line[9:].split(' ', 1)
if value != 'is not set': if value != 'is not set':
sys.exit('[!] BUG: bad disabled config option "{}"'.format(line)) sys.exit('[!] BUG: bad disabled config option "{}"'.format(line))
if config in parsed_options: if option in parsed_options:
sys.exit('[!] ERROR: config option "{}" exists multiple times'.format(line)) sys.exit('[!] ERROR: config option "{}" exists multiple times'.format(line))
parsed_options[config] = value if option is not None:
parsed_options[option] = value
check_state(parsed_options) check_state(parsed_options)
print_check_results() print_check_results()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment