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

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