diff options
Diffstat (limited to 'cli/ops.rs')
-rw-r--r-- | cli/ops.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cli/ops.rs b/cli/ops.rs index ab2284110..7b9500ef8 100644 --- a/cli/ops.rs +++ b/cli/ops.rs @@ -186,6 +186,7 @@ pub fn op_selector_std(inner_type: msg::Any) -> Option<OpCreator> { msg::Any::Accept => Some(op_accept), msg::Any::Chdir => Some(op_chdir), msg::Any::Chmod => Some(op_chmod), + msg::Any::Chown => Some(op_chown), msg::Any::Close => Some(op_close), msg::Any::CopyFile => Some(op_copy_file), msg::Any::Cwd => Some(op_cwd), @@ -869,6 +870,30 @@ fn op_chmod( }) } +fn op_chown( + state: &ThreadSafeState, + base: &msg::Base<'_>, + data: Option<PinnedBuf>, +) -> Box<OpWithError> { + assert!(data.is_none()); + let inner = base.inner_as_chown().unwrap(); + let path = String::from(inner.path().unwrap()); + let uid = inner.uid(); + let gid = inner.gid(); + + if let Err(e) = state.check_write(&path) { + return odd_future(e); + } + + blocking(base.sync(), move || { + debug!("op_chown {}", &path); + match deno_fs::chown(&path, uid, gid) { + Ok(_) => Ok(empty_buf()), + Err(e) => Err(e), + } + }) +} + fn op_open( state: &ThreadSafeState, base: &msg::Base<'_>, |