Skip to content

Commit

Permalink
[wip] add flatcar,ubuntu and handle missing CONFIG_MODULE_SIG_HASH
Browse files Browse the repository at this point in the history
  • Loading branch information
iurly committed Feb 24, 2023
1 parent 6800942 commit cef65bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion probe_builder/builder/distro/base_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions probe_builder/builder/distro/flatcar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions probe_builder/builder/distro/ubuntu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit cef65bf

Please sign in to comment.