libtpmtss: Initialize library from all users

Previously, only the tpm plugin initialized the library, so in order
to use a TPM 2.0 (a required TCTI library is loaded via init), it was
necessary to load it even if none of its actual features were used.
This commit is contained in:
Tobias Brunner
2021-08-20 17:10:11 +02:00
parent 6c1210dcf6
commit 5126e7c0fc
5 changed files with 45 additions and 18 deletions
+7 -2
View File
@@ -137,7 +137,6 @@ static void exit_aikgen(err_t message, ...)
fprintf(stderr, "aikgen error: %s\n", m);
status = -1;
}
library_deinit();
exit(status);
}
@@ -194,17 +193,23 @@ int main(int argc, char *argv[])
chunk_t aik_blob;
hasher_t *hasher;
atexit(library_deinit);
if (!library_init(NULL, "aikgen"))
{
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
}
atexit(library_deinit);
if (lib->integrity &&
!lib->integrity->check_file(lib->integrity, "aikgen", argv[0]))
{
fprintf(stderr, "integrity check of aikgen failed\n");
exit(SS_RC_DAEMON_INTEGRITY);
}
if (!libtpmtss_init())
{
fprintf(stderr, "libtpmtss initialization failed\n");
exit(SS_RC_INITIALIZATION_FAILED);
}
atexit(libtpmtss_deinit);
/* initialize global variables */
options = options_create();