diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-01-07 17:25:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-07 17:25:34 +0100 |
commit | fac64478157ee563b185edb5734688e4523df3a1 (patch) | |
tree | 888d562982e1fc37dfb9a4459928bcec84d55dfc /runtime/ops/spawn.rs | |
parent | 82e930726ee5dbac8e6eae0962c07c72daf9843c (diff) |
refactor(permissions): add PermissionsContainer struct for internal mutability (#17134)
Turns out we were cloning permissions which after prompting were discarded,
so the state of permissions was never preserved. To handle that we need to store
all permissions behind "Arc<Mutex<>>" (because there are situations where we
need to send them to other thread).
Testing and benching code still uses "Permissions" in most places - it's undesirable
to share the same permission set between various test/bench files - otherwise
granting or revoking permissions in one file would influence behavior of other test
files.
Diffstat (limited to 'runtime/ops/spawn.rs')
-rw-r--r-- | runtime/ops/spawn.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/runtime/ops/spawn.rs b/runtime/ops/spawn.rs index 11940013c..4bbf1ef48 100644 --- a/runtime/ops/spawn.rs +++ b/runtime/ops/spawn.rs @@ -5,7 +5,7 @@ use super::io::ChildStdinResource; use super::io::ChildStdoutResource; use super::process::Stdio; use super::process::StdioOrRid; -use crate::permissions::Permissions; +use crate::permissions::PermissionsContainer; use deno_core::error::AnyError; use deno_core::op; use deno_core::Extension; @@ -131,9 +131,8 @@ fn node_unstable_create_command( api_name: &str, ) -> Result<std::process::Command, AnyError> { state - .borrow_mut::<Permissions>() - .run - .check(&args.cmd, Some(api_name))?; + .borrow_mut::<PermissionsContainer>() + .check_run(&args.cmd, api_name)?; let mut command = std::process::Command::new(args.cmd); @@ -196,9 +195,8 @@ fn create_command( ) -> Result<std::process::Command, AnyError> { super::check_unstable(state, "Deno.spawn"); state - .borrow_mut::<Permissions>() - .run - .check(&args.cmd, Some(api_name))?; + .borrow_mut::<PermissionsContainer>() + .check_run(&args.cmd, api_name)?; let mut command = std::process::Command::new(args.cmd); |