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

This commit is contained in:
dw 2019-06-04 17:45:20 +01:00 committed by Sam Doran
parent 256d1a9947
commit 3fadf4a1cb
2 changed files with 3 additions and 1 deletions

View file

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

View file

@ -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)