Fix the check against multiple options in config file
authorAlexander Popov <alex.popov@linux.com>
Fri, 20 Jul 2018 16:00:20 +0000 (19:00 +0300)
committerAlexander Popov <alex.popov@linux.com>
Fri, 20 Jul 2018 16:00:20 +0000 (19:00 +0300)
kconfig-hardened-check.py

index a239836563ddf9d677f14732c0dd5a4a00677c01..949c19a56fbb3e2fed62484bdfca007006b2a017 100755 (executable)
@@ -198,19 +198,21 @@ def check_config_file(fname):
         print('[+] Checking "{}" against hardening preferences...'.format(fname))
         for line in f.readlines():
             line = line.strip()
+            option = None
+            value = None
 
             if opt_is_on.match(line):
-                config, value = line[7:].split('=', 1)
-                parsed_options[config] = value
+                option, value = line[7:].split('=', 1)
             elif opt_is_off.match(line):
-                config, value = line[9:].split(' ', 1)
+                option, value = line[9:].split(' ', 1)
                 if value != 'is not set':
                     sys.exit('[!] BUG: bad disabled config option "{}"'.format(line))
 
-                if config in parsed_options:
-                    sys.exit('[!] ERROR: config option "{}" exists multiple times'.format(line))
+            if option in parsed_options:
+                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)
         print_check_results()