]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmulatorPkg/RedfishPlatformCredentialLib: Check EFI_SECURE_BOOT_MODE_NAME
authorAbner Chang <abner.chang@hpe.com>
Fri, 4 Mar 2022 08:45:05 +0000 (16:45 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 16 Mar 2022 08:58:43 +0000 (08:58 +0000)
https://bugzilla.tianocore.org/show_bug.cgi?id=3858

Check EFI_SECURE_BOOT_MODE_NAME before setting the flags to
prohibit acquiring Redfish service credential and using Redfish
service.

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
EmulatorPkg/Library/RedfishPlatformCredentialLib/RedfishPlatformCredentialLib.c

index eaf9c56450e11127981d1aa21e476a71c6b2fefb..a0233a984d622e9839da5240a6ef1364f1931a34 100644 (file)
@@ -165,6 +165,9 @@ LibStopRedfishService (
   IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE  ServiceStopType\r
   )\r
 {\r
+  EFI_STATUS  Status;\r
+  UINT8       *SecureBootVar;\r
+\r
   if (ServiceStopType >= ServiceStopTypeMax) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -177,8 +180,18 @@ LibStopRedfishService (
     if (!PcdGetBool (PcdRedfishServieStopIfSecureBootDisabled)) {\r
       return EFI_UNSUPPORTED;\r
     } else {\r
-      mStopRedfishService = TRUE;\r
-      DEBUG ((DEBUG_INFO, "EFI Redfish service is stopped due to SecureBoot is disabled!!\n"));\r
+      //\r
+      // Check Secure Boot status and lock Redfish service if Secure Boot is disabled.\r
+      //\r
+      Status = GetVariable2 (EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid, (VOID **)&SecureBootVar, NULL);\r
+      if (EFI_ERROR (Status) || (*SecureBootVar != SECURE_BOOT_MODE_ENABLE)) {\r
+        //\r
+        // Secure Boot is disabled\r
+        //\r
+        mSecureBootDisabled = TRUE;\r
+        mStopRedfishService = TRUE;\r
+        DEBUG ((DEBUG_INFO, "EFI Redfish service is stopped due to SecureBoot is disabled!!\n"));\r
+      }\r
     }\r
   } else if (ServiceStopType == ServiceStopTypeExitBootService) {\r
     //\r
@@ -224,18 +237,5 @@ LibCredentialEndOfDxeNotify (
   IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
-  UINT8       *SecureBootVar;\r
-\r
-  //\r
-  // Check Secure Boot status and lock Redfish service if Secure Boot is disabled.\r
-  //\r
-  Status = GetVariable2 (EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid, (VOID **)&SecureBootVar, NULL);\r
-  if (EFI_ERROR (Status) || (*SecureBootVar != SECURE_BOOT_MODE_ENABLE)) {\r
-    //\r
-    // Secure Boot is disabled\r
-    //\r
-    mSecureBootDisabled = TRUE;\r
-    LibStopRedfishService (This, ServiceStopTypeSecureBootDisabled);\r
-  }\r
+  LibStopRedfishService (This, ServiceStopTypeSecureBootDisabled);\r
 }\r