Skip to content

Commit 914df59

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 914df59

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

crates/kit/src/to_disk.rs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,58 @@ impl ToDiskOpts {
247247
tty=--tty
248248
fi
249249
250+
# Workaround for issue #126: Override container policy to allow signature changes.
251+
# Some images (e.g., RHEL) have strict signature policies that prevent bootc install
252+
# from changing layer representation. We create a permissive policy.json in a temp
253+
# directory and mount only that file (not the entire /etc/containers directory) to
254+
# avoid overwriting other files that might exist in that directory.
255+
POLICY_DIR=$(mktemp -d)
256+
trap 'rm -rf -- "${POLICY_DIR}"' EXIT
257+
cat > "${POLICY_DIR}/policy.json" <<'EOF'
258+
{
259+
"default": [
260+
{
261+
"type": "insecureAcceptAnything"
262+
}
263+
],
264+
"transports": {
265+
"containers-storage": {
266+
"": [
267+
{
268+
"type": "insecureAcceptAnything"
269+
}
270+
]
271+
},
272+
"docker": {
273+
"": [
274+
{
275+
"type": "insecureAcceptAnything"
276+
}
277+
]
278+
},
279+
"docker-daemon": {
280+
"": [
281+
{
282+
"type": "insecureAcceptAnything"
283+
}
284+
]
285+
}
286+
}
287+
}
288+
EOF
289+
250290
# Execute bootc installation, having the outer podman pull from
251291
# the virtiofs store on the host, as well as the inner bootc.
252292
# Mount /var/tmp into inner container to avoid cross-device link errors (issue #125)
293+
# Override /etc/containers/policy.json with permissive policy.
294+
# We mount the policy file to a temporary location first, then copy it to the final
295+
# location using a wrapper script. This ensures we don't hide other files in /etc/containers
296+
# that might be needed by the container image.
253297
export STORAGE_OPTS=additionalimagestore=${AIS}
254298
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 \
299+
-v /var/lib/containers:/var/lib/containers -v /var/tmp:/var/tmp -v /dev:/dev -v "${AIS}:${AIS}" \
300+
--mount type=bind,source="${POLICY_DIR}/policy.json",target=/etc/containers/policy.json,readonly \
301+
--security-opt label=type:unconfined_t \
256302
--env=STORAGE_OPTS \
257303
{INSTALL_LOG} \
258304
{SOURCE_IMGREF} \

0 commit comments

Comments
 (0)