-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: kernel signing cache kernels #9
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4de7d9a
feat: kernel signing cache kernels
m2Giles e599b65
feat: Enable multiple sbsign signatures
m2Giles 9f7b4c5
fix: correct variable name
m2Giles ee762af
fix: surface reinstall for sbverify
m2Giles 3c7af18
fix: dual_sign argument is already a string
m2Giles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDMaUcd1e4fYogO | ||
N/cYZc22xmzsAetfhgVLvHNkKb/mNHywkGK4T7vPwvpQCxFGUufmRxYlGJra/QCn | ||
WjYd4/thBWoU/K7RBcLJJpuHFBODls5eBdXGXXpeTYmRKqcT6qBEJf4p21N2BqMz | ||
Mmh242TUKFOJ3rWWKXxWb8peNC+aMfIMKICLYSQvoonjHQm1ShMjkgTiOZQIaVLB | ||
zjfNewdaNCHOMh49xQrQxquTXJuNU6Y7LvPGSIdxShwotGi/E+Z3Y4kvUCapo0os | ||
wjhXXbhuj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H3n1WAY9qhjusNmHwwJx7pF51fzRlvG3fZTlIWBpoSrwmI2TqQGnFLcJh36s | ||
mAz/jGLtqQMu21leRGC7ooYurBAOjcf3e5Al1mjhAoGAT0L02oGzce1vbwfqHCRK | ||
PexrY8GvNU6/Bml70P9n6FX3jQwt6Dhh1JkZZofv+wJWjOj4zV/Z0tj1uB1Ax9nR | ||
Z+87Pu7iYuNaYFGT9s76q+sbQtiUu5Gwlg6CyRSwbKdL15UBWf+Bt22Tp3NfbEoh | ||
OevJKeniH2GYy+ME5XxXb14= | ||
-----END PRIVATE KEY----- |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCnVfa8014cwVhH | ||
8SKJFg94/krdWYAAbEG+BVMWfJf84v19bqEUWO9GKYUHTXIOYTzOcdyyYkBDm8hL | ||
DpUGHWtgAut4l4cDpDCkL9sJzAhKS6lOW0pCqaZzqJoq8AUyK84j/l3vEBwuucZo | ||
HypEyK+GeaWFc5fo3P/UQmYML78YgS2Lbb/MDwH+Zfrmt9IoKv75oIdmOVC/dpzS | ||
MiJZB1trjKyS+31o6gXCI43kpMsRGSHHqW6k5zhNNEAN/0uiGI28C2WDrB4v2igg | ||
bpF6QOMyrCqKs+oHUWndadUzG6Dwz+f4oZ1F7M/J5Xn8N2F1VEDqvvMBU2ZquRyX | ||
NLzbJvcnAgMBAAECggEAQ9LI7iHxvE/1eztWVx/054KST4NOKV23i9BWq/+WDu7l | ||
9agYa8ncOaDshVgziXaKEdb+r+K4z25d0WY4qsDT25dzX25zT9uFx5aJ/j+PgKWI | ||
GvVPdROUHr7QteSRBpPQurAH3LS354xuyZcQJ877rdKybxO6F60zmBHNkNTtbH2P | ||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CHV1oCgoa8Rq1Zxc/ | ||
5bzd1lBjif4fuc6RXjooHX+3 | ||
-----END PRIVATE KEY----- |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,11 @@ set -eoux pipefail | |
kernel_version="${KERNEL_VERSION}" | ||
kernel_flavor="${KERNEL_FLAVOR}" | ||
|
||
dnf install -y dnf-plugins-core | ||
#CoreOS pool repo | ||
# curl -LsSf -o /etc/yum.repos.d/fedora-coreos-pool.repo \ | ||
# https://raw.githubusercontent.com/coreos/fedora-coreos-config/testing-devel/fedora-coreos-pool.repo | ||
|
||
dnf install -y dnf-plugins-core rpmrebuild sbsigntools openssl | ||
|
||
case "$kernel_flavor" in | ||
"asus") | ||
|
@@ -31,44 +35,155 @@ esac | |
if [[ "${kernel_flavor}" =~ asus|fsync ]]; then | ||
dnf download -y \ | ||
kernel-"${kernel_version}" \ | ||
kernel-core-"${kernel_version}" \ | ||
kernel-modules-"${kernel_version}" \ | ||
kernel-modules-core-"${kernel_version}" \ | ||
kernel-modules-extra-"${kernel_version}" \ | ||
kernel-devel-"${kernel_version}" \ | ||
kernel-devel-matched-"${kernel_version}" \ | ||
kernel-uki-virt-"${kernel_version}" | ||
|
||
elif [[ "${kernel_flavor}" == "surface" ]]; then | ||
dnf download -y \ | ||
kernel-surface-"${kernel_version}" \ | ||
kernel-surface-core-"${kernel_version}" \ | ||
kernel-surface-modules-"${kernel_version}" \ | ||
kernel-surface-modules-core-"${kernel_version}" \ | ||
kernel-surface-modules-extra-"${kernel_version}" \ | ||
kernel-surface-devel-"${kernel_version}" \ | ||
kernel-surface-devel-matched-"${kernel_version}" \ | ||
kernel-surface-default-watchdog-"${kernel_version}" \ | ||
iptsd | ||
iptsd \ | ||
libwacom-surface \ | ||
libwacom-surface-data | ||
|
||
|
||
else | ||
KERNEL_MAJOR_MINOR_PATCH=$(echo "$kernel_version" | cut -d '-' -f 1) | ||
KERNEL_RELEASE="$(echo "$kernel_version" | cut -d - -f 2 | cut -d . -f 1).$(echo "$kernel_version" | cut -d - -f 2 | cut -d . -f 2)" | ||
ARCH=$(uname -m) | ||
dnf download -y \ | ||
https://kojipkgs.fedoraproject.org//packages/kernel/"$KERNEL_MAJOR_MINOR_PATCH"/"$KERNEL_RELEASE"/"$ARCH"/kernel-"$kernel_version".rpm \ | ||
https://kojipkgs.fedoraproject.org//packages/kernel/"$KERNEL_MAJOR_MINOR_PATCH"/"$KERNEL_RELEASE"/"$ARCH"/kernel-core-"$kernel_version".rpm \ | ||
https://kojipkgs.fedoraproject.org//packages/kernel/"$KERNEL_MAJOR_MINOR_PATCH"/"$KERNEL_RELEASE"/"$ARCH"/kernel-modules-"$kernel_version".rpm \ | ||
https://kojipkgs.fedoraproject.org//packages/kernel/"$KERNEL_MAJOR_MINOR_PATCH"/"$KERNEL_RELEASE"/"$ARCH"/kernel-modules-core-"$kernel_version".rpm \ | ||
https://kojipkgs.fedoraproject.org//packages/kernel/"$KERNEL_MAJOR_MINOR_PATCH"/"$KERNEL_RELEASE"/"$ARCH"/kernel-modules-extra-"$kernel_version".rpm \ | ||
https://kojipkgs.fedoraproject.org//packages/kernel/"$KERNEL_MAJOR_MINOR_PATCH"/"$KERNEL_RELEASE"/"$ARCH"/kernel-devel-"$kernel_version".rpm \ | ||
https://kojipkgs.fedoraproject.org//packages/kernel/"$KERNEL_MAJOR_MINOR_PATCH"/"$KERNEL_RELEASE"/"$ARCH"/kernel-devel-matched-"$kernel_version".rpm \ | ||
https://kojipkgs.fedoraproject.org//packages/kernel/"$KERNEL_MAJOR_MINOR_PATCH"/"$KERNEL_RELEASE"/"$ARCH"/kernel-uki-virt-"$kernel_version".rpm | ||
|
||
fi | ||
|
||
if [[ "${kernel_flavor}" =~ fsync ]]; then | ||
dnf download -y \ | ||
kernel-headers-"${kernel_version}" | ||
fi | ||
|
||
if [[ ! -s /tmp/certs/private_key.priv ]]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @p5 Here is the logic for signing during PRs. |
||
echo "WARNING: Using test signing key." | ||
cp /tmp/certs/private_key.priv{.test,} | ||
cp /tmp/certs/public_key.der{.test,} | ||
fi | ||
|
||
PUBLIC_KEY_PATH="/etc/pki/kernel/public/public_key.crt" | ||
PRIVATE_KEY_PATH="/etc/pki/kernel/private/private_key.priv" | ||
|
||
openssl x509 -in /tmp/certs/public_key.der -out /tmp/certs/public_key.crt | ||
|
||
install -Dm644 /tmp/certs/public_key.crt "$PUBLIC_KEY_PATH" | ||
install -Dm644 /tmp/certs/private_key.priv "$PRIVATE_KEY_PATH" | ||
|
||
if [[ "${kernel_flavor}" =~ asus|fsync ]]; then | ||
dnf install -y \ | ||
/kernel-"$kernel_version".rpm \ | ||
/kernel-modules-"$kernel_version".rpm \ | ||
/kernel-modules-core-"$kernel_version".rpm \ | ||
/kernel-modules-extra-"$kernel_version".rpm \ | ||
kernel-core-"${kernel_version}" | ||
elif [[ "${kernel_flavor}" =~ surface ]]; then | ||
dnf install -y \ | ||
/kernel-surface-"$kernel_version".rpm \ | ||
/kernel-surface-modules-"$kernel_version".rpm \ | ||
/kernel-surface-modules-core-"$kernel_version".rpm \ | ||
/kernel-surface-modules-extra-"$kernel_version".rpm \ | ||
kernel-surface-core-"${kernel_version}" | ||
else | ||
dnf install -y \ | ||
/kernel-"$kernel_version".rpm \ | ||
/kernel-modules-"$kernel_version".rpm \ | ||
/kernel-modules-core-"$kernel_version".rpm \ | ||
/kernel-modules-extra-"$kernel_version".rpm \ | ||
https://kojipkgs.fedoraproject.org//packages/kernel/"$KERNEL_MAJOR_MINOR_PATCH"/"$KERNEL_RELEASE"/"$ARCH"/kernel-core-"$kernel_version".rpm | ||
fi | ||
|
||
# Strip Signatures from non-fedora Kernels | ||
if [[ ${kernel_flavor} =~ main|coreos ]]; then | ||
echo "Will not strip Fedora signature(s) from ${kernel_flavor} kernel." | ||
else | ||
EXISTING_SIGNATURES="$(sbverify --list /usr/lib/modules/"$kernel_version"/vmlinuz | grep '^signature \([0-9]\+\)$' | sed 's/^signature \([0-9]\+\)$/\1/')" || true | ||
if [[ -n "$EXISTING_SIGNATURES" ]]; then | ||
for SIGNUM in $EXISTING_SIGNATURES; do | ||
echo "Found existing signature at signum $SIGNUM, removing..." | ||
sbattach --remove /usr/lib/modules/"${kernel_version}"/vmlinuz | ||
done | ||
fi | ||
fi | ||
|
||
# Sign Kernel with Key | ||
sbsign --cert "$PUBLIC_KEY_PATH" --key "$PRIVATE_KEY_PATH" /usr/lib/modules/"${kernel_version}"/vmlinuz --output /usr/lib/modules/"${kernel_version}"/vmlinuz | ||
|
||
# Verify Signatures | ||
sbverify --list /usr/lib/modules/"${kernel_version}"/vmlinuz | ||
|
||
rm -f "$PRIVATE_KEY_PATH" "$PUBLIC_KEY_PATH" | ||
|
||
if [[ ${DUAL_SIGN:-} == "true" ]]; then | ||
SECOND_PUBLIC_KEY_PATH="/etc/pki/kernel/public/public_key_2.crt" | ||
SECOND_PRIVATE_KEY_PATH="/etc/pki/kernel/private/public_key_2.priv" | ||
if [[ ! -s /tmp/certs/private_key_2.priv ]]; then | ||
echo "WARNING: Using test signing key." | ||
cp /tmp/certs/private_key_2.priv{.test,} | ||
cp /tmp/certs/public_key_2.der{.test,} | ||
find /tmp/certs/ | ||
fi | ||
openssl x509 -in /tmp/certs/public_key_2.der -out /tmp/certs/public_key_2.crt | ||
install -Dm644 /tmp/certs/public_key_2.crt "$SECOND_PUBLIC_KEY_PATH" | ||
install -Dm644 /tmp/certs/private_key_2.priv "$SECOND_PRIVATE_KEY_PATH" | ||
sbsign --cert "$SECOND_PUBLIC_KEY_PATH" --key "$SECOND_PRIVATE_KEY_PATH" /usr/lib/modules/"${kernel_version}"/vmlinuz --output /usr/lib/modules/"${kernel_version}"/vmlinuz | ||
sbverify --list /usr/lib/modules/"${kernel_version}"/vmlinuz | ||
rm -f "$SECOND_PRIVATE_KEY_PATH" "$SECOND_PUBLIC_KEY_PATH" | ||
fi | ||
|
||
# Rebuild RPMs and Verify | ||
if [[ "${kernel_flavor}" =~ surface ]]; then | ||
rpmrebuild --batch kernel-surface-core-"${kernel_version}" | ||
rm -f /usr/lib/modules/"${kernel_version}"/vmlinuz | ||
dnf reinstall -y \ | ||
/kernel-surface-"$kernel_version".rpm \ | ||
/kernel-surface-modules-"$kernel_version".rpm \ | ||
/kernel-surface-modules-core-"$kernel_version".rpm \ | ||
/kernel-surface-modules-extra-"$kernel_version".rpm \ | ||
/root/rpmbuild/RPMS/"$(uname -m)"/kernel-*.rpm | ||
else | ||
rpmrebuild --batch kernel-core-"${kernel_version}" | ||
rm -f /usr/lib/modules/"${kernel_version}"/vmlinuz | ||
dnf reinstall -y \ | ||
/kernel-"$kernel_version".rpm \ | ||
/kernel-modules-"$kernel_version".rpm \ | ||
/kernel-modules-core-"$kernel_version".rpm \ | ||
/kernel-modules-extra-"$kernel_version".rpm \ | ||
/root/rpmbuild/RPMS/"$(uname -m)"/kernel-*.rpm | ||
fi | ||
|
||
sbverify --list /usr/lib/modules/"${kernel_version}"/vmlinuz | ||
|
||
# Make Temp Dir | ||
mkdir -p /tmp/rpms | ||
|
||
# Move RPMs over | ||
mv /kernel-*.rpm /tmp/rpms | ||
mv /root/rpmbuild/RPMS/"$(uname -m)"/kernel-*.rpm /tmp/rpms | ||
|
||
if [[ "${kernel_flavor}" =~ surface ]]; then | ||
cp iptsd-*.rpm libwacom-*.rpm /tmp/rpms | ||
fi | ||
|
||
# Delete keys in /tmp if we decide to publish this later | ||
rm -rf /tmp/certs |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think about it now, but it might be worth having a sample signing key that runs on PRs to make it easier to debug in future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, we have signing keys added in this PR anyway. Any reason not to (at a later date) use the .test keys in this step during pull requests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do, you can see in
fetch.sh
if the private-key is 0 bytes, we copy the test keys over.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh, sorry. We don't need to retrieve them since they are already in the repo 🤦