aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2023-05-16 13:00:13 +0100
committerMichael Brown <mcb30@ipxe.org>2023-05-17 15:51:32 +0100
commitbacfb468216ad6a139e63510cb28d4044dd121de (patch)
tree023b4bbfb3dae347ffadc2d3ddf48e2b3bab481f
parentfdf09d852d7905815559d919aab22b6483a8ea2b (diff)
downloadipxe-bacfb468216ad6a139e63510cb28d4044dd121de.tar.gz
WIP - shim crutch
-rw-r--r--src/hci/commands/shim_cmd.c15
-rw-r--r--src/image/efi_image.c5
-rw-r--r--src/include/ipxe/efi/efi_image.h1
-rw-r--r--src/include/usr/shimmgmt.h2
-rw-r--r--src/usr/shimmgmt.c10
5 files changed, 28 insertions, 5 deletions
diff --git a/src/hci/commands/shim_cmd.c b/src/hci/commands/shim_cmd.c
index 9adce2293..54ed2b292 100644
--- a/src/hci/commands/shim_cmd.c
+++ b/src/hci/commands/shim_cmd.c
@@ -42,6 +42,8 @@ struct shim_options {
int always;
/** Download timeout */
unsigned long timeout;
+ /** Crutch image name or URI */
+ char *crutch;
};
/** "shim" option list */
@@ -50,6 +52,8 @@ static struct option_descriptor shim_opts[] = {
struct shim_options, always, parse_flag ),
OPTION_DESC ( "timeout", 't', required_argument,
struct shim_options, timeout, parse_timeout ),
+ OPTION_DESC ( "crutch", 'c', required_argument,
+ struct shim_options, crutch, parse_string ),
};
/** "shim" command descriptor */
@@ -66,6 +70,7 @@ static struct command_descriptor shim_cmd =
static int shim_exec ( int argc, char **argv ) {
struct shim_options opts;
struct image *image = NULL;
+ struct image *crutch = NULL;
struct image *kernel;
char *name_uri;
int download;
@@ -89,11 +94,19 @@ static int shim_exec ( int argc, char **argv ) {
goto err_image;
}
+ /* Acquire crutch image, if applicable */
+ if ( download && opts.crutch &&
+ ( ( rc = imgacquire ( opts.crutch, opts.timeout,
+ &crutch ) ) != 0 ) ) {
+ goto err_crutch;
+ }
+
/* (Un)register as shim */
- if ( ( rc = shim ( image ) ) != 0 )
+ if ( ( rc = shim ( image, crutch ) ) != 0 )
goto err_shim;
err_shim:
+ err_crutch:
err_image:
err_parse:
return rc;
diff --git a/src/image/efi_image.c b/src/image/efi_image.c
index 7649d8f36..42a724ee0 100644
--- a/src/image/efi_image.c
+++ b/src/image/efi_image.c
@@ -61,6 +61,11 @@ struct image_tag efi_shim __image_tag = {
.name = "SHIM",
};
+/** EIF shim crutch image */
+struct image_tag efi_shim_crutch __image_tag = {
+ .name = "SHIMCRUTCH",
+};
+
/**
* Create device path for image
*
diff --git a/src/include/ipxe/efi/efi_image.h b/src/include/ipxe/efi/efi_image.h
index 23a6e0fd8..c9766b924 100644
--- a/src/include/ipxe/efi/efi_image.h
+++ b/src/include/ipxe/efi/efi_image.h
@@ -12,6 +12,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/image.h>
extern struct image_tag efi_shim __image_tag;
+extern struct image_tag efi_shim_crutch __image_tag;
extern struct image_type efi_image_type[] __image_type ( PROBE_NORMAL );
diff --git a/src/include/usr/shimmgmt.h b/src/include/usr/shimmgmt.h
index aef768186..5458e8f39 100644
--- a/src/include/usr/shimmgmt.h
+++ b/src/include/usr/shimmgmt.h
@@ -11,6 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/image.h>
-extern int shim ( struct image *image );
+extern int shim ( struct image *image, struct image *crutch );
#endif /* _USR_SHIMMGMT_H */
diff --git a/src/usr/shimmgmt.c b/src/usr/shimmgmt.c
index 6b2ca85c1..4a5966deb 100644
--- a/src/usr/shimmgmt.c
+++ b/src/usr/shimmgmt.c
@@ -37,16 +37,20 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
* Set shim image
*
* @v image Shim image, or NULL to clear shim
+ * @v crutch Shim crutch image, or NULL to clear crutch
* @ret rc Return status code
*/
-int shim ( struct image *image ) {
+int shim ( struct image *image, struct image *crutch ) {
- /* Record (or clear) shim image */
+ /* Record (or clear) shim and crutch images */
image_tag ( image, &efi_shim );
+ image_tag ( crutch, &efi_shim_crutch );
- /* Avoid including image in constructed initrd */
+ /* Avoid including images in constructed initrd */
if ( image )
image_hide ( image );
+ if ( crutch )
+ image_hide ( crutch );
return 0;
}