iPXE
|
Executable images. More...
Go to the source code of this file.
Data Structures | |
struct | image |
An executable image. More... | |
struct | image_type |
An executable image type. More... | |
struct | image_tag |
An image tag. More... | |
Macros | |
#define | IMAGE_REGISTERED 0x0001 |
Image is registered. More... | |
#define | IMAGE_TRUSTED 0x0002 |
Image is trusted. More... | |
#define | IMAGE_AUTO_UNREGISTER 0x0004 |
Image will be automatically unregistered after execution. More... | |
#define | IMAGE_HIDDEN 0x0008 |
Image will be hidden from enumeration. More... | |
#define | PROBE_MULTIBOOT 01 |
Multiboot image probe priority. More... | |
#define | PROBE_NORMAL 02 |
Normal image probe priority. More... | |
#define | PROBE_PXE 03 |
PXE image probe priority. More... | |
#define | IMAGE_TYPES __table ( struct image_type, "image_types" ) |
Executable image type table. More... | |
#define | __image_type(probe_order) __table_entry ( IMAGE_TYPES, probe_order ) |
An executable image type. More... | |
#define | IMAGE_TAGS __table ( struct image_tag, "image_tags" ) |
Image tag table. More... | |
#define | __image_tag __table_entry ( IMAGE_TAGS, 01 ) |
An image tag. More... | |
#define | for_each_image(image) list_for_each_entry ( (image), &images, list ) |
Iterate over all registered images. More... | |
#define | for_each_image_safe(image, tmp) list_for_each_entry_safe ( (image), (tmp), &images, list ) |
Iterate over all registered images, safe against deletion. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static struct image * | first_image (void) |
Retrieve first image. More... | |
struct image * | alloc_image (struct uri *uri) |
Allocate executable image. More... | |
int | image_set_uri (struct image *image, struct uri *uri) |
Set image URI. More... | |
int | image_set_name (struct image *image, const char *name) |
Set image name. More... | |
char * | image_strip_suffix (struct image *image) |
Strip dot suffix from image name, if present. More... | |
int | image_set_cmdline (struct image *image, const char *cmdline) |
Set image command line. More... | |
int | image_set_len (struct image *image, size_t len) |
Set image length. More... | |
int | image_set_data (struct image *image, userptr_t data, size_t len) |
Set image data. More... | |
int | register_image (struct image *image) |
Register executable image. More... | |
void | unregister_image (struct image *image) |
Unregister executable image. More... | |
struct image * | find_image (const char *name) |
Find image by name. More... | |
struct image * | find_image_tag (struct image_tag *tag) |
Find image by tag. More... | |
int | image_exec (struct image *image) |
Execute image. More... | |
int | image_replace (struct image *replacement) |
Set replacement image. More... | |
int | image_select (struct image *image) |
Select image for execution. More... | |
int | image_set_trust (int require_trusted, int permanent) |
Change image trust requirement. More... | |
struct image * | image_memory (const char *name, userptr_t data, size_t len) |
Create registered image from block of memory. More... | |
const char * | image_argument (struct image *image, const char *key) |
Find argument within image command line. More... | |
int | image_pixbuf (struct image *image, struct pixel_buffer **pixbuf) |
Create pixel buffer from image. More... | |
int | image_asn1 (struct image *image, size_t offset, struct asn1_cursor **cursor) |
Extract ASN.1 object from image. More... | |
int | image_extract (struct image *image, const char *name, struct image **extracted) |
Extract archive image. More... | |
int | image_extract_exec (struct image *image) |
Extract and execute image. More... | |
static struct image * | image_get (struct image *image) |
Increment reference count on an image. More... | |
static void | image_put (struct image *image) |
Decrement reference count on an image. More... | |
static void | image_clear_cmdline (struct image *image) |
Clear image command line. More... | |
static void | image_trust (struct image *image) |
Set image as trusted. More... | |
static void | image_untrust (struct image *image) |
Set image as untrusted. More... | |
static void | image_hide (struct image *image) |
Mark image as hidden. More... | |
static struct image * | image_tag (struct image *image, struct image_tag *tag) |
Tag image. More... | |
Variables | |
struct image | __attribute__ |
struct list_head | images |
List of registered images. More... | |
struct image_tag | current_image |
struct image_tag | selected_image |
Executable images.
Definition in file image.h.
#define IMAGE_AUTO_UNREGISTER 0x0004 |
#define IMAGE_HIDDEN 0x0008 |
#define PROBE_MULTIBOOT 01 |
#define PROBE_PXE 03 |
#define IMAGE_TYPES __table ( struct image_type, "image_types" ) |
#define __image_type | ( | probe_order | ) | __table_entry ( IMAGE_TYPES, probe_order ) |
struct image_tag current_image __image_tag __table_entry ( IMAGE_TAGS, 01 ) |
#define for_each_image | ( | image | ) | list_for_each_entry ( (image), &images, list ) |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
inlinestatic |
Retrieve first image.
image | Image, or NULL |
Definition at line 184 of file image.h.
References images, image::list, and list_first_entry.
Referenced by ipxe().
Allocate executable image.
uri | URI, or NULL |
image | Executable image |
Definition at line 103 of file image.c.
References free_image(), image_put(), image_set_uri(), NULL, rc, ref_init, image::refcnt, and zalloc().
Referenced by image_extract(), image_memory(), and imgdownload().
Set image URI.
image | Image |
uri | New image URI |
rc | Return status code |
Definition at line 132 of file image.c.
References basename(), image_set_name(), image::name, name, uri::opaque, uri::path, rc, image::uri, uri_get(), and uri_put().
Referenced by alloc_image(), and downloader_vredirect().
int image_set_name | ( | struct image * | image, |
const char * | name | ||
) |
Set image name.
image | Image |
name | New image name |
rc | Return status code |
Definition at line 160 of file image.c.
References ENOMEM, free, image::name, name, and strdup().
Referenced by cms_decrypt(), image_extract(), image_memory(), image_set_uri(), imgsingle_exec(), and register_image().
char* image_strip_suffix | ( | struct image * | image | ) |
Strip dot suffix from image name, if present.
image | Image |
sep | Position of old dot separator, or NULL |
Definition at line 181 of file image.c.
References image::name, NULL, and strrchr().
Referenced by cms_decrypt(), and image_extract().
int image_set_cmdline | ( | struct image * | image, |
const char * | cmdline | ||
) |
Set image command line.
image | Image |
cmdline | New image command line, or NULL |
rc | Return status code |
Definition at line 201 of file image.c.
References cmdline, image::cmdline, ENOMEM, free, NULL, and strdup().
Referenced by image_clear_cmdline(), image_extract_exec(), and imgsingle_exec().
Set image length.
image | Image |
len | Length of image data |
rc | Return status code |
Definition at line 220 of file image.c.
References image::data, ENOMEM, len, image::len, and urealloc().
Referenced by gzip_extract(), image_set_data(), and zlib_deflate().
Set image data.
image | Image |
data | Image data |
len | Length of image data |
rc | Return status code |
Definition at line 241 of file image.c.
References data, image::data, image_set_len(), len, memcpy_user(), and rc.
Referenced by image_memory().
int register_image | ( | struct image * | image | ) |
Register executable image.
image | Executable image |
rc | Return status code |
Definition at line 286 of file image.c.
References image::data, DBGC, image::flags, image_get(), image_probe(), IMAGE_REGISTERED, image_set_name(), images, image::len, image::list, list_add_tail, image::name, name, rc, snprintf(), image::type, and user_to_phys().
Referenced by asn1_okx(), cmdline_init(), cms_decrypt(), efi_cmdline_init(), efi_image_exec(), embedded_init(), image_exec(), image_extract(), image_memory(), imgdownload(), pixbuf_okx(), and test_init().
void unregister_image | ( | struct image * | image | ) |
Unregister executable image.
image | Executable image |
Definition at line 322 of file image.c.
References DBGC, image::flags, image_put(), IMAGE_REGISTERED, image::list, list_del, and image::name.
Referenced by asn1_okx(), bzimage_exec(), cert_exec(), cms_decrypt(), com32_exec_loop(), comboot_exec_loop(), console_exec(), efi_autoexec_load(), efi_image_exec(), gzip_okx(), image_exec(), image_extract(), image_extract_exec(), imgdecrypt_exec(), imgextract_exec(), imgfree_exec(), imgverify_exec(), pixbuf_okx(), and zlib_okx().
struct image* find_image | ( | const char * | name | ) |
Find image by name.
name | Image name |
image | Executable image, or NULL |
Definition at line 340 of file image.c.
References for_each_image, image::name, name, NULL, and strcmp().
Referenced by imgacquire(), and imgmulti_exec().
Find image by tag.
tag | Image tag |
image | Executable image, or NULL |
Definition at line 357 of file image.c.
References for_each_image, NULL, and tag.
Referenced by efi_file_open(), efi_image_exec(), imgsingle_exec(), and shim_exec().
int image_exec | ( | struct image * | image | ) |
Execute image.
image | Executable image |
rc | Return status code |
The image must already be registered. Note that executing an image may cause it to unregister itself. The caller must therefore assume that the image pointer becomes invalid.
Definition at line 378 of file image.c.
References assert(), churi(), current_image, cwuri, DBGC, EACCES_UNTRUSTED, ENOEXEC, image_type::exec, image::flags, IMAGE_AUTO_UNREGISTER, image_exec(), image_get(), image_put(), IMAGE_REGISTERED, image_tag(), IMAGE_TRUSTED, LOG_ERR, LOG_NOTICE, image::name, NULL, rc, register_image(), replacement, image::replacement, require_trusted_images, strerror(), syslog, image::type, unregister_image(), image::uri, uri_get(), and uri_put().
Referenced by image_exec(), image_extract_exec(), imgexec(), ipxe(), and uriboot().
int image_replace | ( | struct image * | replacement | ) |
Set replacement image.
replacement | Replacement image |
rc | Return status code |
The replacement image must already be registered, and must remain registered until the currently-executing image returns.
Definition at line 489 of file image.c.
References assert(), current_image, DBGC, ENOEXEC, ENOTTY, image_tag::image, image_get(), image_put(), IMAGE_REGISTERED, image::name, rc, replacement, image::replacement, and strerror().
Referenced by comboot_fetch_kernel(), and imgexec().
int image_select | ( | struct image * | image | ) |
Select image for execution.
image | Executable image |
rc | Return status code |
Definition at line 525 of file image.c.
References ENOEXEC, image_type::exec, image_tag(), selected_image, and image::type.
Referenced by embedded_init(), and imgselect().
int image_set_trust | ( | int | require_trusted, |
int | permanent | ||
) |
Change image trust requirement.
require_trusted | Require trusted images |
permanent | Make trust requirement permanent |
rc | Return status code |
Definition at line 544 of file image.c.
References EACCES_PERMANENT, require_trusted_images, and require_trusted_images_permanent.
Referenced by imgtrust_exec().
Create registered image from block of memory.
name | Name |
data | Image data |
len | Length |
image | Image, or NULL on error |
Definition at line 569 of file image.c.
References alloc_image(), data, ENOMEM, image_put(), image_set_data(), image_set_name(), len, name, NULL, rc, and register_image().
Referenced by gzip_okx(), imgmem(), initrd_init(), and zlib_okx().
const char* image_argument | ( | struct image * | image, |
const char * | key | ||
) |
Find argument within image command line.
image | Image |
key | Argument search key (including trailing delimiter) |
value | Argument value, or NULL if not found |
Definition at line 612 of file image.c.
References cmdline, image::cmdline, isspace(), key, next, NULL, strlen(), and strstr().
Referenced by bzimage_parse_cmdline(), and cpio_parse_cmdline().
int image_pixbuf | ( | struct image * | image, |
struct pixel_buffer ** | pixbuf | ||
) |
Create pixel buffer from image.
image | Image |
pixbuf | Pixel buffer to fill in |
rc | Return status code |
Definition at line 97 of file pixbuf.c.
References DBGC, ENOTSUP, image::name, image_type::pixbuf, rc, strerror(), and image::type.
Referenced by console_exec(), and pixbuf_okx().
int image_asn1 | ( | struct image * | image, |
size_t | offset, | ||
struct asn1_cursor ** | cursor | ||
) |
Extract ASN.1 object from image.
image | Image |
offset | Offset within image |
cursor | ASN.1 cursor to fill in |
next | Offset to next image, or negative error |
The caller is responsible for eventually calling free() on the allocated ASN.1 cursor.
Definition at line 1002 of file asn1.c.
References image_type::asn1, assert(), DBGC, ENOTSUP, len, image::name, next, offset, rc, strerror(), and image::type.
Referenced by asn1_okx(), cms_message(), and image_x509().
Extract archive image.
image | Image |
name | Extracted image name |
extracted | Extracted image to fill in |
rc | Return status code |
Definition at line 44 of file archive.c.
References alloc_image(), DBGC, ENOMEM, ENOTSUP, image_type::extract, image::flags, image_put(), image_set_name(), image_strip_suffix(), image_trust(), IMAGE_TRUSTED, image::name, name, rc, register_image(), strerror(), image::type, unregister_image(), and image::uri.
Referenced by gzip_okx(), image_extract_exec(), imgextract(), and zlib_okx().
int image_extract_exec | ( | struct image * | image | ) |
Extract and execute image.
image | Image |
rc | Return status code |
Definition at line 107 of file archive.c.
References image::cmdline, image::flags, IMAGE_AUTO_UNREGISTER, image_exec(), image_extract(), image_set_cmdline(), NULL, rc, and unregister_image().
Increment reference count on an image.
image | Image |
image | Image |
Definition at line 219 of file image.h.
References ref_get, and image::refcnt.
Referenced by bzimage_exec(), cms_decrypt(), create_downloader(), efi_file_open_image(), image_exec(), image_replace(), and register_image().
|
inlinestatic |
Decrement reference count on an image.
image | Image |
Definition at line 229 of file image.h.
References ref_put, and image::refcnt.
Referenced by alloc_image(), cmdline_init(), cms_decrypt(), downloader_free(), efi_cmdline_init(), efi_file_free(), free_image(), image_exec(), image_extract(), image_memory(), image_replace(), imgdownload(), and unregister_image().
|
inlinestatic |
Clear image command line.
image | Image |
Definition at line 238 of file image.h.
References image_set_cmdline(), and NULL.
|
inlinestatic |
Set image as trusted.
image | Image |
Definition at line 247 of file image.h.
References image::flags, and IMAGE_TRUSTED.
Referenced by cms_verify(), embedded_init(), and image_extract().
|
inlinestatic |
Set image as untrusted.
image | Image |
Definition at line 256 of file image.h.
References image::flags, and IMAGE_TRUSTED.
Referenced by cms_decrypt(), and cms_verify().
|
inlinestatic |
Mark image as hidden.
image | Image |
Definition at line 265 of file image.h.
References image::flags, and IMAGE_HIDDEN.
Referenced by shim().
Tag image.
image | Image |
tag | Image tag |
prev | Previous tagged image (if any) |
Definition at line 276 of file image.h.
References tag.
Referenced by image_exec(), image_select(), and shim().
struct image __attribute__ |
struct list_head images |
List of registered images.
Definition at line 57 of file image.c.
Referenced by first_image(), initrd_dump(), initrd_reshuffle(), initrd_squash_high(), initrd_swap(), and register_image().
struct image_tag current_image |
Referenced by goto_exec(), image_exec(), and image_replace().
struct image_tag selected_image |
Referenced by efi_file_open(), image_select(), imgsingle_exec(), and shim_exec().