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
+6 -2
View File
@@ -132,7 +132,7 @@ bool libimcv_init(bool is_imv)
if (lib)
{
/* did main program initialize libstrongswan? */
if (libstrongswan_ref == 0)
if (!ref_cur(&libstrongswan_ref))
{
ref_get(&libstrongswan_ref);
}
@@ -171,10 +171,12 @@ bool libimcv_init(bool is_imv)
lib->settings->add_fallback(lib->settings, "%s.plugins", "libimcv.plugins",
lib->ns);
if (libimcv_ref == 0)
if (!ref_cur(&libimcv_ref))
{
char *uri, *script;
libtpmtss_init();
/* initialize the PA-TNC attribute manager */
imcv_pa_tnc_attributes = pa_tnc_attr_manager_create();
imcv_pa_tnc_attributes->add_vendor(imcv_pa_tnc_attributes, PEN_IETF,
@@ -246,6 +248,8 @@ void libimcv_deinit(void)
DESTROY_IF(imcv_db);
DESTROY_IF(imcv_sessions);
DBG1(DBG_LIB, "libimcv terminated");
libtpmtss_deinit();
}
if (ref_put(&libstrongswan_ref))
{