-
Notifications
You must be signed in to change notification settings - Fork 4
/
signify-snapshots
executable file
·81 lines (68 loc) · 1.89 KB
/
signify-snapshots
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
78
79
80
81
#!/bin/sh
# verify all snapshots, architectures and packages with signify
set -eu
if [ $# != 0 ]
then
echo usage: signify-snapshots >&2
exit 2
fi
debug="${debug:=debug}"
ftp="/data/mirror/openbsd/ftp"
tag="signify-snapshots[$$]"
logger -p daemon.info -t "$tag" "openbsd start"
# verify each architecture snapshot
for dir in $ftp/snapshots/*
do
[ -d "$dir" ] || continue
arch="${dir##*/}"
case "$arch" in
Changelogs|packages|tools) continue ;;
esac
logger -p daemon.info -t "$tag" "openbsd $arch start"
base="`echo "$dir"/base??.tgz`"
if ! [ -f "$base" ]
then
logger -p daemon.warning -s -t "$tag" \
"openbsd $dir.new no base tgz"
continue
fi
version="${base##*/base}"
version="${version%.tgz}"
key="/etc/signify/openbsd-$version-base.pub"
logger -p daemon.info -t "$tag" "openbsd $arch signify key $key"
if ! ( cd "$dir" && signify -C -p $key -x SHA256.sig )
then
logger -p daemon.warning -s -t "$tag" "openbsd $dir fail"
else
logger -p daemon.notice -t "$tag" "openbsd $arch success"
fi | logger -p "daemon.$debug" -t signify
done
# verify each architecture package
for dir in $ftp/snapshots/packages/*
do
[ -d "$dir" ] || continue
arch=${dir##*/}
logger -p daemon.info -t "$tag" "openbsd package $arch start"
if ! [ -f "$dir/SHA256.sig" ]
then
logger -p daemon.warning -s -t "$tag" \
"openbsd $dir no SHA256 sig"
continue
fi
key=`sed -n '1s,^untrusted comment: verify with \(openbsd-..-pkg.pub\)$,/etc/signify/\1,p' "$dir/SHA256.sig"`
if [ -z "$key" ]
then
logger -p daemon.warning -s -t "$tag" \
"openbsd $dir no key name in comment"
continue
fi
if ! ( cd "$dir" && signify -C -p $key -x SHA256.sig )
then
logger -p daemon.warning -s -t "$tag" "openbsd $dir fail"
else
logger -p daemon.notice -t "$tag" \
"openbsd package $arch success"
fi | logger -p "daemon.$debug" -t signify
done
logger -p daemon.notice -t "$tag" "openbsd finished"
exit 0