Skip to content

Commit

Permalink
script/seccomp.sh: check tarball sha256
Browse files Browse the repository at this point in the history
Add checking of downloaded tarball checksum.

In case it doesn't match, the error is like this:

	libseccomp-2.5.4.tar.gz checksum mismatch!

In case the checksum for a particular version is not specified in the
script, the error will look like this:

	./script/seccomp.sh: line 29: SECCOMP_SHA256[${ver}]: unbound variable

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit c532f33)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed May 24, 2022
1 parent ec989ea commit eded0c5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion script/seccomp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ set -e -u -o pipefail
# shellcheck source=./script/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"

# sha256 checksums for seccomp release tarballs.
declare -A SECCOMP_SHA256=(
["2.5.4"]=d82902400405cf0068574ef3dc1fe5f5926207543ba1ae6f8e7a1576351dcbdb
)

# Due to libseccomp being LGPL we must include its sources,
# so download, install and build against it.
# Parameters:
Expand All @@ -19,8 +24,12 @@ function build_libseccomp() {
local arches=("$@")
local tar="libseccomp-${ver}.tar.gz"

# Download and extract.
# Download, check, and extract.
wget "https://github.com/seccomp/libseccomp/releases/download/v${ver}/${tar}"{,.asc}
if ! sha256sum "${tar}" | grep -E "^${SECCOMP_SHA256[${ver}]}\s+${tar}$"; then
echo "$tar checksum mismatch!"
exit 1
fi
local srcdir
srcdir="$(mktemp -d)"
tar xf "$tar" -C "$srcdir"
Expand Down

0 comments on commit eded0c5

Please sign in to comment.