1*4882a593SmuzhiyunFrom d90367471779c240e002e62edfb6b31fc85b4908 Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Javier Martinez Canillas <javierm@redhat.com>
3*4882a593SmuzhiyunDate: Tue, 2 Feb 2021 19:59:48 +0100
4*4882a593SmuzhiyunSubject: [PATCH] kern/lockdown: Set a variable if the GRUB is locked down
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunIt may be useful for scripts to determine whether the GRUB is locked
7*4882a593Smuzhiyundown or not. Add the lockdown variable which is set to "y" when the GRUB
8*4882a593Smuzhiyunis locked down.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunSuggested-by: Dimitri John Ledkov <xnox@ubuntu.com>
11*4882a593SmuzhiyunSigned-off-by: Javier Martinez Canillas <javierm@redhat.com>
12*4882a593SmuzhiyunReviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
13*4882a593SmuzhiyunSigned-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
14*4882a593Smuzhiyun---
15*4882a593Smuzhiyun docs/grub.texi            | 3 +++
16*4882a593Smuzhiyun grub-core/kern/lockdown.c | 4 ++++
17*4882a593Smuzhiyun 2 files changed, 7 insertions(+)
18*4882a593Smuzhiyun
19*4882a593Smuzhiyundiff --git a/docs/grub.texi b/docs/grub.texi
20*4882a593Smuzhiyunindex a25459f..bdbb329 100644
21*4882a593Smuzhiyun--- a/docs/grub.texi
22*4882a593Smuzhiyun+++ b/docs/grub.texi
23*4882a593Smuzhiyun@@ -5803,6 +5803,9 @@ The GRUB can be locked down when booted on a secure boot environment, for exampl
24*4882a593Smuzhiyun if the UEFI secure boot is enabled. On a locked down configuration, the GRUB will
25*4882a593Smuzhiyun be restricted and some operations/commands cannot be executed.
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun+The @samp{lockdown} variable is set to @samp{y} when the GRUB is locked down.
28*4882a593Smuzhiyun+Otherwise it does not exit.
29*4882a593Smuzhiyun+
30*4882a593Smuzhiyun @node Platform limitations
31*4882a593Smuzhiyun @chapter Platform limitations
32*4882a593Smuzhiyun
33*4882a593Smuzhiyundiff --git a/grub-core/kern/lockdown.c b/grub-core/kern/lockdown.c
34*4882a593Smuzhiyunindex 1e56c0b..0bc70fd 100644
35*4882a593Smuzhiyun--- a/grub-core/kern/lockdown.c
36*4882a593Smuzhiyun+++ b/grub-core/kern/lockdown.c
37*4882a593Smuzhiyun@@ -18,6 +18,7 @@
38*4882a593Smuzhiyun  */
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun #include <grub/dl.h>
41*4882a593Smuzhiyun+#include <grub/env.h>
42*4882a593Smuzhiyun #include <grub/file.h>
43*4882a593Smuzhiyun #include <grub/lockdown.h>
44*4882a593Smuzhiyun #include <grub/verify.h>
45*4882a593Smuzhiyun@@ -71,6 +72,9 @@ grub_lockdown (void)
46*4882a593Smuzhiyun   lockdown = GRUB_LOCKDOWN_ENABLED;
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun   grub_verifier_register (&lockdown_verifier);
49*4882a593Smuzhiyun+
50*4882a593Smuzhiyun+  grub_env_set ("lockdown", "y");
51*4882a593Smuzhiyun+  grub_env_export ("lockdown");
52*4882a593Smuzhiyun }
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun int
55*4882a593Smuzhiyun--
56*4882a593Smuzhiyun2.14.2
57*4882a593Smuzhiyun
58