Skip to content
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: Add notification for secure boot key check #1661

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
62e779b
feat: Add notification for secure boot key check
jardon Sep 9, 2024
4219f50
Squash: refactor to single script for motd and notify-send
jardon Sep 11, 2024
4da13af
Add quoting
jardon Sep 11, 2024
b75477f
Reverse conditional
jardon Sep 11, 2024
30c1aac
Fix grouping during quoting
jardon Sep 11, 2024
0cfbfc2
Check for file before deletion
jardon Sep 11, 2024
cfccc33
Add ~ for newline sub
jardon Sep 11, 2024
64f8a61
Clean up notify command formatting
jardon Sep 11, 2024
6517ab3
Remove fq paths to some bins
jardon Sep 11, 2024
8c3985d
Add secure boot check
jardon Sep 11, 2024
196aaa2
Add back ~ in message
jardon Sep 11, 2024
5b93743
Move motd warning outside of tips
jardon Sep 12, 2024
391e55e
Fix motd script errors
jardon Sep 12, 2024
8a49652
Bold motd warning header
jardon Sep 12, 2024
aad5db4
Fix double quoting on XDG var
jardon Sep 12, 2024
9709836
check for loginctl changes
jardon Sep 12, 2024
b2f921c
Fix linting
jardon Sep 12, 2024
1bf0a3c
Merge branch 'main' into key-dbus-notify
bsherman Sep 13, 2024
f8c31f2
Rework script check syntax
jardon Sep 13, 2024
1cc6160
Update sb key warning file location
jardon Sep 13, 2024
880d75d
Split up checking to check for sb enabled first
jardon Sep 13, 2024
edd7750
Fix json mode arg format
jardon Sep 13, 2024
3efe8f1
Merge branch 'main' into key-dbus-notify
bsherman Sep 14, 2024
87ddcf2
Rework notification to not be sent from systemd service
jardon Sep 15, 2024
bc88dc3
Update systemd service description
jardon Sep 15, 2024
306bab3
Fix execute permissions
jardon Sep 18, 2024
dbc8a65
Fix linting and update script perm
jardon Sep 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build_files/systemd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ systemctl enable brew-upgrade.timer
systemctl enable brew-update.timer
systemctl --global enable ublue-user-setup.service
systemctl --global enable podman-auto-update.timer
systemctl enable sb-key-notify.service
15 changes: 15 additions & 0 deletions system_files/shared/usr/bin/check-sb-key
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

FINGERPRINT="$(openssl x509 -fingerprint -noout -in /etc/pki/akmods/certs/akmods-ublue.der | cut -c 18-)"
mokutil --list-enrolled | grep -q $FINGERPRINT
jardon marked this conversation as resolved.
Show resolved Hide resolved
ENROLLED=$?
mokutil --sb-state | grep -q enabled
SB_ENABLED=$?

if [[ $ENROLLED -eq 1 ]] && [[ $SB_ENABLED -eq 0 ]]; then
echo "Secure Boot enabled. Key missing..."
exit 1
fi

echo "No key enrollment needed at this time."
exit 0
12 changes: 12 additions & 0 deletions system_files/shared/usr/lib/systemd/system/sb-key-notify.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Service to check for secure boot key enrollment and send notifications

[Service]
ExecStart=/usr/libexec/sb-key-notify.sh

[Install]
WantedBy=multi-user.target

[Timer]
jardon marked this conversation as resolved.
Show resolved Hide resolved
OnBootSec=1min
OnUnitActiveSec=3h
15 changes: 15 additions & 0 deletions system_files/shared/usr/libexec/sb-key-notify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
/usr/bin/check-sb-key > /dev/null

if [[ $? -eq 1 ]]; then
USER_ID=$(/usr/bin/loginctl list-users --output=json | jq -r '.[] | .user')
XDG_DIR=$(/usr/bin/loginctl show-user $USER_ID | grep RuntimePath | cut -c 13-)
/usr/bin/sudo -u \
$USER_ID DISPLAY=:0 \
DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_DIR/bus \
notify-send "WARNING" \
"This machine has secure boot turned on, but you haven't enrolled Universal Blue's keys. Failing to enroll these before rebooting may cause your system to fail to boot. Follow this link https://docs.projectbluefin.io/introduction#secure-boot for instructions on how to enroll the keys." \
-i dialog-warning \
-u critical \
-a mokutil \
--wait