diff --git a/userspace/ksud/src/utils.rs b/userspace/ksud/src/utils.rs index 51b48b3a..a3badc96 100644 --- a/userspace/ksud/src/utils.rs +++ b/userspace/ksud/src/utils.rs @@ -299,8 +299,19 @@ pub fn copy_module_files(source: impl AsRef, destination: impl AsRef log::info!("Symlink: {:?} -> {:?}", dest_path, target); std::os::unix::fs::symlink(target, &dest_path).context("Failed to create symlink")?; 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() { 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)?; } else if entry.file_type().is_char_device() { if dest_path.exists() {