Skip to content

Commit 00ca840

Browse files
etc-merge: Use rustix::symlinkat
Using cap_std's symlink results in an error if the symlink target is absolute Signed-off-by: Pragyan Poudyal <[email protected]>
1 parent 389a922 commit 00ca840

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/etc-merge/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ use cap_std_ext::dirext::CapStdExtDirExt;
2020
use composefs::fsverity::{FsVerityHashValue, Sha256HashValue, Sha512HashValue};
2121
use composefs::generic_tree::{Directory, Inode, Leaf, LeafContent, Stat};
2222
use composefs::tree::ImageError;
23-
use rustix::fs::{AtFlags, Gid, Uid, XattrFlags, lgetxattr, llistxattr, lsetxattr, readlinkat};
23+
use rustix::fs::{
24+
lgetxattr, llistxattr, lsetxattr, readlinkat, symlinkat, AtFlags, Gid, Uid, XattrFlags,
25+
};
2426

2527
/// Metadata associated with a file, directory, or symlink entry.
2628
#[derive(Debug)]
@@ -627,9 +629,8 @@ fn merge_leaf(
627629
.context(format!("Deleting {file:?}"))?;
628630

629631
if let Some(target) = symlink {
630-
new_etc_fd
631-
.symlink(target.as_ref(), &file)
632-
.context(format!("Creating symlink {file:?}"))?;
632+
// Using rustix's symlinkat here as we might have absolute symlinks which clash with ambient_authority
633+
symlinkat(&**target, new_etc_fd, file).context(format!("Creating symlink {file:?}"))?;
633634
} else {
634635
current_etc_fd
635636
.copy(&file, new_etc_fd, &file)

0 commit comments

Comments
 (0)