Skip to content

Commit e68793b

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 e68793b

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

crates/kit/src/to_disk.rs

Lines changed: 48 additions & 2 deletions
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 override /etc/containers/policy.json with
253+
# a permissive policy that allows all operations.
254+
export STORAGE_OPTS=additionalimagestore=${AIS}
255+
256+
# Create permissive policy.json in a temp directory
257+
# We mount only the policy.json file (not the entire /etc/containers directory)
258+
# to avoid overwriting other files that might exist in that directory.
259+
POLICY_DIR=$(mktemp -d)
260+
trap 'rm -rf -- "${POLICY_DIR}"' EXIT
261+
cat > "${POLICY_DIR}/policy.json" <<'EOF'
262+
{
263+
"default": [
264+
{
265+
"type": "insecureAcceptAnything"
266+
}
267+
],
268+
"transports": {
269+
"containers-storage": {
270+
"": [
271+
{
272+
"type": "insecureAcceptAnything"
273+
}
274+
]
275+
},
276+
"docker": {
277+
"": [
278+
{
279+
"type": "insecureAcceptAnything"
280+
}
281+
]
282+
},
283+
"docker-daemon": {
284+
"": [
285+
{
286+
"type": "insecureAcceptAnything"
287+
}
288+
]
289+
}
290+
}
291+
}
292+
EOF
293+
250294
# Execute bootc installation, having the outer podman pull from
251295
# the virtiofs store on the host, as well as the inner bootc.
252296
# Mount /var/tmp into inner container to avoid cross-device link errors (issue #125)
253-
export STORAGE_OPTS=additionalimagestore=${AIS}
297+
# Override /etc/containers/policy.json with permissive policy (only mount the file, not the directory)
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)