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.
This commit is contained in:
parent
5bb76f5eca
commit
aea822c47a
1 changed files with 8 additions and 6 deletions
6
sysctl
6
sysctl
|
@ -158,11 +158,13 @@ def sysctl_check(current_step, **sysctl_args):
|
|||
# sysctl file exists and openable ?
|
||||
# TODO choose if prefered to use os.access() instead try/catch on open
|
||||
if current_step == 'before':
|
||||
if not os.access(sysctl_args['sysctl_file'], os.W_OK):
|
||||
try:
|
||||
f = open(sysctl_args['sysctl_file'])
|
||||
f = open(sysctl_args['sysctl_file'],'w')
|
||||
f.write('')
|
||||
f.close()
|
||||
except IOError, e:
|
||||
return 1, 'unable to open supplied sysctl.conf'
|
||||
return 1, 'unable to create supplied sysctl file (directory missing)'
|
||||
|
||||
# no smart checks at this step ?
|
||||
if sysctl_args['checks'] == 'none':
|
||||
|
|
Loading…
Reference in a new issue