Fix file descriptor leak in lineinfile module. (#57328)
This commit is contained in:
parent
256d1a9947
commit
3fadf4a1cb
2 changed files with 3 additions and 1 deletions
2
changelogs/fragments/57327-fix-file-descriptor-leak.yaml
Normal file
2
changelogs/fragments/57327-fix-file-descriptor-leak.yaml
Normal file
|
@ -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…
Reference in a new issue