From 4908667cc3fb95260000b81664e0f9c409592831 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Tue, 10 Dec 2024 15:16:18 +0200 Subject: [PATCH] lxc-alpine: remove unverified apk.static to prevent its execution on the next run Signed-off-by: Kaarle Ritvanen --- templates/lxc-alpine.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/lxc-alpine.in b/templates/lxc-alpine.in index beadd53..37f6248 100644 --- a/templates/lxc-alpine.in +++ b/templates/lxc-alpine.in @@ -224,11 +224,14 @@ fetch_apk_static() { local sigprefix=$apk.SIGN.RSA. local keyfile=$(ls -1 "$sigprefix"alpine-*.pub 2>/dev/null | head -n 1) - openssl dgst -sha1 \ + if ! openssl dgst -sha1 \ -verify "$APK_KEYS_DIR/${keyfile#$sigprefix}" \ -signature "$keyfile" \ - "$apk" \ - || die 2 'Signature verification for apk.static failed' + "$apk"; then + + rm -f "$apk" + die 2 'Signature verification for apk.static failed' + fi # Note: apk doesn't return 0 for --version local out=$("$apk" --version)