[gnome-remote-desktop] tpm: Check for a module before attempting to initialize interface
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] tpm: Check for a module before attempting to initialize interface
- Date: Sun, 7 Aug 2022 09:09:45 +0000 (UTC)
commit 9682cf2e26e4b7f48f1ca32abe106ea72449e8b0
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Sun Aug 7 08:59:31 2022 +0200
tpm: Check for a module before attempting to initialize interface
The TPM2 tools work, but only if a TPM2 device is found. If no TPM2
device is found, they don't just fail, unless the daemon for the TPM2
device discovery is not installed.
Instead, they lead to a freeze in the thread of the program, where they
are called.
While this is an error in the TPM2 tools, people will run into this
issue.
So, prevent this issue by manually checking for a TPM2 device first.
If no TPM2 is found, just error out.
src/grd-tpm.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
---
diff --git a/src/grd-tpm.c b/src/grd-tpm.c
index ff88c607..7cce0bdc 100644
--- a/src/grd-tpm.c
+++ b/src/grd-tpm.c
@@ -48,6 +48,25 @@ struct _GrdTpm
G_DEFINE_TYPE (GrdTpm, grd_tpm, G_TYPE_OBJECT)
+static gboolean
+check_tpm_existence (GError **error)
+{
+ g_autoptr (GFile) tpm_dev = NULL;
+ g_autoptr (GFile) tpmrm_dev = NULL;
+
+ tpm_dev = g_file_new_for_path ("/dev/tpm0");
+ tpmrm_dev = g_file_new_for_path ("/dev/tpmrm0");
+ if (!g_file_query_exists (tpm_dev, NULL) ||
+ !g_file_query_exists (tpmrm_dev, NULL))
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+ "No TPM device found");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static gboolean
init_transmission_interface (GrdTpm *tpm,
GError **error)
@@ -727,6 +746,9 @@ grd_tpm_new (GrdTpmMode mode,
if (!(grd_get_debug_flags () & GRD_DEBUG_TPM))
g_setenv ("TSS2_LOGFILE", "/dev/null", TRUE);
+ if (!check_tpm_existence (error))
+ return NULL;
+
if (!init_transmission_interface (tpm, error))
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]