Skip to content

Commit e25b44d

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 <gursmangat@gmail.com>
1 parent b664ecb commit e25b44d

File tree

1 file changed

+49
-3
lines changed

1 file changed

+49
-3
lines changed

crates/kit/src/to_disk.rs

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,61 @@ 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+
SOURCE_REF={SOURCE_IMGREF}
256+
257+
# Create permissive policy.json (use /var/tmp since it's mounted into podman container)
258+
# Mount as directory to /etc/containers so podman creates the directory if it doesn't exist
259+
POLICY_DIR=/var/tmp/bcvk-policy-dir
260+
mkdir -p "${POLICY_DIR}"
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 only /etc/containers/policy.json with permissive policy (preserves other config)
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+
-v "${POLICY_DIR}/policy.json:/etc/containers/policy.json:ro" \
301+
--security-opt label=type:unconfined_t \
256302
--env=STORAGE_OPTS \
257303
{INSTALL_LOG} \
258-
{SOURCE_IMGREF} \
304+
"${SOURCE_REF}" \
259305
bootc install to-disk \
260306
--generic-image \
261307
--skip-fetch-check \

0 commit comments

Comments
 (0)