Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 38342d6

Browse files
committedMar 3, 2023
feat(dracut.sh): allow to pass all UEFI options as dracut arguments
This patch adds three dracut arguments that can currently only be set via configuration files: `--uefi-secureboot-cert`, `--uefi-secureboot-key` and `--uefi-secureboot-engine`.
1 parent aca5120 commit 38342d6

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed
 

‎dracut.sh

+29
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,14 @@ Creates initial ramdisk images for preloading modules
271271
--uefi-splash-image [FILE]
272272
Use [FILE] as a splash image when creating an UEFI
273273
executable. Requires bitmap (.bmp) image format.
274+
--uefi-secureboot-cert [FILE], --uefi-secureboot-key [FILE]
275+
Specifies a certificate and corresponding key, which are
276+
used to sign the created UEFI executable.
277+
Requires both certificate and key need to be specified
278+
and sbsign to be installed.
279+
--uefi-secureboot-engine [ENGINE]
280+
Specifies an OpenSSL engine to use when signing the
281+
created UEFI executable. E.g. "pkcs11".
274282
--kernel-image [FILE] Location of the kernel image.
275283
--regenerate-all Regenerate all initramfs images at the default location
276284
for the kernel versions found on the system.
@@ -462,6 +470,9 @@ rearrange_params() {
462470
--long no-uefi \
463471
--long uefi-stub: \
464472
--long uefi-splash-image: \
473+
--long uefi-secureboot-cert: \
474+
--long uefi-secureboot-key: \
475+
--long uefi-secureboot-engine: \
465476
--long kernel-image: \
466477
--long no-hostonly-i18n \
467478
--long hostonly-i18n \
@@ -835,6 +846,21 @@ while :; do
835846
PARMS_TO_STORE+=" '$2'"
836847
shift
837848
;;
849+
--uefi-secureboot-cert)
850+
uefi_secureboot_cert_l="$2"
851+
PARMS_TO_STORE+=" '$2'"
852+
shift
853+
;;
854+
--uefi-secureboot-key)
855+
uefi_secureboot_key_l="$2"
856+
PARMS_TO_STORE+=" '$2'"
857+
shift
858+
;;
859+
--uefi-secureboot-engine)
860+
uefi_secureboot_engine_l="$2"
861+
PARMS_TO_STORE+=" '$2'"
862+
shift
863+
;;
838864
--kernel-image)
839865
kernel_image_l="$2"
840866
PARMS_TO_STORE+=" '$2'"
@@ -1078,6 +1104,9 @@ drivers_dir="${drivers_dir%"${drivers_dir##*[!/]}"}"
10781104
[[ $uefi_l ]] && uefi=$uefi_l
10791105
[[ $uefi_stub_l ]] && uefi_stub="$uefi_stub_l"
10801106
[[ $uefi_splash_image_l ]] && uefi_splash_image="$uefi_splash_image_l"
1107+
[[ $uefi_secureboot_cert_l ]] && uefi_secureboot_cert="$uefi_secureboot_cert_l"
1108+
[[ $uefi_secureboot_key_l ]] && uefi_secureboot_key="$uefi_secureboot_key_l"
1109+
[[ $uefi_secureboot_engine_l ]] && uefi_secureboot_engine="$uefi_secureboot_engine_l"
10811110
[[ $kernel_image_l ]] && kernel_image="$kernel_image_l"
10821111
[[ $machine_id_l ]] && machine_id="$machine_id_l"
10831112

‎man/dracut.8.asc

+10
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,16 @@ and no /etc/cmdline/*.conf will be generated into the initramfs.
595595
Specifies the UEFI stub loader's splash image. Requires bitmap (**.bmp**)
596596
image format.
597597
598+
**--uefi-secureboot-cert _<file>_, --uefi-secureboot-key _<file>_**::
599+
Specifies a certificate and corresponding key, which are used to sign the
600+
created UEFI executable.
601+
Requires both certificate and key need to be specified and _sbsign_ to be
602+
installed.
603+
604+
**--uefi-secureboot-engine _engine_**::
605+
Specifies an OpenSSL engine to use when signing the created UEFI executable.
606+
E.g. "pkcs11".
607+
598608
**--kernel-image _<file>_**::
599609
Specifies the kernel image, which to include in the UEFI executable. The
600610
default is _/lib/modules/<KERNEL-VERSION>/vmlinuz_ or

‎man/dracut.conf.5.asc

+3-2
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,9 @@ Logging levels:
294294
Requires both certificate and key need to be specified and _sbsign_ to be
295295
installed.
296296

297-
*uefi_secureboot_engine=*"_parameter_"::
298-
Specifies an engine to use when signing the created UEFI executable. E.g. "pkcs11"
297+
*uefi_secureboot_engine=*"_engine_"::
298+
Specifies an OpenSSL engine to use when signing the created UEFI executable.
299+
E.g. "pkcs11".
299300

300301
*kernel_image=*"_<file>_"::
301302
Specifies the kernel image, which to include in the UEFI executable. The

‎shell-completion/bash/dracut

+12-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ __contains_word() {
2222
return 1
2323
}
2424

25+
__get_openssl_engines() {
26+
# sbsign uses installed OpenSSL engines
27+
openssl engine 2> /dev/null | awk -F[\(\)] '{print $2}'
28+
}
29+
2530
_dracut() {
2631
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD - 1]}
2732
local -A OPTS=(
@@ -46,7 +51,8 @@ _dracut() {
4651
--kernel-cmdline --sshkey --persistent-policy --install-optional
4752
--loginstall --uefi-stub --kernel-image --squash-compressor
4853
--sysroot --hostonly-mode --hostonly-nics --include --logfile
49-
--uefi-splash-image
54+
--uefi-splash-image --uefi-secureboot-cert --uefi-secureboot-key
55+
--uefi-secureboot-engine
5056
'
5157
)
5258

@@ -58,7 +64,8 @@ _dracut() {
5864
compopt -o filenames
5965
;;
6066
-c | --conf | --sshkey | --add-fstab | --add-device | -I | \
61-
--install | --install-optional | --uefi-splash-image)
67+
--install | --install-optional | --uefi-splash-image | \
68+
--uefi-secureboot-cert | --uefi-secureboot-key)
6269
comps=$(compgen -f -- "$cur")
6370
compopt -o filenames
6471
;;
@@ -86,6 +93,9 @@ _dracut() {
8693
printf -- "%s " *
8794
)
8895
;;
96+
--uefi-secureboot-engine)
97+
comps="$(__get_openssl_engines)"
98+
;;
8999
*)
90100
return 0
91101
;;

0 commit comments

Comments
 (0)
Please sign in to comment.