We double checked the meaning of "w+" and it will open the file
read-write. Since the file is never read there's no real reason
to keep it that way so its OK to convert to `write_new`.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
for ccf in config_json['custom_config_files']:
if all(k in ccf for k in mandatory_keys):
file_path = os.path.join(custom_config_dir, os.path.basename(ccf['mount_path']))
- with open(file_path, 'w+', encoding='utf-8') as f:
- os.fchown(f.fileno(), uid, gid)
- os.fchmod(f.fileno(), 0o600)
+ with write_new(file_path, owner=(uid, gid), perms=0o600, encoding='utf-8') as f:
f.write(ccf['content'])