mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 16:49:18 -05:00
feat(runtime): stabilize Deno.link and Deno.linkSync (#9417)
This commit makes "Deno.link" and "Deno.linkSync" stable. The permission required has been changed to read-write to ensure one cannot escape the sandbox.
This commit is contained in:
parent
cdae4423c2
commit
aa47f8186c
5 changed files with 27 additions and 29 deletions
|
@ -44,8 +44,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
|
||||||
"ftruncateSync",
|
"ftruncateSync",
|
||||||
"hostname",
|
"hostname",
|
||||||
"kill",
|
"kill",
|
||||||
"link",
|
|
||||||
"linkSync",
|
|
||||||
"listen",
|
"listen",
|
||||||
"listenDatagram",
|
"listenDatagram",
|
||||||
"loadavg",
|
"loadavg",
|
||||||
|
|
21
cli/dts/lib.deno.ns.d.ts
vendored
21
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -265,6 +265,27 @@ declare namespace Deno {
|
||||||
*/
|
*/
|
||||||
export function cwd(): string;
|
export function cwd(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synchronously creates `newpath` as a hard link to `oldpath`.
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* Deno.linkSync("old/name", "new/name");
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Requires `allow-read` and `allow-write` permissions. */
|
||||||
|
export function linkSync(oldpath: string, newpath: string): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Creates `newpath` as a hard link to `oldpath`.
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* await Deno.link("old/name", "new/name");
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Requires `allow-read` and `allow-write` permissions. */
|
||||||
|
export function link(oldpath: string, newpath: string): Promise<void>;
|
||||||
|
|
||||||
export enum SeekMode {
|
export enum SeekMode {
|
||||||
Start = 0,
|
Start = 0,
|
||||||
Current = 1,
|
Current = 1,
|
||||||
|
|
22
cli/dts/lib.deno.unstable.d.ts
vendored
22
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -21,28 +21,6 @@ declare namespace Deno {
|
||||||
*/
|
*/
|
||||||
export function umask(mask?: number): number;
|
export function umask(mask?: number): number;
|
||||||
|
|
||||||
/** **UNSTABLE**: This API needs a security review.
|
|
||||||
*
|
|
||||||
* Synchronously creates `newpath` as a hard link to `oldpath`.
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* Deno.linkSync("old/name", "new/name");
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Requires `allow-read` and `allow-write` permissions. */
|
|
||||||
export function linkSync(oldpath: string, newpath: string): void;
|
|
||||||
|
|
||||||
/** **UNSTABLE**: This API needs a security review.
|
|
||||||
*
|
|
||||||
* Creates `newpath` as a hard link to `oldpath`.
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* await Deno.link("old/name", "new/name");
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Requires `allow-read` and `allow-write` permissions. */
|
|
||||||
export function link(oldpath: string, newpath: string): Promise<void>;
|
|
||||||
|
|
||||||
/** **UNSTABLE**: New API, yet to be vetted.
|
/** **UNSTABLE**: New API, yet to be vetted.
|
||||||
*
|
*
|
||||||
* Gets the size of the console as columns/rows.
|
* Gets the size of the console as columns/rows.
|
||||||
|
|
|
@ -88,6 +88,8 @@
|
||||||
fsync: __bootstrap.fs.fsync,
|
fsync: __bootstrap.fs.fsync,
|
||||||
fdatasyncSync: __bootstrap.fs.fdatasyncSync,
|
fdatasyncSync: __bootstrap.fs.fdatasyncSync,
|
||||||
fdatasync: __bootstrap.fs.fdatasync,
|
fdatasync: __bootstrap.fs.fdatasync,
|
||||||
|
link: __bootstrap.fs.link,
|
||||||
|
linkSync: __bootstrap.fs.linkSync,
|
||||||
permissions: __bootstrap.permissions.permissions,
|
permissions: __bootstrap.permissions.permissions,
|
||||||
Permissions: __bootstrap.permissions.Permissions,
|
Permissions: __bootstrap.permissions.Permissions,
|
||||||
PermissionStatus: __bootstrap.permissions.PermissionStatus,
|
PermissionStatus: __bootstrap.permissions.PermissionStatus,
|
||||||
|
@ -122,8 +124,6 @@
|
||||||
ftruncateSync: __bootstrap.fs.ftruncateSync,
|
ftruncateSync: __bootstrap.fs.ftruncateSync,
|
||||||
ftruncate: __bootstrap.fs.ftruncate,
|
ftruncate: __bootstrap.fs.ftruncate,
|
||||||
umask: __bootstrap.fs.umask,
|
umask: __bootstrap.fs.umask,
|
||||||
link: __bootstrap.fs.link,
|
|
||||||
linkSync: __bootstrap.fs.linkSync,
|
|
||||||
futime: __bootstrap.fs.futime,
|
futime: __bootstrap.fs.futime,
|
||||||
futimeSync: __bootstrap.fs.futimeSync,
|
futimeSync: __bootstrap.fs.futimeSync,
|
||||||
utime: __bootstrap.fs.utime,
|
utime: __bootstrap.fs.utime,
|
||||||
|
|
|
@ -1140,13 +1140,14 @@ fn op_link_sync(
|
||||||
args: Value,
|
args: Value,
|
||||||
_zero_copy: &mut [ZeroCopyBuf],
|
_zero_copy: &mut [ZeroCopyBuf],
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
super::check_unstable(state, "Deno.link");
|
|
||||||
let args: LinkArgs = serde_json::from_value(args)?;
|
let args: LinkArgs = serde_json::from_value(args)?;
|
||||||
let oldpath = PathBuf::from(&args.oldpath);
|
let oldpath = PathBuf::from(&args.oldpath);
|
||||||
let newpath = PathBuf::from(&args.newpath);
|
let newpath = PathBuf::from(&args.newpath);
|
||||||
|
|
||||||
let permissions = state.borrow::<Permissions>();
|
let permissions = state.borrow::<Permissions>();
|
||||||
permissions.check_read(&oldpath)?;
|
permissions.check_read(&oldpath)?;
|
||||||
|
permissions.check_write(&oldpath)?;
|
||||||
|
permissions.check_read(&newpath)?;
|
||||||
permissions.check_write(&newpath)?;
|
permissions.check_write(&newpath)?;
|
||||||
|
|
||||||
debug!("op_link_sync {} {}", oldpath.display(), newpath.display());
|
debug!("op_link_sync {} {}", oldpath.display(), newpath.display());
|
||||||
|
@ -1159,8 +1160,6 @@ async fn op_link_async(
|
||||||
args: Value,
|
args: Value,
|
||||||
_zero_copy: BufVec,
|
_zero_copy: BufVec,
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
super::check_unstable2(&state, "Deno.link");
|
|
||||||
|
|
||||||
let args: LinkArgs = serde_json::from_value(args)?;
|
let args: LinkArgs = serde_json::from_value(args)?;
|
||||||
let oldpath = PathBuf::from(&args.oldpath);
|
let oldpath = PathBuf::from(&args.oldpath);
|
||||||
let newpath = PathBuf::from(&args.newpath);
|
let newpath = PathBuf::from(&args.newpath);
|
||||||
|
@ -1169,6 +1168,8 @@ async fn op_link_async(
|
||||||
let state = state.borrow();
|
let state = state.borrow();
|
||||||
let permissions = state.borrow::<Permissions>();
|
let permissions = state.borrow::<Permissions>();
|
||||||
permissions.check_read(&oldpath)?;
|
permissions.check_read(&oldpath)?;
|
||||||
|
permissions.check_write(&oldpath)?;
|
||||||
|
permissions.check_read(&newpath)?;
|
||||||
permissions.check_write(&newpath)?;
|
permissions.check_write(&newpath)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue