Blame SOURCES/0003-Let-MokManager-follow-a-MokTimeout-var-for-timeout-l.patch

d1e1c8
From 74718677945b1ab825130b317c63f5002876e772 Mon Sep 17 00:00:00 2001
d1e1c8
From: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
d1e1c8
Date: Thu, 5 Jul 2018 11:28:12 -0400
d1e1c8
Subject: [PATCH 03/62] Let MokManager follow a MokTimeout var for timeout
d1e1c8
 length for the prompt
d1e1c8
d1e1c8
This timeout can have the values [-1,0..0x7fff]; where -1 means "no timeout",
d1e1c8
with MokManager going directly to the menu, and is capped to 0x7fff to avoid
d1e1c8
unecessary long timeouts. The default remains 10, which will be used whenever
d1e1c8
the MokTimeout variable isn't set.
d1e1c8
d1e1c8
Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
d1e1c8
Upstream-commit-id: 93708c11083
d1e1c8
---
d1e1c8
 MokManager.c | 23 ++++++++++++++++++++++-
d1e1c8
 1 file changed, 22 insertions(+), 1 deletion(-)
d1e1c8
d1e1c8
diff --git a/MokManager.c b/MokManager.c
d1e1c8
index 7e40a38f1d1..0767e4a6cde 100644
d1e1c8
--- a/MokManager.c
d1e1c8
+++ b/MokManager.c
d1e1c8
@@ -40,6 +40,10 @@ typedef struct {
d1e1c8
 	CHAR16 Password[SB_PASSWORD_LEN];
d1e1c8
 } __attribute__ ((packed)) MokDBvar;
d1e1c8
 
d1e1c8
+typedef struct {
d1e1c8
+	INT32 Timeout;
d1e1c8
+} __attribute__ ((packed)) MokTimeoutvar;
d1e1c8
+
d1e1c8
 static EFI_STATUS get_sha1sum(void *Data, int DataSize, UINT8 * hash)
d1e1c8
 {
d1e1c8
 	EFI_STATUS efi_status;
d1e1c8
@@ -2041,7 +2045,24 @@ static int draw_countdown()
d1e1c8
 	UINTN cols, rows;
d1e1c8
 	CHAR16 *title[2];
d1e1c8
 	CHAR16 *message = L"Press any key to perform MOK management";
d1e1c8
-	int timeout = 10, wait = 10000000;
d1e1c8
+	void *MokTimeout = NULL;
d1e1c8
+	MokTimeoutvar *var;
d1e1c8
+	UINTN MokTimeoutSize = 0;
d1e1c8
+	int timeout, wait = 10000000;
d1e1c8
+
d1e1c8
+	efi_status = get_variable(L"MokTimeout", (UINT8 **) &MokTimeout,
d1e1c8
+				  &MokTimeoutSize, SHIM_LOCK_GUID);
d1e1c8
+	if (EFI_ERROR(efi_status)) {
d1e1c8
+		timeout = 10;
d1e1c8
+	} else {
d1e1c8
+		var = MokTimeout;
d1e1c8
+		timeout = (int)var->Timeout;
d1e1c8
+		FreePool(MokTimeout);
d1e1c8
+		LibDeleteVariable(L"MokTimeout", &SHIM_LOCK_GUID);
d1e1c8
+	}
d1e1c8
+
d1e1c8
+	if (timeout < 0)
d1e1c8
+		return timeout;
d1e1c8
 
d1e1c8
 	console_save_and_set_mode(&SavedMode);
d1e1c8
 
d1e1c8
-- 
d1e1c8
2.26.2
d1e1c8