blob: d66875149a69c11d54c9834ad301f927fd243740 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#!/bin/ash
set -u
set -e
# set -x
# Grab functions
[ -f /usr/lib/nannycam/nannycam.functions ] && source /usr/lib/nannycam/nannycam.functions
[ -f nannycam.functions ] && source nannycam.functions
# Check if running outside the initramfs environment, setup env otherwise
ensure_initramfs_environment
# Parse options
while getopts ":k:h:q:m:p:e:" opt; do
case $opt in
k)
AUTH_KEY_FILE="$OPTARG"
;;
h)
HASH_ALG="$OPTARG"
;;
q)
QR_OPTS="$OPTARG"
;;
m)
EXPECTED_MBR_HASH="$OPTARG"
;;
p)
EXPECTED_MBR_GAP_HASH="$OPTARG"
;;
e)
EXPECTED_EFI_STUB_HASH="$OPTARG"
;;
\?)
nannycam_usage >&2
exit 1
;;
:)
echo "$OPTARG requires an argument" >&2
exit 1
esac
done
[ -z ${AUTH_KEY_FILE:-} ] && err_required_arg k
[ -z ${EXPECTED_MBR_HASH:-} ] && err_required_arg m
[ -z ${EXPECTED_MBR_GAP_HASH:-} ] && err_required_arg p
[ -z ${EXPECTED_EFI_STUB_HASH:-} ] && err_required_arg e
# Can't access block devices unless root
assert_root
ACTUAL_MBR_HASH="not checked"
ACTUAL_MBR_GAP_HASH="not checked"
ACTUAL_EFI_STUB_HASH="not checked"
if [ ! -f "$AUTH_KEY_FILE" ]; then
echo "Keyfile: $AUTH_KEY_FILE not found, aborting boot." >&2
exit 2
fi
check_mbr && check_mbr_gap && check_efi_stub || hash_mismatch
DATE_TIME="$(date +%s)"
PREFIX="D${DATE_TIME}S"
(
echo -n "$PREFIX"
echo -n "$DATE_TIME" \
| openssl dgst -"$HASH_ALG" -sign "$AUTH_KEY_FILE"
) \
| qrencode -8 $QR_OPTS
echo "$DATE_TIME"
response=""
while [[ "$response" != "YES" ]]; do
read -p "Enter YES if the signature is correct: " response
done
|