@@ -71,19 +71,28 @@ sysext_download() {
71
71
entries=$( grep -m 1 -o " <package name=\" ${name} \" [^>]*" " ${from} " )
72
72
url=" ${base} /${name} "
73
73
size=$( echo " ${entries} " | grep -o ' size="[0-9]*' | cut -d ' "' -f 2)
74
- hash=$( echo " ${entries} " | grep -o -P ' hash="[^"]*' | cut -d ' "' -f 2) # openssl dgst -binary -sha1 < "$PAYLOAD" | base64
74
+ hash=$( echo " ${entries} " | { grep -o -P ' hash="[^"]*' || true ; } | cut -d ' "' -f 2) # openssl dgst -binary -sha1 < "$PAYLOAD" | base64
75
+ hash_sha256=$( echo " ${entries} " | { grep -o -P ' hash_sha256="[^"]*' || true ; } | cut -d ' "' -f 2) # sha256sum -b "$PAYLOAD" | cut -d " " -f 1
75
76
fi
76
77
rm -f " ${target} .tmp"
77
78
curl -fsSL --retry-delay 1 --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 -o " ${target} .tmp" " ${url} "
78
- if [ " ${size} " != " " ] && [ " ${hash }" != " " ]; then
79
+ if [ " ${base } " != " " ]; then
79
80
if [ " $( stat --printf=' %s' " ${target} .tmp" ) " != " ${size} " ]; then
80
81
echo " Size mismatch for ${name} " >&2
81
82
return 1 # jump to ret=
82
83
fi
83
- if [ " $( openssl dgst -binary -sha1 < " ${target} .tmp" | base64) " != " ${hash} " ]; then
84
+ if [ " ${hash} " = " " ] && [ " ${hash_sha256} " = " " ]; then
85
+ echo " At least one hash is expected, found none in Omaha package for ${name} " >&2
86
+ return 1 # jump to ret=
87
+ fi
88
+ if [ " ${hash} " != " " ] && [ " $( openssl dgst -binary -sha1 < " ${target} .tmp" | base64) " != " ${hash} " ]; then
84
89
echo " Hash mismatch for ${name} " >&2
85
90
return 1 # jump to ret=
86
91
fi
92
+ if [ " ${hash_sha256} " != " " ] && [ " $( sha256sum -b " ${target} .tmp" | cut -d " " -f 1) " != " ${hash_sha256} " ]; then
93
+ echo " Hash SHA256 mismatch for ${name} " >&2
94
+ return 1 # jump to ret=
95
+ fi
87
96
fi
88
97
# Using "${INSTALL_MNT}" here is ok because it was verified first by update-engine
89
98
PROTOPATH=" ${INSTALL_MNT} " /share/update_engine/ " ${INSTALL_MNT} " /share/update_engine/decode_payload /usr/share/update_engine/update-payload-key.pub.pem " ${target} .tmp" " ${target} "
@@ -118,7 +127,8 @@ if [ "${OEMID}" != "" ] && { [ -e "${INSTALL_MNT}/share/flatcar/oems/${OEMID}" ]
118
127
fi
119
128
done
120
129
# Note that in the case of VERSION=NEXT_VERSION we will replace the running sysext and maybe it's better
121
- # to do so than not because it allows to recover from a corrupted file (where the corruption happened on disk)
130
+ # to do so than not because it allows to recover from a corrupted file (where the corruption happened on disk).
131
+ # However, as soon as update-engine would already download the payload, we should skip the overwriting.
122
132
SUCCESS=false
123
133
# Preferred is to download from the location given by the Omaha response
124
134
# which only works with a new update-engine client that creates "full-response",
0 commit comments