Commit 0eaa936b by Michel Blanc

Removes exception is sysctl file is missing

When syscl file was missing, sysctl module was complaining about it and
bailing out.
This behaviour prevents usage of /etc/sysctl.d directory, present in
some distributions.
This patch accepts a missing sysctl.conf file so sysctl.d directory can
be used.
However, it will bail out if the destination directory doesn't exist.
parent 3f2fd22e
...@@ -158,12 +158,14 @@ def sysctl_check(current_step, **sysctl_args): ...@@ -158,12 +158,14 @@ def sysctl_check(current_step, **sysctl_args):
# sysctl file exists and openable ? # sysctl file exists and openable ?
# TODO choose if prefered to use os.access() instead try/catch on open # TODO choose if prefered to use os.access() instead try/catch on open
if current_step == 'before': if current_step == 'before':
try: if not os.access(sysctl_args['sysctl_file'], os.W_OK):
f = open(sysctl_args['sysctl_file']) try:
f.close() f = open(sysctl_args['sysctl_file'],'w')
except IOError, e: f.write('')
return 1, 'unable to open supplied sysctl.conf' f.close()
except IOError, e:
return 1, 'unable to create supplied sysctl file (directory missing)'
# no smart checks at this step ? # no smart checks at this step ?
if sysctl_args['checks'] == 'none': if sysctl_args['checks'] == 'none':
return 0, '' return 0, ''
......
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