summaryrefslogtreecommitdiff
path: root/src/ukify
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-12-20 10:20:35 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-12-20 10:39:10 +0100
commit33bdec184f08d955979484d63bb60fba3942adca (patch)
tree68c8d3e3e7be1b4c828b9c396e88fdfa6e44497a /src/ukify
parent57e7af551edafa8ad840a26c28184bc6339e09ad (diff)
downloadsystemd-33bdec184f08d955979484d63bb60fba3942adca.tar.gz
ukify: catch error when loading foreign pe file
The autodetection code is supposed to throw ValueError when it cannot figure out the version so that we fall back to the next method. With the patch: Kernel version not specified, starting autodetection 😖. Real-Mode Kernel Header magic not found + readelf --notes vmlinuz/arm64/vmlinuz-6.0.9-300.fc37.aarch64 readelf: vmlinuz/arm64/vmlinuz-6.0.9-300.fc37.aarch64: Error: Not an ELF file - it has the wrong magic bytes at the start Found uname version: 6.0.9-300.fc37.aarch64
Diffstat (limited to 'src/ukify')
-rwxr-xr-xsrc/ukify/ukify.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ukify/ukify.py b/src/ukify/ukify.py
index e9e5d13d13..cd27f92a97 100755
--- a/src/ukify/ukify.py
+++ b/src/ukify/ukify.py
@@ -161,7 +161,10 @@ class Uname:
]
print('+', shell_join(cmd))
- notes = subprocess.check_output(cmd, text=True)
+ try:
+ notes = subprocess.check_output(cmd, stderr=subprocess.PIPE, text=True)
+ except subprocess.CalledProcessError as e:
+ raise ValueError(e.stderr.strip()) from e
if not (m := re.search(cls.NOTES_PATTERN, notes, re.MULTILINE)):
raise ValueError('Cannot find Linux version note')