From cbdf3860b0b3b0451e00ae98a18a07a003ec8821 Mon Sep 17 00:00:00 2001 From: Giulio Date: Wed, 23 Sep 2020 11:32:09 +0200 Subject: [PATCH] BusyBox tar does not support gz; use plain tar archives --- build-tgr.sh | 12 ++++++------ update/update.sh | 17 ++++++++--------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/build-tgr.sh b/build-tgr.sh index 2036ba9..01560a3 100755 --- a/build-tgr.sh +++ b/build-tgr.sh @@ -51,12 +51,12 @@ cp target/keys/signingpub.pem target/overlay/pub.pem echo "[+] Generating sample update package" mkdir -p home/update echo "sample update" > home/update/sample.txt -tar -cvzf update.tgz home -openssl dgst -sha256 -sign target/keys/signingkey.pem -out update.tgz.sig update.tgz -cat update.tgz > update.tgz.cc -cat update.tgz.sig >> update.tgz.cc -mv update.tgz.cc target/overlay -rm -rf home update.tgz update.tgz.sig +tar -cvf update.tar home +openssl dgst -sha256 -sign target/keys/signingkey.pem -out update.tar.sig update.tar +cat update.tar > update.tar.cc +cat update.tar.sig >> update.tar.cc +mv update.tar.cc target/overlay +rm -rf home update.tar update.tar.sig echo "[+] Generating Monitoring SSH Key" ssh-keygen -t ecdsa -f target/keys/sshkey -q -N "" diff --git a/update/update.sh b/update/update.sh index b3e5260..d7b08b0 100755 --- a/update/update.sh +++ b/update/update.sh @@ -15,7 +15,8 @@ fi pubkey="/pub.pem" -file="/tmp/update.tgz.cc" +file="/tmp/update.tar.cc" +/bin/chmod 777 $file /bin/echo "### ccOS Update Script ###" /bin/echo "[+] Starting" /bin/sleep 1 @@ -25,19 +26,17 @@ if [[ -L $file ]] then exit 0 fi -/bin/dd if=/tmp/update.tgz.cc of=sig bs=1 count=256 skip=$skip -/usr/bin/truncate -s $skip update.tgz.cc -check=`/usr/bin/openssl dgst -sha256 -verify $pubkey -signature /tmp/sig /tmp/update.tgz.cc` +/bin/dd if=/tmp/update.tar.cc of=sig bs=1 count=256 skip=$skip +/usr/bin/truncate -s $skip $file +check=`/usr/bin/openssl dgst -sha256 -verify $pubkey -signature /tmp/sig $file` if [ "$check" == "Verified OK" ] then /bin/echo "[+] Signature is valid!" /bin/echo "[+] Upgrading..." - /bin/tar -xvzf /tmp/update.tgz.cc -C / - /bin/rm /tmp/update.tgz.cc /tmp/sig + /bin/tar -xvf $file -C / + /bin/rm $file /tmp/sig /bin/echo "[+] Done" - exit 0 else /bin/echo "[-] Signature error, exiting..." - /bin/rm /tmp/update.tgz.cc /tmp/sig - exit 1 + /bin/rm $file /tmp/sig fi