Last active
January 22, 2019 15:47
-
-
Save bbayles/bc3592648e6231f4b7751d74ec2570f2 to your computer and use it in GitHub Desktop.
Sign kernel modules for secure boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import io | |
import glob | |
import os | |
import subprocess | |
os.chdir(os.path.dirname(__file__)) | |
priv_file = 'MOK.priv' | |
der_file = 'MOK.der' | |
osrelease = io.open('/proc/sys/kernel/osrelease').read().strip() | |
sign_file = '/usr/src/linux-headers-{}/scripts/sign-file'.format(osrelease) | |
assert(os.path.exists(sign_file)) | |
glob_pattern = '/lib/modules/{}/misc/*.ko'.format(osrelease) | |
for file_path in glob.iglob(glob_pattern): | |
print(file_path) | |
subprocess.check_call( | |
[sign_file, 'sha256', priv_file, der_file, file_path] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment