Fixing issue related to writing ini files

When the file is opened with rwa+ and the update file size is smaller than the original the ini file can become corrupt.  The issue was noticed when we had comments at the top of /etc/yum/pluginconf.d/rhnplugin.conf after using the rhn_register module the file became correct.

rwa+ also make no sense as the file is only written too and why would any appending need to happen?
This commit is contained in:
Greg 2017-02-26 01:14:45 -05:00 committed by Brian Coca
parent 9d95ea0832
commit 3506febbb9

View file

@ -66,7 +66,7 @@ class RegistrationBase(object):
cfg.set('main', 'enabled', 1)
else:
cfg.set('main', 'enabled', 0)
fd = open(plugin_conf, 'rwa+')
fd = open(plugin_conf, 'w+')
cfg.write(fd)
fd.close()