Skip to content

Commit 2b3e7bd

Browse files
bors[bot]prashks
andauthored
Merge #133
133: DLPX-65330 Latest public keys are missing in upgrade and migration images r=prashks a=prashks These changes install the correct image signing keys (both `registration` and `upgrade` keys) for the correct/current Delphix Release version being built. The signing keys version to use is parameterized via `DELPHIX_SIGNATURE_VERSION` which is passed as environment variable via jenkins build job -> linux-pkg -> delphix_platform package build. Corresponding jenkins changes are: [devops-gate ](http://reviews.delphix.com/r/52325/) Co-authored-by: Prashanth Sreenivasa <pks@delphix.com>
2 parents ce2a29d + 0e605c5 commit 2b3e7bd

File tree

6 files changed

+50
-18
lines changed

6 files changed

+50
-18
lines changed

debian/rules

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ KERNEL_TYPE.esx := generic
2222
KERNEL_TYPE.gcp := gcp
2323
KERNEL_TYPE.kvm := kvm
2424

25+
DELPHIX_SIGNATURE_TYPES = registration upgrade
26+
2527
#
2628
# The following meta-package consolidates all the kernel packages required
2729
# by the Delphix Appliance for a given platform. Note that delphix-kernel
@@ -166,8 +168,9 @@ override_dh_install:
166168
>debian/tmp/var/lib/delphix-appliance/platform
167169
rm debian/tmp/var/lib/delphix-appliance/platform.in
168170

169-
./scripts/download-signature-key.sh upgrade 5.3 \
170-
>debian/tmp/var/lib/delphix-appliance/key-public.pem.upgrade.5.3
171+
for type in $(DELPHIX_SIGNATURE_TYPES) ; do \
172+
./scripts/download-signature-key.sh $$type "$(DELPHIX_SIGNATURE_VERSION)" \
173+
>"debian/tmp/var/lib/delphix-appliance/key-public.pem.$$type.$(DELPHIX_SIGNATURE_VERSION)" ; done
171174

172175
dh_install --autodest "debian/tmp/*"
173176

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2019 Delphix
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
set -o errexit
19+
set -o pipefail
20+
21+
zfs get -Hpo value \
22+
"com.delphix:current-version" \
23+
"$(dirname "$(zfs list -Hpo name /)")" | tr -d '\n'

files/common/usr/bin/get-property-from-image

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,23 @@ UNPACK_DIR=$(mktemp -d -p "$UPDATE_DIR" -t unpack.XXXXXXX)
8080
[[ -d "$UNPACK_DIR" ]] || die "failed to create unpack directory '$UNPACK_DIR'"
8181
pushd "$UNPACK_DIR" &>/dev/null || die "'pushd $UNPACK_DIR' failed"
8282

83-
tar -x SHA256SUMS SHA256SUMS.sig.5.3 version.info -f "$UPGRADE_IMAGE_PATH" ||
83+
DELPHIX_SIGNATURE_VERSION=$(/usr/bin/get-appliance-version | cut -d - -f 1 | cut -d . -f 1-2)
84+
85+
tar -x SHA256SUMS SHA256SUMS.sig."$DELPHIX_SIGNATURE_VERSION" version.info -f "$UPGRADE_IMAGE_PATH" ||
8486
die 14 "failed to extract files from upgrade image '$UPGRADE_IMAGE_PATH'"
8587

86-
for file in SHA256SUMS SHA256SUMS.sig.5.3 version.info; do
88+
for file in SHA256SUMS SHA256SUMS.sig."$DELPHIX_SIGNATURE_VERSION" version.info; do
8789
[[ -f "$file" ]] || die 15 "image is corrupt; missing '$file' file"
8890
done
8991

9092
if [[ -z "$opt_s" ]]; then
9193
openssl dgst -sha256 \
92-
-verify /var/lib/delphix-appliance/key-public.pem.upgrade.5.3 \
93-
-signature SHA256SUMS.sig.5.3 \
94+
-verify /var/lib/delphix-appliance/key-public.pem.upgrade."$DELPHIX_SIGNATURE_VERSION" \
95+
-signature SHA256SUMS.sig."$DELPHIX_SIGNATURE_VERSION" \
9496
SHA256SUMS >/dev/null ||
9597
die 16 "image is corrupt; verification of 'SHA256SUMS' file," \
96-
"using signature 'SHA256SUMS.sig.5.3'" \
97-
"and key 'key-public.pem.upgrade.5.3' failed"
98+
"using signature 'SHA256SUMS.sig.$DELPHIX_SIGNATURE_VERSION'" \
99+
"and key 'key-public.pem.upgrade.$DELPHIX_SIGNATURE_VERSION' failed"
98100
fi
99101

100102
awk '$2 == "version.info" { print $0 }' SHA256SUMS |

files/common/usr/bin/unpack-image

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,16 @@ for file in SHA256SUMS prepare; do
110110
[[ -f "$file" ]] || die 15 "image is corrupt; missing '$file' file"
111111
done
112112

113+
DELPHIX_SIGNATURE_VERSION=$(/usr/bin/get-appliance-version | cut -d - -f 1 | cut -d . -f 1-2)
114+
113115
if [[ -z "$opt_s" ]]; then
114116
openssl dgst -sha256 \
115-
-verify /var/lib/delphix-appliance/key-public.pem.upgrade.5.3 \
116-
-signature SHA256SUMS.sig.5.3 \
117+
-verify /var/lib/delphix-appliance/key-public.pem.upgrade."$DELPHIX_SIGNATURE_VERSION" \
118+
-signature SHA256SUMS.sig."$DELPHIX_SIGNATURE_VERSION" \
117119
SHA256SUMS >/dev/null ||
118120
die 16 "image is corrupt; verification of 'SHA256SUMS' file," \
119-
"using signature 'SHA256SUMS.sig.5.3'" \
120-
"and key 'key-public.pem.upgrade.5.3' failed"
121+
"using signature 'SHA256SUMS.sig.$DELPHIX_SIGNATURE_VERSION'" \
122+
"and key 'key-public.pem.upgrade.$DELPHIX_SIGNATURE_VERSION' failed"
121123
fi
122124

123125
sha256sum -c SHA256SUMS >/dev/null ||

scripts/docker-run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ $DOCKER_RUN --rm \
4747
--env AWS_SECRET_ACCESS_KEY \
4848
--env DELPHIX_SIGNATURE_URL \
4949
--env DELPHIX_SIGNATURE_TOKEN \
50+
--env DELPHIX_SIGNATURE_VERSION \
5051
--volume "$TOP:/opt/delphix-platform" \
5152
--workdir "/opt/delphix-platform" \
5253
delphix-platform "$@"

scripts/download-signature-key.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ fi
3030
set -o errexit
3131
set -o pipefail
3232

33-
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
34-
echo "Must specify key 'type' and 'version'."
35-
exit 1
36-
fi
37-
3833
TYPE="$1"
3934
VERSION="$2"
4035

@@ -46,7 +41,13 @@ VERSION="$2"
4641
# package will not be correct. When this package is built by our build
4742
# system and automation, these variables should be available.
4843
#
49-
if [[ -n "${DELPHIX_SIGNATURE_TOKEN:-}" ]] && [[ -n "${DELPHIX_SIGNATURE_URL:-}" ]]; then
44+
if [[ -n "${DELPHIX_SIGNATURE_TOKEN:-}" ]] &&
45+
[[ -n "${DELPHIX_SIGNATURE_URL:-}" ]] &&
46+
[[ -n "${DELPHIX_SIGNATURE_VERSION:-}" ]]; then
47+
if [[ -z "$TYPE" ]] || [[ -z "$VERSION" ]]; then
48+
echo "Must specify key 'type' and 'version'."
49+
exit 1
50+
fi
5051
curl -s -S -u "$DELPHIX_SIGNATURE_TOKEN" \
5152
"$DELPHIX_SIGNATURE_URL/$TYPE/keyVersion/$VERSION" |
5253
jq -Mr .publicKey

0 commit comments

Comments
 (0)