1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fixes #6482 Check sysctl file path and catch read exceptions

This commit is contained in:
James Tanner 2014-03-14 11:16:45 -04:00
parent b2350d8aaf
commit 9d6518de5a

View file

@ -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)