TT#54410 Get rid of hardcoded checksum of sipwise.gpg file

We want to get rid of old sipwise gpg file as it contains weak key. To
do it we need either update this hardcoded value (and do it every time
when key is updated) or use the same behavior as it's used in
installer.

Change-Id: I4eba8a22cbc0b620b468fc133c07800d7f671cac
changes/18/38118/1
Mykola Malkov 7 years ago
parent b2bf8be349
commit c383a8d72d

@ -93,8 +93,6 @@ VIRTUALBOX_DIR="/usr/share/virtualbox"
VIRTUALBOX_ISO="VBoxGuestAdditions_5.1.26.iso"
VIRTUALBOX_ISO_CHECKSUM="6df8c8ab6e7ac3a70a5e29116f8a5dcdb7dfbd0b226ef849a5cd9502e956b06f" # sha256
VIRTUALBOX_ISO_URL_PATH="/files/${VIRTUALBOX_ISO}"
SIPWISE_APT_KEY_CHECKSUM_OLD="f4cdbe4994ae8ca6c4b24eb164e82a20579b335da4eca0907ecaace832e9a0a7" # sha256
SIPWISE_APT_KEY_CHECKSUM_NEW="c3b8271ec7cfd8debfd3ffcb1604a952cdf8c1033511e449684658c866eff6d8" # sha256
SIPWISE_APT_KEY_PATH="/etc/apt/trusted.gpg.d/sipwise.gpg"
# overriden later, although since the checksum is the same we could use this URL
# also for Pro/Carrier installations
@ -193,18 +191,29 @@ install_sipwise_key() {
echo "Sipwise keyring not found, downloading."
fi
local tmp_key
tmp_key="$(mktemp)"
for try in 1 2 3; do
wget --retry-connrefused --no-verbose -O "${SIPWISE_APT_KEY_PATH}" "${SIPWISE_URL}${SIPWISE_APT_KEY_URL_PATH}"
sipwise_key_checksum=$(sha256sum "${SIPWISE_APT_KEY_PATH}" | awk '{print $1}')
if [[ "${sipwise_key_checksum}" != "${SIPWISE_APT_KEY_CHECKSUM_OLD}" && \
"${sipwise_key_checksum}" != "${SIPWISE_APT_KEY_CHECKSUM_NEW}" ]] ; then
echo "Sipwise keyring downloaded has wrong checksum (expected: [${SIPWISE_APT_KEY_CHECKSUM}] - got: [${sipwise_key_checksum}]), retry $try" >&2
else
echo "Sipwise keyring downloaded with expected checksum (sha256sum: [${sipwise_key_checksum}]), debootstrap sipwise key"
debootstrap_sipwise_key
return
wget -q -T 10 --retry-connrefused --tries=3 --no-verbose -O "${tmp_key}" "${SIPWISE_URL}${SIPWISE_APT_KEY_URL_PATH}"
chmod 644 "${tmp_key}"
local sipwise_key_checksum
sipwise_key_checksum=$(sha256sum "${tmp_key}" | awk '{print $1}')
echo "Sipwise keyring downloaded with checksum (sha256sum: [${sipwise_key_checksum}]). Is it correct and should be imported into the system? [y/N]"
if "${INTERACTIVE}"; then
local a
read -r a
if [[ "${a,,}" != "y" ]] ; then
echo "The key wasn't accepted, retrying... ${try}/3"
continue
fi
fi
echo "The key has been accepted, installing it as /etc/apt/trusted.gpg.d/sipwise.gpg"
debootstrap_sipwise_key
mv "${tmp_key}" "${SIPWISE_APT_KEY_PATH}"
return
done
die "Error validating sipwise keyring for apt usage, aborting installation."

Loading…
Cancel
Save