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

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