From ee2b59a3e0349ade31a7c98a0a6c1bdf74ccc83e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Draszik?= Date: Tue, 23 Nov 2021 12:16:43 +0000 Subject: [PATCH] csd-wrapper: make it work again if binaries are compressed MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit CSD binaries can be uncompressed or .gz compressed, and the csd-wrapper.sh script here tries to support both cases, but actually doesn't work in the compressed case. It just ends up specifying incorrect URLs and destination file names, making this miserably fail: + curl -s -k https://xx.xxx.xxx.xx/CACHE/sdesktop/hostscan/linux_x64/cscan -o /home/xxx/.cisco/hostscan/bin/cscan.tmp + [[ ! -f /home/xxx/.cisco/hostscan/bin/cscan.tmp ]] + [[ ! -s /home/xxx/.cisco/hostscan/bin/cscan.tmp ]] + [[ ! -s /home/xxx/.cisco/hostscan/bin/cscan.tmp ]] + rm /home/xxx/.cisco/hostscan/bin/cscan.tmp + echo 'Failure on cscan, trying gz' Failure on cscan, trying gz + FILE_GZ=/home/xxx/.cisco/hostscan/bin/cscan.tmp.gz + curl -s -k --pinnedpubkey sha256//vI158z4H4BLBZKv927uWmvsJbFZzGEilTkI36lKv5BM= https://xx.xxx.xxx.xx/CACHE/sdesktop/hostscan/linux_x64//home/xxx/.cisco/hostscan/bin/cscan.tmp.gz -o /home/xxx/.cisco/hostscan/bin/cscan.tmp.gz + gunzip --verbose --decompress /home/xxx/.cisco/hostscan/bin/cscan.tmp.gz gzip: /home/xxx/.cisco/hostscan/bin/cscan.tmp.gz: unexpected end of file As can be seen the 2nd curl call has my local path appended to the URL, which of course can not work ($TMPFILE contains the full local path). Fixes: 9da32db08ba4 ("Clean up csd-wrapper.sh") Signed-off-by: André Draszik --- trojans/csd-wrapper.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trojans/csd-wrapper.sh b/trojans/csd-wrapper.sh index 1dbedb08..5a3608e6 100755 --- a/trojans/csd-wrapper.sh +++ b/trojans/csd-wrapper.sh @@ -120,9 +120,9 @@ while read HASHTYPE FILE EQU HASHVAL; do fi echo "Failure on $FILE, trying gz" - FILE_GZ="${TMPFILE}.gz" - curl $PINNEDPUBKEY -s "${URL}/sdesktop/hostscan/$ARCH/$FILE_GZ" -o "${FILE_GZ}" && - gunzip --verbose --decompress "${FILE_GZ}" + FILE_GZ="${FILE}.gz" + curl $PINNEDPUBKEY -s "${URL}/sdesktop/hostscan/$ARCH/$FILE_GZ" -o "${TMPFILE}.gz" && + gunzip --verbose --decompress "${TMPFILE}.gz" fi if [ -r "${TMPFILE}" ]; then -- 2.50.1