summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--dp.c43
-rw-r--r--include/dp.h14
-rw-r--r--shim.c33
-rw-r--r--shim.h1
5 files changed, 61 insertions, 36 deletions
diff --git a/Makefile b/Makefile
index 3d9fd614..833bcd2a 100644
--- a/Makefile
+++ b/Makefile
@@ -38,10 +38,10 @@ CFLAGS += -DENABLE_SHIM_CERT
else
TARGETS += $(MMNAME) $(FBNAME)
endif
-OBJS = shim.o globals.o mok.o netboot.o cert.o replacements.o tpm.o version.o errlog.o sbat.o sbat_data.o sbat_var.o pe.o pe-relocate.o httpboot.o csv.o load-options.o
+OBJS = shim.o globals.o mok.o netboot.o cert.o dp.o replacements.o tpm.o version.o errlog.o sbat.o sbat_data.o sbat_var.o pe.o pe-relocate.o httpboot.o csv.o load-options.o
KEYS = shim_cert.h ocsp.* ca.* shim.crt shim.csr shim.p12 shim.pem shim.key shim.cer
-ORIG_SOURCES = shim.c globals.c mok.c netboot.c replacements.c tpm.c errlog.c sbat.c pe.c pe-relocate.c httpboot.c shim.h version.h $(wildcard include/*.h) cert.S sbat_var.S
-MOK_OBJS = MokManager.o PasswordCrypt.o crypt_blowfish.o errlog.o sbat_data.o globals.o
+ORIG_SOURCES = shim.c globals.c mok.c netboot.c dp.c replacements.c tpm.c errlog.c sbat.c pe.c pe-relocate.c httpboot.c shim.h version.h $(wildcard include/*.h) cert.S sbat_var.S
+MOK_OBJS = MokManager.o PasswordCrypt.o crypt_blowfish.o errlog.o sbat_data.o globals.o dp.o
ORIG_MOK_SOURCES = MokManager.c PasswordCrypt.c crypt_blowfish.c shim.h $(wildcard include/*.h)
FALLBACK_OBJS = fallback.o tpm.o errlog.o sbat_data.o globals.o
ORIG_FALLBACK_SRCS = fallback.c
diff --git a/dp.c b/dp.c
new file mode 100644
index 00000000..3fc46f8d
--- /dev/null
+++ b/dp.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+/*
+ * dp.c - device path helpers
+ * Copyright Peter Jones <pjones@redhat.com>
+ */
+
+#include "shim.h"
+
+int
+is_removable_media_path(EFI_LOADED_IMAGE *li)
+{
+ unsigned int pathlen = 0;
+ CHAR16 *bootpath = NULL;
+ int ret = 0;
+
+ bootpath = DevicePathToStr(li->FilePath);
+
+ /* Check the beginning of the string and the end, to avoid
+ * caring about which arch this is. */
+ /* I really don't know why, but sometimes bootpath gives us
+ * L"\\EFI\\BOOT\\/BOOTX64.EFI". So just handle that here...
+ */
+ if (StrnCaseCmp(bootpath, L"\\EFI\\BOOT\\BOOT", 14) &&
+ StrnCaseCmp(bootpath, L"\\EFI\\BOOT\\/BOOT", 15) &&
+ StrnCaseCmp(bootpath, L"EFI\\BOOT\\BOOT", 13) &&
+ StrnCaseCmp(bootpath, L"EFI\\BOOT\\/BOOT", 14))
+ goto error;
+
+ pathlen = StrLen(bootpath);
+ if (pathlen < 5 || StrCaseCmp(bootpath + pathlen - 4, L".EFI"))
+ goto error;
+
+ ret = 1;
+
+error:
+ if (bootpath)
+ FreePool(bootpath);
+
+ return ret;
+}
+
+
+// vim:fenc=utf-8:tw=75:noet
diff --git a/include/dp.h b/include/dp.h
new file mode 100644
index 00000000..884c1460
--- /dev/null
+++ b/include/dp.h
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+/*
+ * dp.h - device path helper functions
+ * Copyright Peter Jones <pjones@redhat.com>
+ */
+
+#ifndef DP_H_
+#define DP_H_
+
+int
+is_removable_media_path(EFI_LOADED_IMAGE *li);
+
+#endif /* !DP_H_ */
+// vim:fenc=utf-8:tw=75:noet
diff --git a/shim.c b/shim.c
index bb54993f..c447c3d3 100644
--- a/shim.c
+++ b/shim.c
@@ -779,39 +779,6 @@ verify_buffer (char *data, int datasize,
}
static int
-is_removable_media_path(EFI_LOADED_IMAGE *li)
-{
- unsigned int pathlen = 0;
- CHAR16 *bootpath = NULL;
- int ret = 0;
-
- bootpath = DevicePathToStr(li->FilePath);
-
- /* Check the beginning of the string and the end, to avoid
- * caring about which arch this is. */
- /* I really don't know why, but sometimes bootpath gives us
- * L"\\EFI\\BOOT\\/BOOTX64.EFI". So just handle that here...
- */
- if (StrnCaseCmp(bootpath, L"\\EFI\\BOOT\\BOOT", 14) &&
- StrnCaseCmp(bootpath, L"\\EFI\\BOOT\\/BOOT", 15) &&
- StrnCaseCmp(bootpath, L"EFI\\BOOT\\BOOT", 13) &&
- StrnCaseCmp(bootpath, L"EFI\\BOOT\\/BOOT", 14))
- goto error;
-
- pathlen = StrLen(bootpath);
- if (pathlen < 5 || StrCaseCmp(bootpath + pathlen - 4, L".EFI"))
- goto error;
-
- ret = 1;
-
-error:
- if (bootpath)
- FreePool(bootpath);
-
- return ret;
-}
-
-static int
should_use_fallback(EFI_HANDLE image_handle)
{
EFI_LOADED_IMAGE *li;
diff --git a/shim.h b/shim.h
index 5791a031..c0d8aa95 100644
--- a/shim.h
+++ b/shim.h
@@ -163,6 +163,7 @@
#include "include/configtable.h"
#include "include/console.h"
#include "include/crypt_blowfish.h"
+#include "include/dp.h"
#include "include/efiauthenticated.h"
#include "include/errors.h"
#include "include/execute.h"