image-info: ignore lines with only whitespace characters in fstab

image-info could produce a weird fstab error with an empty list as a
member, when analysing images not built using osbuild. Ensure that any
lines in fstab with only whitespace characters are skipped during image
analysis.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
Tomas Hozza 2021-08-02 16:32:01 +02:00 committed by Ondřej Budai
parent 53109945ef
commit 972515ad84

View file

@ -555,7 +555,6 @@ def read_fstab(tree):
An example return value:
[
[],
[
"UUID=6d066eb4-e4c1-4472-91f9-d167097f48d1",
"/",
@ -569,7 +568,7 @@ def read_fstab(tree):
result = []
with contextlib.suppress(FileNotFoundError):
with open(f"{tree}/etc/fstab") as f:
result = sorted([line.split() for line in f if line and not line.startswith("#")])
result = sorted([line.split() for line in f if line.strip() and not line.startswith("#")])
return result