Skip to content

Commit 1b74591

Browse files
committed
podvm: disable cloud-init unsafe modules for CoCo
this is executed when CONFIDENTIAL_COMPUTE_ENABLED=yes or based on the CUSTOM_CLOUD_INIT_MODULES value, if set in either case, this is currently disabled for the libvirt provider Signed-off-by: Snir Sheriber <[email protected]>
1 parent 2156263 commit 1b74591

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

config/peerpods/podvm/lib.sh

+34
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ function prepare_source_code() {
229229
create_overlay_mount_unit
230230
fi
231231

232+
# disable ssh and unsafe cloud-init modules
233+
if [[ "$CONFIDENTIAL_COMPUTE_ENABLED" == "yes" ]] || [[ -n "$CUSTOM_CLOUD_INIT_MODULES" ]]; then
234+
[[ "$CUSTOM_CLOUD_INIT_MODULES" != "no" ]] && [[ "$CLOUD_PROVIDER" != "libvirt" ]] && set_custom_cloud_init_modules
235+
fi
236+
232237
# Validate and copy HKD for IBM Z Secure Enablement
233238
if [[ "$SE_BOOT" == "true" ]]; then
234239
if [[ -z "$HOST_KEY_CERTS" ]]; then
@@ -283,6 +288,35 @@ function download_and_extract_pause_image() {
283288

284289
}
285290

291+
# These are cloud-init modules we allow for the CoCo case, it's mostly used to disable ssh
292+
# and other unsafe modules
293+
function set_custom_cloud_init_modules() {
294+
local cfg_file="${podvm_dir}/files/etc/cloud/cloud.cfg.d/99_coco_only_allow.cfg"
295+
mkdir -p $(dirname "${cfg_file}")
296+
cat <<EOF >"${cfg_file}"
297+
cloud_init_modules:
298+
- migrator
299+
- set_hostname
300+
- update_hostname
301+
302+
cloud_config_modules:
303+
- locale
304+
- rh_subscription
305+
- ntp
306+
- timezone
307+
- disable_ec2_metadata
308+
309+
cloud_final_modules:
310+
#- reset_rmc # needed for ibm power?
311+
#- install_hotplug ?
312+
- phone_home
313+
- final_message
314+
- power_state_change
315+
EOF
316+
echo "sudo cp -a /tmp/files/etc/cloud/cloud.cfg.d/* /etc/cloud/cloud.cfg.d/" >> "${podvm_dir}"/qcow2/copy-files.sh
317+
echo "Inject cloud-init configuration file:" && cat "${cfg_file}"
318+
}
319+
286320
# Function to create overlay mount unit in the podvm files
287321
# this ensures rw (overlay) layer for the container images are in memory (encrypted)
288322
function create_overlay_mount_unit() {

0 commit comments

Comments
 (0)