Index: firmware/stub/tpm_lite_stub.c |
diff --git a/firmware/stub/tpm_lite_stub.c b/firmware/stub/tpm_lite_stub.c |
index 0dabb8f1a49c70a537959860a92570f4dccf6e15..2211064363a257eb69b96dac678028d61fc1e2e2 100644 |
--- a/firmware/stub/tpm_lite_stub.c |
+++ b/firmware/stub/tpm_lite_stub.c |
@@ -15,6 +15,7 @@ |
#include <fcntl.h> |
#include <stdarg.h> |
#include <stdio.h> |
+#include <stdlib.h> |
#include <string.h> |
#include <sys/time.h> |
#include <sys/types.h> |
@@ -111,12 +112,19 @@ void TlclCloseDevice(void) { |
void TlclOpenDevice(void) { |
+ char* device_path; |
+ |
if (tpm_fd >= 0) |
return; /* Already open */ |
- tpm_fd = open(TPM_DEVICE_PATH, O_RDWR); |
+ device_path = getenv("TPM_DEVICE_PATH"); |
+ if (device_path == NULL) { |
+ device_path = TPM_DEVICE_PATH; |
+ } |
+ |
+ tpm_fd = open(device_path, O_RDWR); |
if (tpm_fd < 0) { |
- error("cannot open TPM device %s: %s\n", TPM_DEVICE_PATH, strerror(errno)); |
+ error("cannot open TPM device %s: %s\n", device_path, strerror(errno)); |
} |
} |