Skip to content

Commit f10ee36

Browse files
qemu-secex: drop hardcoded 'secex-hostkey' name and inject user-provided file instead
1 parent 688fbb7 commit f10ee36

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/cmd-osbuild

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,21 @@ postprocess_qemu_secex() {
8686
if [ ! -f "${hostkey}" ]; then
8787
fatal "No hostkey and no genprotimgvm provided"
8888
fi
89-
ignition=$(mktemp -p "${tmp_builddir}")
90-
butane -p -d "$(dirname "${hostkey}")" /usr/lib/coreos-assembler/secex-genprotimgvm-scripts/genprotimg.bu -o "${ignition}"
89+
echo "Injecting user-provided hostkey into config"
90+
# shellcheck disable=SC2155
91+
local ignition_cfg=$(mktemp -p "${tmp_builddir}")
92+
local butane_cfg=$(mktemp -p "${tmp_builddir}")
93+
local hostkey_name=$(basename "${hostkey}")
94+
local hostkey_path=$(dirname "${hostkey}")
95+
cp /usr/lib/coreos-assembler/secex-genprotimgvm-scripts/genprotimg.bu "${butane_cfg}"
96+
sed -i 's/HOSTKEY-FILE/'"${hostkey_name}"'/g' "${butane_cfg}"
97+
butane -p -d "${hostkey_path}" "${butane_cfg}" -o "${ignition_cfg}"
9198

9299
cp "/srv/builds/latest/${basearch}/${name}-${build}-qemu.${basearch}.${suffix}" "${genprotimgvm}"
93100
chmod +w "${genprotimgvm}"
94101
genvm_args=("-drive" "if=none,id=hda,file=${genprotimgvm},auto-read-only=off,cache=unsafe" \
95102
"-device" "virtio-blk,drive=hda,bootindex=1")
96-
kola qemuexec -i "${ignition}" -- "${genvm_args[@]}"
103+
kola qemuexec -i "${ignition_cfg}" -- "${genvm_args[@]}"
97104
fi
98105
fi
99106

src/secex-genprotimgvm-scripts/genprotimg.bu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ storage:
1313
- path: /etc/se-hostkeys/ibm-z-hostkey-1
1414
overwrite: true
1515
contents:
16-
local: secex-hostkey
16+
local: HOSTKEY-FILE
1717
- path: /etc/do_genprotimg
1818
overwrite: true
1919
mode: 0755

0 commit comments

Comments
 (0)