Fix file descriptor leak in lineinfile module. (#57328)

pull/57168/head
dw 5 years ago committed by Sam Doran
parent 256d1a9947
commit 3fadf4a1cb

@ -0,0 +1,2 @@
bugfixes:
- lineinfile - fix a race / file descriptor leak when writing the file (https://github.com/ansible/ansible/issues/57327)

@ -215,7 +215,7 @@ from ansible.module_utils._text import to_bytes, to_native
def write_changes(module, b_lines, dest):
tmpfd, tmpfile = tempfile.mkstemp()
with open(tmpfile, 'wb') as f:
with os.fdopen(tmpfd, 'wb') as f:
f.writelines(b_lines)
validate = module.params.get('validate', None)

Loading…
Cancel
Save