ksud: Copy directory permission mode
This commit is contained in:
@@ -299,8 +299,19 @@ pub fn copy_module_files(source: impl AsRef<Path>, destination: impl AsRef<Path>
|
|||||||
log::info!("Symlink: {:?} -> {:?}", dest_path, target);
|
log::info!("Symlink: {:?} -> {:?}", dest_path, target);
|
||||||
std::os::unix::fs::symlink(target, &dest_path).context("Failed to create symlink")?;
|
std::os::unix::fs::symlink(target, &dest_path).context("Failed to create symlink")?;
|
||||||
copy_xattrs(&source_path, &dest_path)?;
|
copy_xattrs(&source_path, &dest_path)?;
|
||||||
|
let metadata =
|
||||||
|
std::fs::symlink_metadata(&dest_path).context("Failed to read metadata")?;
|
||||||
|
rustix::fs::chmodat(
|
||||||
|
rustix::fs::CWD,
|
||||||
|
&dest_path,
|
||||||
|
metadata.permissions().mode().into(),
|
||||||
|
rustix::fs::AtFlags::SYMLINK_NOFOLLOW,
|
||||||
|
)?;
|
||||||
} else if entry.file_type().is_dir() {
|
} else if entry.file_type().is_dir() {
|
||||||
create_dir_all(&dest_path)?;
|
create_dir_all(&dest_path)?;
|
||||||
|
let metadata = std::fs::metadata(&source_path).context("Failed to read metadata")?;
|
||||||
|
std::fs::set_permissions(&dest_path, metadata.permissions())
|
||||||
|
.with_context(|| format!("Failed to set permissions for {dest_path:?}"))?;
|
||||||
copy_xattrs(&source_path, &dest_path)?;
|
copy_xattrs(&source_path, &dest_path)?;
|
||||||
} else if entry.file_type().is_char_device() {
|
} else if entry.file_type().is_char_device() {
|
||||||
if dest_path.exists() {
|
if dest_path.exists() {
|
||||||
|
|||||||
Reference in New Issue
Block a user