mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
BREAKING(unstable): drop support for Deno.run.{clearEnv,gid,uid} (#25371)
These are unstable options and the APIs is now deprecated. To limit amount of unstable flags we elected to have these APIs removed.
This commit is contained in:
parent
bf7571a6f9
commit
71e4ac774b
4 changed files with 2 additions and 123 deletions
|
@ -133,10 +133,7 @@ class Process {
|
||||||
function run({
|
function run({
|
||||||
cmd,
|
cmd,
|
||||||
cwd = undefined,
|
cwd = undefined,
|
||||||
clearEnv = false,
|
|
||||||
env = { __proto__: null },
|
env = { __proto__: null },
|
||||||
gid = undefined,
|
|
||||||
uid = undefined,
|
|
||||||
stdout = "inherit",
|
stdout = "inherit",
|
||||||
stderr = "inherit",
|
stderr = "inherit",
|
||||||
stdin = "inherit",
|
stdin = "inherit",
|
||||||
|
@ -155,10 +152,7 @@ function run({
|
||||||
const res = opRun({
|
const res = opRun({
|
||||||
cmd: ArrayPrototypeMap(cmd, String),
|
cmd: ArrayPrototypeMap(cmd, String),
|
||||||
cwd,
|
cwd,
|
||||||
clearEnv,
|
|
||||||
env: ObjectEntries(env),
|
env: ObjectEntries(env),
|
||||||
gid,
|
|
||||||
uid,
|
|
||||||
stdin,
|
stdin,
|
||||||
stdout,
|
stdout,
|
||||||
stderr,
|
stderr,
|
||||||
|
|
|
@ -99,10 +99,11 @@ pub static UNSTABLE_GRANULAR_FLAGS: &[UnstableGranularFlag] = &[
|
||||||
show_in_help: true,
|
show_in_help: true,
|
||||||
id: 7,
|
id: 7,
|
||||||
},
|
},
|
||||||
|
// TODO(bartlomieju): consider removing it
|
||||||
UnstableGranularFlag {
|
UnstableGranularFlag {
|
||||||
name: ops::process::UNSTABLE_FEATURE_NAME,
|
name: ops::process::UNSTABLE_FEATURE_NAME,
|
||||||
help_text: "Enable unstable process APIs",
|
help_text: "Enable unstable process APIs",
|
||||||
show_in_help: true,
|
show_in_help: false,
|
||||||
id: 8,
|
id: 8,
|
||||||
},
|
},
|
||||||
UnstableGranularFlag {
|
UnstableGranularFlag {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use super::check_unstable;
|
|
||||||
use deno_core::anyhow::Context;
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::type_error;
|
use deno_core::error::type_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
@ -642,12 +641,7 @@ mod deprecated {
|
||||||
pub struct RunArgs {
|
pub struct RunArgs {
|
||||||
cmd: Vec<String>,
|
cmd: Vec<String>,
|
||||||
cwd: Option<String>,
|
cwd: Option<String>,
|
||||||
clear_env: bool,
|
|
||||||
env: Vec<(String, String)>,
|
env: Vec<(String, String)>,
|
||||||
#[cfg(unix)]
|
|
||||||
gid: Option<u32>,
|
|
||||||
#[cfg(unix)]
|
|
||||||
uid: Option<u32>,
|
|
||||||
stdin: StdioOrRid,
|
stdin: StdioOrRid,
|
||||||
stdout: StdioOrRid,
|
stdout: StdioOrRid,
|
||||||
stderr: StdioOrRid,
|
stderr: StdioOrRid,
|
||||||
|
@ -700,24 +694,10 @@ mod deprecated {
|
||||||
});
|
});
|
||||||
cwd.map(|d| c.current_dir(d));
|
cwd.map(|d| c.current_dir(d));
|
||||||
|
|
||||||
if run_args.clear_env {
|
|
||||||
super::check_unstable(state, UNSTABLE_FEATURE_NAME, "Deno.run.clearEnv");
|
|
||||||
c.env_clear();
|
|
||||||
}
|
|
||||||
for (key, value) in &env {
|
for (key, value) in &env {
|
||||||
c.env(key, value);
|
c.env(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
if let Some(gid) = run_args.gid {
|
|
||||||
super::check_unstable(state, UNSTABLE_FEATURE_NAME, "Deno.run.gid");
|
|
||||||
c.gid(gid);
|
|
||||||
}
|
|
||||||
#[cfg(unix)]
|
|
||||||
if let Some(uid) = run_args.uid {
|
|
||||||
super::check_unstable(state, UNSTABLE_FEATURE_NAME, "Deno.run.uid");
|
|
||||||
c.uid(uid);
|
|
||||||
}
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
// TODO(bartlomieju):
|
// TODO(bartlomieju):
|
||||||
#[allow(clippy::undocumented_unsafe_blocks)]
|
#[allow(clippy::undocumented_unsafe_blocks)]
|
||||||
|
|
|
@ -582,102 +582,6 @@ Deno.test({ permissions: { run: true, read: true } }, function killFailed() {
|
||||||
p.close();
|
p.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(
|
|
||||||
{ permissions: { run: true, read: true, env: true } },
|
|
||||||
async function clearEnv(): Promise<void> {
|
|
||||||
// deno-lint-ignore no-deprecated-deno-api
|
|
||||||
const p = Deno.run({
|
|
||||||
cmd: [
|
|
||||||
Deno.execPath(),
|
|
||||||
"eval",
|
|
||||||
"-p",
|
|
||||||
"JSON.stringify(Deno.env.toObject())",
|
|
||||||
],
|
|
||||||
stdout: "piped",
|
|
||||||
clearEnv: true,
|
|
||||||
env: {
|
|
||||||
FOO: "23147",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const obj = JSON.parse(new TextDecoder().decode(await p.output()));
|
|
||||||
|
|
||||||
// can't check for object equality because the OS may set additional env
|
|
||||||
// vars for processes, so we check if PATH isn't present as that is a common
|
|
||||||
// env var across OS's and isn't set for processes.
|
|
||||||
assertEquals(obj.FOO, "23147");
|
|
||||||
assert(!("PATH" in obj));
|
|
||||||
|
|
||||||
p.close();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
Deno.test(
|
|
||||||
{
|
|
||||||
permissions: { run: true, read: true },
|
|
||||||
ignore: Deno.build.os === "windows",
|
|
||||||
},
|
|
||||||
async function uid(): Promise<void> {
|
|
||||||
// deno-lint-ignore no-deprecated-deno-api
|
|
||||||
const p = Deno.run({
|
|
||||||
cmd: [
|
|
||||||
"id",
|
|
||||||
"-u",
|
|
||||||
],
|
|
||||||
stdout: "piped",
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentUid = new TextDecoder().decode(await p.output());
|
|
||||||
p.close();
|
|
||||||
|
|
||||||
if (currentUid !== "0") {
|
|
||||||
assertThrows(() => {
|
|
||||||
// deno-lint-ignore no-deprecated-deno-api
|
|
||||||
Deno.run({
|
|
||||||
cmd: [
|
|
||||||
"echo",
|
|
||||||
"fhqwhgads",
|
|
||||||
],
|
|
||||||
uid: 0,
|
|
||||||
});
|
|
||||||
}, Deno.errors.PermissionDenied);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
Deno.test(
|
|
||||||
{
|
|
||||||
permissions: { run: true, read: true },
|
|
||||||
ignore: Deno.build.os === "windows",
|
|
||||||
},
|
|
||||||
async function gid(): Promise<void> {
|
|
||||||
// deno-lint-ignore no-deprecated-deno-api
|
|
||||||
const p = Deno.run({
|
|
||||||
cmd: [
|
|
||||||
"id",
|
|
||||||
"-g",
|
|
||||||
],
|
|
||||||
stdout: "piped",
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentGid = new TextDecoder().decode(await p.output());
|
|
||||||
p.close();
|
|
||||||
|
|
||||||
if (currentGid !== "0") {
|
|
||||||
assertThrows(() => {
|
|
||||||
// deno-lint-ignore no-deprecated-deno-api
|
|
||||||
Deno.run({
|
|
||||||
cmd: [
|
|
||||||
"echo",
|
|
||||||
"fhqwhgads",
|
|
||||||
],
|
|
||||||
gid: 0,
|
|
||||||
});
|
|
||||||
}, Deno.errors.PermissionDenied);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{
|
{
|
||||||
permissions: { run: true, read: true, write: true },
|
permissions: { run: true, read: true, write: true },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue