summaryrefslogtreecommitdiff
path: root/runtime/ops/process.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-01-07 17:25:34 +0100
committerGitHub <noreply@github.com>2023-01-07 17:25:34 +0100
commitfac64478157ee563b185edb5734688e4523df3a1 (patch)
tree888d562982e1fc37dfb9a4459928bcec84d55dfc /runtime/ops/process.rs
parent82e930726ee5dbac8e6eae0962c07c72daf9843c (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/process.rs')
-rw-r--r--runtime/ops/process.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs
index b831f1338..86ad292b8 100644
--- a/runtime/ops/process.rs
+++ b/runtime/ops/process.rs
@@ -4,7 +4,7 @@ use super::io::ChildStderrResource;
use super::io::ChildStdinResource;
use super::io::ChildStdoutResource;
use super::io::StdFileResource;
-use crate::permissions::Permissions;
+use crate::permissions::PermissionsContainer;
use deno_core::error::AnyError;
use deno_core::op;
@@ -145,9 +145,8 @@ struct RunInfo {
fn op_run(state: &mut OpState, run_args: RunArgs) -> Result<RunInfo, AnyError> {
let args = run_args.cmd;
state
- .borrow_mut::<Permissions>()
- .run
- .check(&args[0], Some("Deno.run()"))?;
+ .borrow_mut::<PermissionsContainer>()
+ .check_run(&args[0], "Deno.run()")?;
let env = run_args.env;
let cwd = run_args.cwd;
@@ -354,9 +353,8 @@ fn op_kill(
api_name: String,
) -> Result<(), AnyError> {
state
- .borrow_mut::<Permissions>()
- .run
- .check_all(Some(&api_name))?;
+ .borrow_mut::<PermissionsContainer>()
+ .check_run_all(&api_name)?;
kill(pid, &signal)?;
Ok(())
}