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

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