From fb61df35fe107ec8411433cddc53642c2a120564 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Tue, 24 Nov 2026 15:14:25 +0100 Subject: [PATCH] deb: chown the symlinks, not their targets, in the handover The handover pipeline found entries with find, which never dereferences, but chowned them without -h, so chown followed each symlink to its target. A dangling one, which vendored trees carry (skia's fontations/Cargo.toml points into a bazel external that is not shipped), then failed with ENOENT and aborted the handover mid-build. --- src/deb/local.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/deb/local.rs b/src/deb/local.rs index b65bd80..898b662 100644 --- a/src/deb/local.rs +++ b/src/deb/local.rs @@ -408,11 +408,15 @@ fn migrate_ccache_ownership(ccache_host_dir: &Path) { /// (staging, quilt re-application), and the copy-ups of independent files /// parallelize across the chroot's cores. On a resumed tree every entry /// is already owned and the phase collapses to a metadata-only walk. +/// +/// The chown is `-h`: find never dereferences, and plain chown would follow +/// a symlink to its target — a dangling one (vendored trees carry them) +/// then fails with ENOENT and aborts the handover. fn hand_over_script(dir: &str, uid: &str, gid: &str) -> String { format!( "n=$(nproc 2>/dev/null || echo 4); \ find {} \\! -uid {uid} -print0 \ - | xargs -0 -r -P \"$n\" -n 512 chown -- {uid}:{gid}", + | xargs -0 -r -P \"$n\" -n 512 chown -h -- {uid}:{gid}", shlex_quote(dir) ) } @@ -1963,7 +1967,7 @@ mod tests { "{script}" ); assert!(script.contains("xargs -0 -r -P"), "{script}"); - assert!(script.contains("chown -- 64500:64500"), "{script}"); + assert!(script.contains("chown -h -- 64500:64500"), "{script}"); let quoted = hand_over_script("/tmp/some'dir", "1000", "1000"); assert!(