irtimmer/tpm2-pk11

Old log file will be overwirtten at the beginning of each session

Closed this issue · 1 comments

tpm2-pk11/src/pk11.c

Lines 242 to 251 in 7c6aa34

CK_RV C_Initialize(CK_VOID_PTR pInitArgs) {
print_log(VERBOSE, "C_Initialize");
char configfile_path[256];
snprintf(configfile_path, sizeof(configfile_path), "%s/" TPM2_PK11_CONFIG_DIR "/" TPM2_PK11_CONFIG_FILE, getenv("HOME"));
if (config_load(configfile_path, &pk11_config) < 0)
return CKR_GENERAL_ERROR;
log_init(pk11_config.log_file, pk11_config.log_level);
return CKR_OK;
}

tpm2-pk11/src/log.c

Lines 30 to 40 in 31d45ce

void log_init(char* filename, int level) {
log_level = level;
if (filename != NULL) {
if (strcmp(filename, "stdout") == 0)
log_stream = stdout;
else if (strcmp(filename, "stderr") == 0)
log_stream = stderr;
else
log_stream = fopen(filename, "w");
}
}

It seemd that we shoud call fopen(filename, "a"); to add new lines.

Issue have been fixed with commit 12c3061