iPXE
shim_cmd.c File Reference

EFI shim command. More...

#include <getopt.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/efi/efi_image.h>
#include <usr/imgmgmt.h>
#include <usr/shimmgmt.h>

Go to the source code of this file.

Data Structures

struct  shim_options
 "shim" options More...

Macros

#define shim_dummy   1

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static int shim_exec (int argc, char **argv)
 The "shim" command.
 COMMAND (shim, shim_exec)
 Shim commands.

Variables

static struct option_descriptor shim_opts []
 "shim" option list
static struct command_descriptor shim_cmd
 "shim" command descriptor

Detailed Description

EFI shim command.

Definition in file shim_cmd.c.

Macro Definition Documentation

◆ shim_dummy

#define shim_dummy   1

Definition at line 44 of file shim_cmd.c.

Referenced by shim_exec().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ shim_exec()

int shim_exec ( int argc,
char ** argv )
static

The "shim" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 86 of file shim_cmd.c.

86 {
87 struct shim_options opts;
88 struct image *image = NULL;
89 struct image *kernel;
90 char *name_uri;
91 int download;
92 int rc;
93
94 /* Do absolutely nothing if this is a non-EFI platform */
95 if ( shim_dummy ) {
96 rc = 0;
97 goto err_dummy;
98 }
99
100 /* Parse options */
101 if ( ( rc = parse_options ( argc, argv, &shim_cmd, &opts ) ) != 0 )
102 goto err_parse;
103
104 /* Decide whether or not to download images */
106 download = ( ! ( kernel && efi_can_load ( kernel ) ) );
107
108 /* Parse name/URI string */
109 name_uri = argv[optind];
110
111 /* Acquire image, if applicable */
112 if ( download && name_uri &&
113 ( ( rc = imgacquire ( name_uri, opts.timeout, opts.quiet,
114 &image ) ) != 0 ) ) {
115 goto err_image;
116 }
117
118 /* (Un)register as shim */
119 if ( ( rc = shim ( image, opts.require_loader, opts.allow_pxe,
120 opts.allow_sbat ) ) != 0 )
121 goto err_shim;
122
123 err_shim:
124 err_image:
125 err_parse:
126 err_dummy:
127 return rc;
128}
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static union @024010030001061367220137227263210031030210157031 opts
"cert<xxx>" option list
static int efi_can_load(struct image *image)
Check if EFI image can be loaded directly.
Definition efi_image.h:23
uint32_t kernel
Kernel version (numeric).
Definition ena.h:9
int optind
Current option index.
Definition getopt.c:52
struct image * find_image_tag(struct image_tag *tag)
Find image by tag.
Definition image.c:425
struct image_tag selected_image
int imgacquire(const char *name_uri, unsigned long timeout, int quiet, struct image **image)
Acquire an image.
Definition imgmgmt.c:148
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition parseopt.c:485
#define shim_dummy
Definition shim_cmd.c:44
static struct command_descriptor shim_cmd
"shim" command descriptor
Definition shim_cmd.c:76
int shim(struct image *image, int require_loader, int allow_pxe, int allow_sbat)
Set shim image.
Definition shimmgmt.c:46
An executable image.
Definition image.h:24
"shim" options
Definition shim_cmd.c:48

References efi_can_load(), find_image_tag(), imgacquire(), kernel, NULL, optind, opts, parse_options(), rc, selected_image, shim(), shim_cmd, and shim_dummy.

Referenced by COMMAND().

◆ COMMAND()

COMMAND ( shim ,
shim_exec  )

Shim commands.

References shim(), and shim_exec().

Variable Documentation

◆ shim_opts

struct option_descriptor shim_opts[]
static
Initial value:
= {
OPTION_DESC ( "timeout", 't', required_argument,
OPTION_DESC ( "quiet", 'q', no_argument,
struct shim_options, quiet, parse_flag ),
OPTION_DESC ( "require-loader", 'l', no_argument,
struct shim_options, require_loader, parse_flag ),
OPTION_DESC ( "allow-pxe", 'p', no_argument,
struct shim_options, allow_pxe, parse_flag ),
OPTION_DESC ( "allow-sbat", 's', no_argument,
struct shim_options, allow_sbat, parse_flag ),
}
void timeout(int)
@ required_argument
Option requires an argument.
Definition getopt.h:19
@ no_argument
Option does not take an argument.
Definition getopt.h:17
int parse_flag(char *text __unused, int *flag)
Parse flag.
Definition parseopt.c:227
int parse_timeout(char *text, unsigned long *value)
Parse timeout value (in ms).
Definition parseopt.c:115
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition parseopt.h:68

"shim" option list

Definition at line 62 of file shim_cmd.c.

62 {
63 OPTION_DESC ( "timeout", 't', required_argument,
65 OPTION_DESC ( "quiet", 'q', no_argument,
66 struct shim_options, quiet, parse_flag ),
67 OPTION_DESC ( "require-loader", 'l', no_argument,
68 struct shim_options, require_loader, parse_flag ),
69 OPTION_DESC ( "allow-pxe", 'p', no_argument,
70 struct shim_options, allow_pxe, parse_flag ),
71 OPTION_DESC ( "allow-sbat", 's', no_argument,
72 struct shim_options, allow_sbat, parse_flag ),
73};

◆ shim_cmd

struct command_descriptor shim_cmd
static
Initial value:
=
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition parseopt.h:109
static struct option_descriptor shim_opts[]
"shim" option list
Definition shim_cmd.c:62

"shim" command descriptor

Definition at line 76 of file shim_cmd.c.

Referenced by PROVIDE_REQUIRING_SYMBOL(), and shim_exec().