(f)chmod: add missing isolation checks

This commit is contained in:
Ralf Jung
2026-05-11 13:28:19 +02:00
parent 46d2c71709
commit b37dbc42e7
+12
View File
@@ -863,6 +863,12 @@ fn chmod(&mut self, path_op: &OpTy<'tcx>, mode_op: &OpTy<'tcx>) -> InterpResult<
}
let path = this.read_path_from_c_str(path_ptr)?;
// Reject if isolation is enabled.
if let IsolatedOp::Reject(reject_with) = this.machine.isolated_op {
this.reject_in_isolation("`chmod`", reject_with)?;
return this.set_last_error_and_return_i32(LibcError("EACCES"));
}
let permissions = this.host_permissions_from_mode(mode.try_into().unwrap())?;
if let Err(err) = fs::set_permissions(path, permissions) {
return this.set_last_error_and_return_i32(IoError::HostError(err));
@@ -885,6 +891,12 @@ fn fchmod(&mut self, fd_op: &OpTy<'tcx>, mode_op: &OpTy<'tcx>) -> InterpResult<'
throw_unsup_format!("`fchmod` is only supported on regular files")
};
// Reject if isolation is enabled.
if let IsolatedOp::Reject(reject_with) = this.machine.isolated_op {
this.reject_in_isolation("`fchmod`", reject_with)?;
return this.set_last_error_and_return_i32(LibcError("EACCES"));
}
let permissions = this.host_permissions_from_mode(mode.try_into().unwrap())?;
if let Err(err) = file.file.set_permissions(permissions) {
return this.set_last_error_and_return_i32(IoError::HostError(err));