Merge pull request #10976 from zvonkok/fix-dev-permissions

agent: Fix default linux device permissions
This commit is contained in:
Fabiano Fidêncio 2025-03-05 13:54:06 +01:00 committed by GitHub
commit 504d9e2b66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1016,10 +1016,17 @@ fn mknod_dev(dev: &LinuxDevice, relpath: &Path) -> Result<()> {
None => return Err(anyhow!("invalid spec".to_string())),
};
let file_mode = dev
.file_mode()
// drop the mode if it is 0
.filter(|&m| m != 0)
// fall back to 0o666
.unwrap_or(0o666);
stat::mknod(
relpath,
*f,
Mode::from_bits_truncate(dev.file_mode().unwrap_or(0)),
Mode::from_bits_truncate(file_mode),
nix::sys::stat::makedev(dev.major() as u64, dev.minor() as u64),
)?;