rpm-ostree/0001-composepost-Handle-existing-absolute-symlinks.patch

43 lines
1.4 KiB
Diff

From 37ae5546dad6df1897cc3d903add5cecd09bc47f Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Thu, 24 Nov 2022 12:56:37 -0500
Subject: [PATCH] composepost: Handle existing absolute symlinks
Regression from cap-std porting around absolute symlinks *again*.
The `try_exists()` API will follow symlinks, which is not what
we want here.
This was hit in the fedora-iot builds.
---
rust/src/composepost.rs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/rust/src/composepost.rs b/rust/src/composepost.rs
index bbe49a2e..77dfcc07 100644
--- a/rust/src/composepost.rs
+++ b/rust/src/composepost.rs
@@ -344,13 +344,18 @@ fn compose_postprocess_units(rootfs_dfd: &Dir, treefile: &mut Treefile) -> Resul
for unit in units {
let dest = multiuser_wants.join(unit);
- if rootfs_dfd.try_exists(&dest)? {
+ if rootfs_dfd
+ .symlink_metadata_optional(&dest)
+ .with_context(|| format!("Querying {unit}"))?
+ .is_some()
+ {
continue;
}
println!("Adding {} to multi-user.target.wants", unit);
let target = format!("/usr/lib/systemd/system/{unit}");
- cap_primitives::fs::symlink_contents(target, &rootfs_dfd.as_filelike_view(), dest)?;
+ cap_primitives::fs::symlink_contents(target, &rootfs_dfd.as_filelike_view(), dest)
+ .with_context(|| format!("Linking {unit}"))?;
}
Ok(())
}
--
2.38.1