From 594e27b0bc896a84017db02227e45e172186d1a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 28 Aug 2023 18:44:42 +0300 Subject: [PATCH] ukify: fail if the config file was not read Inspired by https://github.com/systemd/systemd/pull/28997. Noticed by Alvin Alvarado . --- src/ukify/ukify.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ukify/ukify.py b/src/ukify/ukify.py index 10a464bb1a3..b7e21dafed7 100755 --- a/src/ukify/ukify.py +++ b/src/ukify/ukify.py @@ -1413,7 +1413,10 @@ def apply_config(namespace, filename=None): # Do not make keys lowercase cp.optionxform = lambda option: option - cp.read(filename) + # The API is not great. + read = cp.read(filename) + if not read: + raise IOError(f'Failed to read {filename}') for section_name, section in cp.items(): idx = section_name.find(':') -- 2.47.3