summaryrefslogtreecommitdiffstats
path: root/classes/image-oci-umoci.inc
diff options
context:
space:
mode:
authorTim Orling <tim.orling@konsulko.com>2026-05-02 14:01:40 -0700
committerBruce Ashfield <bruce.ashfield@gmail.com>2026-05-11 20:11:22 +0000
commitf7eb4abba27a54c06432cca45f817f21f5754532 (patch)
tree7377ef0f04e9536a944d64c17569ef0a84ccb8e0 /classes/image-oci-umoci.inc
parent7ab697991c867dfd9da5704e3ca71f633faf476b (diff)
downloadmeta-virtualization-f7eb4abba27a54c06432cca45f817f21f5754532.tar.gz
image-oci: don't preserve ownership in directories/files/host layer copies
The multi-layer 'directories', 'files', and 'host' branches in IMAGE_CMD:oci copy delta content into the OCI bundle rootfs with 'cp -a'. 'cp -a' implies '--preserve=all', which calls lchown() on the destination to copy ownership from the source. When a directories/files layer copies a symbolic link whose target does not exist at build time (for example, the '/dev/stdout' and '/dev/stderr' log forwarding symlinks used by the official nginx Docker image), lchown() can return EINVAL under pseudo and 'cp' aborts with: cp: failed to preserve ownership for .../var/log/nginx/access.log: Invalid argument failing the whole do_image_oci task. The single-layer rootfs copy already handles this correctly: cp -r -a --no-preserve=ownership ${IMAGE_ROOTFS}/* $image_bundle_name/rootfs and the multi-layer 'packages' branch uses 'rsync -a --no-owner --no-group' for the same reason. Bring the three remaining cp -a sites in line by adding '--no-preserve=ownership'. Ownership inside an OCI image is set by umoci based on the image config and source ownership has no meaning for symlinks to runtime device nodes anyway, so dropping preservation is the correct behaviour. Reproduce: declare a directories: layer that copies a path containing a symlink to '/dev/stdout' or '/dev/stderr' (e.g. a postprocess that creates /var/log/nginx/{access,error}.log -> /dev/{stdout,stderr} to mirror the upstream nginx Docker image). Signed-off-by: Tim Orling <tim.orling@konsulko.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'classes/image-oci-umoci.inc')
-rw-r--r--classes/image-oci-umoci.inc6
1 files changed, 3 insertions, 3 deletions
diff --git a/classes/image-oci-umoci.inc b/classes/image-oci-umoci.inc
index bad6c5d0..a033d73a 100644
--- a/classes/image-oci-umoci.inc
+++ b/classes/image-oci-umoci.inc
@@ -611,7 +611,7 @@ IMAGE_CMD:oci() {
611 oci_dst_file="$image_bundle_name/rootfs$oci_rel_path" 611 oci_dst_file="$image_bundle_name/rootfs$oci_rel_path"
612 if [ ! -e "$oci_dst_file" ]; then 612 if [ ! -e "$oci_dst_file" ]; then
613 mkdir -p "$(dirname "$oci_dst_file")" 613 mkdir -p "$(dirname "$oci_dst_file")"
614 cp -a "$oci_src_file" "$oci_dst_file" 614 cp -a --no-preserve=ownership "$oci_src_file" "$oci_dst_file"
615 oci_delta_copied=$(expr $oci_delta_copied + 1) 615 oci_delta_copied=$(expr $oci_delta_copied + 1)
616 else 616 else
617 oci_delta_skipped=$(expr $oci_delta_skipped + 1) 617 oci_delta_skipped=$(expr $oci_delta_skipped + 1)
@@ -638,7 +638,7 @@ IMAGE_CMD:oci() {
638 oci_dst_file="$image_bundle_name/rootfs$oci_file" 638 oci_dst_file="$image_bundle_name/rootfs$oci_file"
639 if [ ! -e "$oci_dst_file" ]; then 639 if [ ! -e "$oci_dst_file" ]; then
640 mkdir -p "$(dirname "$oci_dst_file")" 640 mkdir -p "$(dirname "$oci_dst_file")"
641 cp -a "${IMAGE_ROOTFS}$oci_file" "$oci_dst_file" 641 cp -a --no-preserve=ownership "${IMAGE_ROOTFS}$oci_file" "$oci_dst_file"
642 bbnote "OCI: Added file $oci_file" 642 bbnote "OCI: Added file $oci_file"
643 else 643 else
644 bbnote "OCI: Skipped file $oci_file (already in bundle)" 644 bbnote "OCI: Skipped file $oci_file (already in bundle)"
@@ -657,7 +657,7 @@ IMAGE_CMD:oci() {
657 oci_host_dst="${oci_host_pair##*:}" 657 oci_host_dst="${oci_host_pair##*:}"
658 if [ -e "$oci_host_src" ]; then 658 if [ -e "$oci_host_src" ]; then
659 mkdir -p "$image_bundle_name/rootfs$(dirname $oci_host_dst)" 659 mkdir -p "$image_bundle_name/rootfs$(dirname $oci_host_dst)"
660 cp -a "$oci_host_src" "$image_bundle_name/rootfs$oci_host_dst" 660 cp -a --no-preserve=ownership "$oci_host_src" "$image_bundle_name/rootfs$oci_host_dst"
661 bbnote "OCI: Added from host: $oci_host_src -> $oci_host_dst" 661 bbnote "OCI: Added from host: $oci_host_src -> $oci_host_dst"
662 else 662 else
663 bbfatal "OCI: Host path not found: $oci_host_src" 663 bbfatal "OCI: Host path not found: $oci_host_src"