]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
EFI stub: add LoaderImageIdentifier if non-existant
authorДамјан Георгиевски <gdamjan@gmail.com>
Mon, 15 Jan 2018 16:59:33 +0000 (17:59 +0100)
committerДамјан Георгиевски <gdamjan@gmail.com>
Mon, 15 Jan 2018 16:59:33 +0000 (17:59 +0100)
when an image with the stub is booted directly from UEFI, bootctl status
shows this:
```
Current Loader:
      Product: n/a
          ESP: /dev/disk/by-partuuid/b0a0807d-0592-40e9-adac-3bb724e9e305
         File: └─n/a
```

After this change, the stub reports the image itself:
```
Current Loader:
      Product: n/a
          ESP: /dev/disk/by-partuuid/b0a0807d-0592-40e9-adac-3bb724e9e305
         File: └─/EFI/Secure/secure-boot-4.14.8+.efi
```

src/boot/efi/stub.c

index e917019c0c569e56ec6938eabcb4b2cacf2e08ae..8066c2b8b588d991514b291fef1d49759f389cca 100644 (file)
@@ -104,6 +104,13 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
         if (disk_get_part_uuid(loaded_image->DeviceHandle, uuid) == EFI_SUCCESS)
                 efivar_set(L"LoaderDevicePartUUID", uuid, FALSE);
 
+        /* if LoaderImageIdentifier is not set, assume the image with this stub was loaded directly from UEFI */
+        if (efivar_get_raw(&global_guid, L"LoaderImageIdentifier", &b, &size) != EFI_SUCCESS) {
+                CHAR16 *loaded_image_path = DevicePathToStr(loaded_image->FilePath);
+                efivar_set(L"LoaderImageIdentifier", loaded_image_path, FALSE);
+                FreePool(loaded_image_path);
+        }
+
         if (szs[3] > 0)
                 graphics_splash((UINT8 *)((UINTN)loaded_image->ImageBase + addrs[3]), szs[3], NULL);