summaryrefslogtreecommitdiffstats
path: root/src/ukify
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-07-31 21:35:02 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2023-08-01 22:11:15 +0200
commitd713104abef503708451a8efd88a7f5a78418f91 (patch)
treef7e9dc1cec1544cf129a4ae44534498b64fbfb38 /src/ukify
parenttest: skip tests earlier when we do not have enough privileges (diff)
downloadsystemd-d713104abef503708451a8efd88a7f5a78418f91.tar.xz
systemd-d713104abef503708451a8efd88a7f5a78418f91.zip
ukify: Only run systemd-measure after adding all sections
We were running systemd-measure before adding the sbat section, let's fix that. Also make sure we only pass --linux to systemd-measure once instead of twice.
Diffstat (limited to 'src/ukify')
-rwxr-xr-xsrc/ukify/ukify.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/ukify/ukify.py b/src/ukify/ukify.py
index 49317fbf78..8324942f99 100755
--- a/src/ukify/ukify.py
+++ b/src/ukify/ukify.py
@@ -792,23 +792,29 @@ def make_uki(opts):
for section in opts.sections:
uki.add_section(section)
- # PCR measurement and signing
-
- call_systemd_measure(uki, linux, opts=opts)
-
- # UKI or addon creation - addons don't use the stub so we add SBAT manually
-
if linux is not None:
# Merge the .sbat sections from stub, kernel and parameter, so that revocation can be done on either.
uki.add_section(Section.create('.sbat', merge_sbat([opts.stub, linux], opts.sbat), measure=True))
- uki.add_section(Section.create('.linux', linux, measure=True))
else:
+ # Addons don't use the stub so we add SBAT manually
if not opts.sbat:
opts.sbat = ["""sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
uki,1,UKI,uki,1,https://www.freedesktop.org/software/systemd/man/systemd-stub.html
"""]
uki.add_section(Section.create('.sbat', merge_sbat([], opts.sbat), measure=False))
+ # PCR measurement and signing
+
+ # We pass in the contents for .linux separately because we need them to do the measurement but can't add
+ # the section yet because we want .linux to be the last section. Make sure any other sections are added
+ # before this function is called.
+ call_systemd_measure(uki, linux, opts=opts)
+
+ # UKI creation
+
+ if linux is not None:
+ uki.add_section(Section.create('.linux', linux, measure=True))
+
if sign_args_present:
unsigned = tempfile.NamedTemporaryFile(prefix='uki')
unsigned_output = unsigned.name