permission: block FileHandle fsync and fdatasync · nodejs/node@847fe4d · GitHub
Skip to content

Commit 847fe4d

Browse files
RafaelGSSaduh95
authored andcommitted
permission: block FileHandle fsync and fdatasync
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: #65431 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 79509c2 commit 847fe4d

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎doc/api/permissions.md‎

Lines changed: 8 additions & 0 deletions

‎lib/internal/fs/promises.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,9 @@ async function rmdir(path, options) {
15351535
}
15361536

15371537
async function fdatasync(handle) {
1538+
if (permission.isEnabled()) {
1539+
throw new ERR_ACCESS_DENIED('fdatasync API is disabled when Permission Model is enabled.');
1540+
}
15381541
return await PromisePrototypeThen(
15391542
binding.fdatasync(handle.fd, kUsePromises),
15401543
undefined,
@@ -1543,6 +1546,9 @@ async function fdatasync(handle) {
15431546
}
15441547

15451548
async function fsync(handle) {
1549+
if (permission.isEnabled()) {
1550+
throw new ERR_ACCESS_DENIED('fsync API is disabled when Permission Model is enabled.');
1551+
}
15461552
return await PromisePrototypeThen(
15471553
binding.fsync(handle.fd, kUsePromises),
15481554
undefined,
Lines changed: 33 additions & 0 deletions

0 commit comments

Comments
 (0)