Close leaking file descriptors (#622)
Close leaking file descriptors (#622)

* Close file descriptor in finally branch

Close the temporary file's file descriptor in the finally branch where
we already remove its associated file. This avoid file descriptor leaks
in case of an exception.

* Close leaking file descriptor of temp. file

Fix a leaking file descriptor of a temporary file opened using mkstemp().
The file itself is already being deleted.

$ sudo ls -l /proc/193311/fd
total 0
[...]
lrwx------. 1 root root 64 Apr 10 17:06 3 -> 'anon_inode:[eventfd]'
lrwx------. 1 root root 64 Apr 10 17:06 4 -> /var/lib/keylime/secure/tmpap5ng_mv
lrwx------. 1 root root 64 Apr 10 17:06 5 -> '/var/lib/keylime/secure/tmp5q5i1sr2 (deleted)'
[...]

This patch now close file descriptor '5'.

Signed-off-by: Stefan Berger <5c96973112e540fb909b13997fcd087e5bfbee96@linux.ibm.com>

mit-ll/python-keylime,mit-ll/python-keylime,mit-ll/python-keylime,mit-ll/python-keylime