Handle sysctl.conf files that use ';' for comments (#20576)

'#' and ';' are both valid comment chars for sysctl.conf files
according to the 'man sysctl.conf':

  "Lines which begin with a # or ; are considered comments and ignored."

Fixes #20569
This commit is contained in:
Adrian Likins 2017-02-15 13:37:09 -05:00 committed by GitHub
commit 106439e470

View file

@ -307,7 +307,7 @@ class SysctlModule(object):
self.file_lines.append(line) self.file_lines.append(line)
# don't split empty lines or comments # don't split empty lines or comments
if not line or line.startswith("#"): if not line or line.startswith(("#", ";")):
continue continue
k, v = line.split('=',1) k, v = line.split('=',1)
@ -320,7 +320,7 @@ class SysctlModule(object):
checked = [] checked = []
self.fixed_lines = [] self.fixed_lines = []
for line in self.file_lines: for line in self.file_lines:
if not line.strip() or line.strip().startswith("#"): if not line.strip() or line.strip().startswith(("#", ";")):
self.fixed_lines.append(line) self.fixed_lines.append(line)
continue continue
tmpline = line.strip() tmpline = line.strip()