Skip to content

Commit

Permalink
bootscript: use sha256sum formatted hash file
Browse files Browse the repository at this point in the history
  • Loading branch information
osresearch committed Jul 23, 2021
1 parent 5d583be commit 09e0b14
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ local.conf
build
linux-*
initramfs/response/wrapper.*
initramfs/response/*.hash
7 changes: 3 additions & 4 deletions initramfs/bootscript
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,9 @@ install_img() {
curl "$URL" | tee "$MAPPER" | sha256sum - | tee "$TMPDIR/url.hash" \
|| die "$DEV: unable to fetch $URL"

if [ -n "$URL_HASH" ]; then
echo "$URL_HASH -" > "$TMPDIR/url.hash.golden"
if ! cmp "$TMPDIR/url.hash" "$TMPDIR/url.hash.golden" ; then
die "$URL: hash failed. Expected $URL_HASH"
if [ -r "$TMPDIR/img.hash" ]; then
if ! cmp "$TMPDIR/img.hash" "$TMPDIR/url.hash" ; then
die "$URL: hash failed!"
fi

warn "$URL: verified $URL_HASH"
Expand Down
3 changes: 1 addition & 2 deletions initramfs/response/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
echo "hello world!"

DEV="/dev/sda"
URL="http://10.0.2.2:8000/focal-server-cloudimg-amd64.img"
URL_HASH="b723a8fa028d6ab80242239c52c0ef7d11d9dc534b491094fbc44e8d908a76ee"
URL="http://10.0.2.2:8080/focal-server-cloudimg-amd64.img"

0 comments on commit 09e0b14

Please sign in to comment.