rust/passwd: minor cleanup, switch to copy_file_at
This updates file copying to use the newer `copy_file_at` from openat-ext.
This commit is contained in:
parent
86ce9ea1f5
commit
867ba1eba8
@ -102,9 +102,11 @@ fn prepare_pwgrp(rootfs: &openat::Dir, merge_passwd_dir: Option<PathBuf>) -> Res
|
|||||||
|
|
||||||
// Copy the merge's passwd/group to usr/lib (breaking hardlinks).
|
// Copy the merge's passwd/group to usr/lib (breaking hardlinks).
|
||||||
if let Some(ref merge_dir) = merge_passwd_dir {
|
if let Some(ref merge_dir) = merge_passwd_dir {
|
||||||
let merge_file = format!("{}/{}", merge_dir.display(), &filename);
|
{
|
||||||
let tmp_target = format!("/proc/self/fd/{}/{}", rootfs.as_raw_fd(), &usrlib_file_tmp);
|
let current_root = openat::Dir::open("/")?;
|
||||||
std::fs::copy(merge_file, tmp_target)?;
|
let merge_file = format!("{}/{}", merge_dir.display(), &filename);
|
||||||
|
current_root.copy_file_at(&merge_file, rootfs, &usrlib_file_tmp)?;
|
||||||
|
}
|
||||||
rootfs.local_rename(&usrlib_file_tmp, &usrlib_file)?;
|
rootfs.local_rename(&usrlib_file_tmp, &usrlib_file)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user