Skip to content

Commit 469a686

Browse files
Revert "session: do not delete on flush"
This reverts commit b654a56. Signed-off-by: Bill Roberts <bill.c.roberts+gh@gmail.com>
1 parent b654a56 commit 469a686

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/tpm2_session.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,14 @@ tool_rc tpm2_session_close(tpm2_session **s) {
361361
}
362362

363363
if ((*s)->internal.delete && path) {
364-
rc = tool_rc_success;
365-
goto out2;
364+
if (remove(path)) {
365+
LOG_ERR("File \"%s\" can't be deleted.", path);
366+
rc = tool_rc_general_error;
367+
goto out2;
368+
} else {
369+
rc = tool_rc_success;
370+
goto out2;
371+
}
366372
}
367373

368374
FILE *session_file = path ? fopen(path, "w+b") : NULL;

test/integration/tests/unseal.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,9 @@ tpm2 sessionconfig enc_session.ctx --enable-encrypt --disable-continuesession
156156
unsealed=`tpm2 unseal -c seal_key.ctx -p sealkeypass -S enc_session.ctx`
157157
test "$unsealed" == "$secret"
158158

159+
if [ -e enc_session.ctx ]; then
160+
echo "enc_session.ctx was not deleted.";
161+
exit 1
162+
fi
163+
159164
exit 0

0 commit comments

Comments
 (0)