return r;
}
-int dlopen_many_sym_or_warn_sentinel(void **dlp, const char *filename, int log_level, ...) {
+int dlopen_verbose(void **dlp, const char *filename) {
int r;
+ assert(dlp);
+
if (*dlp)
return 0; /* Already loaded */
}
log_debug("Loaded shared library '%s' via dlopen().", filename);
+ *dlp = TAKE_PTR(dl);
+ return 1;
+}
+
+int dlopen_many_sym_or_warn_sentinel(void **dlp, const char *filename, int log_level, ...) {
+ int r;
+
+ assert(dlp);
+
+ if (*dlp)
+ return 0; /* Already loaded */
+
+ _cleanup_(dlclosep) void *dl = NULL;
+ r = dlopen_verbose(&dl, filename);
+ if (r < 0)
+ return r;
va_list ap;
va_start(ap, log_level);
safe_dlclose(*dlp);
}
+int dlopen_verbose(void **dlp, const char *filename);
int dlsym_many_or_warn_sentinel(void *dl, int log_level, ...) _sentinel_;
int dlopen_many_sym_or_warn_sentinel(void **dlp, const char *filename, int log_level, ...) _sentinel_;
static void *libtss2_esys_dl = NULL;
static void *libtss2_rc_dl = NULL;
static void *libtss2_mu_dl = NULL;
+static void *libtss2_tcti_device_dl = NULL;
static DLSYM_PROTOTYPE(Esys_Create) = NULL;
static DLSYM_PROTOTYPE(Esys_CreateLoaded) = NULL;
DLSYM_ARG(Tss2_MU_UINT32_Marshal));
}
+static int dlopen_tpm2_tcti_device(void) {
+ /* The "device" TCTI is the most relevant one, let's also load it explicitly on dlopen_tpm2(), even
+ * if we don't resolve any symbols here. */
+
+ ELF_NOTE_DLOPEN("tpm",
+ "Support for TPM",
+ ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
+ "libtss2-tcti-device.so.0");
+
+ return dlopen_verbose(
+ &libtss2_tcti_device_dl,
+ "libtss2-tcti-device.so.0");
+}
+
#endif
int dlopen_tpm2(void) {
if (r < 0)
return r;
+ r = dlopen_tpm2_tcti_device();
+ if (r < 0)
+ return r;
+
return 0;
#else
return -EOPNOTSUPP;