Fixes #6482 Check sysctl file path and catch read exceptions

reviewable/pr18780/r1
James Tanner 11 years ago
parent 0c70cc123e
commit 59fb47ae9a

@ -235,7 +235,16 @@ class SysctlModule(object):
# Get the token value from the sysctl file
def read_sysctl_file(self):
lines = open(self.sysctl_file, "r").readlines()
lines = []
if os.path.isfile(self.sysctl_file):
try:
f = open(self.sysctl_file, "r")
lines = f.readlines()
f.close()
except IOError, e:
self.module.fail_json(msg="Failed to open %s: %s" % (self.sysctl_file, str(e)))
for line in lines:
line = line.strip()
self.file_lines.append(line)

Loading…
Cancel
Save