From cef65bf8a7b1fb9544af49956b2f5f8f50c3aa5b Mon Sep 17 00:00:00 2001 From: Gerlando Falauto Date: Fri, 24 Feb 2023 15:46:57 +0100 Subject: [PATCH] [wip] add flatcar,ubuntu and handle missing CONFIG_MODULE_SIG_HASH --- probe_builder/builder/distro/base_builder.py | 6 +++++- probe_builder/builder/distro/flatcar.py | 3 +++ probe_builder/builder/distro/ubuntu.py | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/probe_builder/builder/distro/base_builder.py b/probe_builder/builder/distro/base_builder.py index 84f1d8e..689ac48 100644 --- a/probe_builder/builder/distro/base_builder.py +++ b/probe_builder/builder/distro/base_builder.py @@ -64,11 +64,15 @@ def md5sum(path): @staticmethod def config_module_sig_hash(path): + # Look up the default hashing algorithm for module signing from within the config file + # Notes: + # 1. If not present, use empty string (no signing) + # 2. Remove the quotes with open(path, 'r') as f: config_string = '[DEFAULT]\n' + f.read() config = configparser.ConfigParser() config.read_string(config_string) - return config['DEFAULT']['CONFIG_MODULE_SIG_HASH'].replace('"','') + return config['DEFAULT'].get('CONFIG_MODULE_SIG_HASH','').replace('"','') def unpack_kernels(self, workspace, distro, kernels): raise NotImplementedError diff --git a/probe_builder/builder/distro/flatcar.py b/probe_builder/builder/distro/flatcar.py index a07f722..3e2e2f6 100644 --- a/probe_builder/builder/distro/flatcar.py +++ b/probe_builder/builder/distro/flatcar.py @@ -32,6 +32,9 @@ def unpack_kernels(self, workspace, distro, kernels): def hash_config(self, release, target): return self.md5sum(os.path.join(target, 'config'.format(release))) + def sign_file_hash_algo(self, release, target): + return self.config_module_sig_hash(os.path.join(target, 'config'.format(release))) + def get_kernel_dir(self, workspace, release, target): versions = glob.glob(os.path.join(target, 'modules/*/build')) if len(versions) != 1: diff --git a/probe_builder/builder/distro/ubuntu.py b/probe_builder/builder/distro/ubuntu.py index fc17ba9..784df6d 100644 --- a/probe_builder/builder/distro/ubuntu.py +++ b/probe_builder/builder/distro/ubuntu.py @@ -68,6 +68,9 @@ def unpack_kernels(self, workspace, distro, kernels): def hash_config(self, release, target): return self.md5sum(os.path.join(target, 'boot/config-{}'.format(release))) + def sign_file_hash_algo(self, release, target): + return self.config_module_sig_hash(os.path.join(target, 'boot/config-{}'.format(release))) + def get_kernel_dir(self, workspace, release, target): return workspace.subdir(target, 'usr/src/linux-headers-{}'.format(release))