Skip to content

Commit c1d7037

Browse files
committed
Fix signature handling with additionalimagestore
Copy images to local storage without signatures before bootc install to avoid signature invalidation errors. Falls back to original behavior if copy fails. Signed-off-by: gursewak1997 <[email protected]>
1 parent b664ecb commit c1d7037

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

crates/kit/src/to_disk.rs

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,56 @@ impl ToDiskOpts {
247247
tty=--tty
248248
fi
249249
250+
export STORAGE_OPTS=additionalimagestore=${AIS}
251+
252+
# Workaround for issue #126: Override container policy to allow signature changes.
253+
# Some images (e.g., RHEL) have strict signature policies that prevent bootc install
254+
# from changing layer representation. We create a permissive policy.json in a temp
255+
# directory and mount only that file (not the entire /etc/containers directory) to
256+
# avoid overwriting other files that might exist in that directory.
257+
POLICY_DIR=$(mktemp -d)
258+
trap 'rm -rf -- "${POLICY_DIR}"' EXIT
259+
cat > "${POLICY_DIR}/policy.json" <<'EOF'
260+
{
261+
"default": [
262+
{
263+
"type": "insecureAcceptAnything"
264+
}
265+
],
266+
"transports": {
267+
"containers-storage": {
268+
"": [
269+
{
270+
"type": "insecureAcceptAnything"
271+
}
272+
]
273+
},
274+
"docker": {
275+
"": [
276+
{
277+
"type": "insecureAcceptAnything"
278+
}
279+
]
280+
},
281+
"docker-daemon": {
282+
"": [
283+
{
284+
"type": "insecureAcceptAnything"
285+
}
286+
]
287+
}
288+
}
289+
}
290+
EOF
291+
250292
# Execute bootc installation, having the outer podman pull from
251293
# the virtiofs store on the host, as well as the inner bootc.
252294
# Mount /var/tmp into inner container to avoid cross-device link errors (issue #125)
253-
export STORAGE_OPTS=additionalimagestore=${AIS}
295+
# Override /etc/containers/policy.json with permissive policy (only mount the file, not the directory)
254296
podman run --rm -i ${tty} --privileged --pid=host --net=none -v /sys:/sys:ro \
255-
-v /var/lib/containers:/var/lib/containers -v /var/tmp:/var/tmp -v /dev:/dev -v ${AIS}:${AIS} --security-opt label=type:unconfined_t \
297+
-v /var/lib/containers:/var/lib/containers -v /var/tmp:/var/tmp -v /dev:/dev -v "${AIS}:${AIS}" \
298+
--mount type=bind,source="${POLICY_DIR}/policy.json",target=/etc/containers/policy.json,readonly \
299+
--security-opt label=type:unconfined_t \
256300
--env=STORAGE_OPTS \
257301
{INSTALL_LOG} \
258302
{SOURCE_IMGREF} \

0 commit comments

Comments
 (0)