GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — permission: disable FileHandle utimes with permission model · nodejs/node@cf85d54

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/fs
    • promises.js
  • test/parallel
    • test-permission-fs-filehandle-utimes.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/fs/promises.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/promises.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,9 @@ async function utimes(path, atime, mtime) {
11541154
}
11551155

11561156
async function futimes(handle, atime, mtime) {
1157+
if (permission.isEnabled()) {
1158+
throw new ERR_ACCESS_DENIED('futimes API is disabled when Permission Model is enabled.');
1159+
}
11571160
atime = toUnixTimestamp(atime, 'atime');
11581161
mtime = toUnixTimestamp(mtime, 'mtime');
11591162
return await PromisePrototypeThen(
Collapse file

‎test/parallel/test-permission-fs-filehandle-utimes.js‎

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Flags: --permission --allow-fs-read=*
2+
'use strict';
3+
4+
const common = require('../common');
5+
const { isMainThread } = require('worker_threads');
6+
7+
if (!isMainThread) {
8+
common.skip('This test only works on a main thread');
9+
}
10+
11+
if (!common.hasCrypto) {
12+
common.skip('no crypto');
13+
}
14+
15+
const assert = require('assert');
16+
const { open } = require('fs/promises');
17+
const fixtures = require('../common/fixtures');
18+
19+
const regularFile = fixtures.path('permission', 'deny', 'regular-file.md');
20+
21+
// FileHandle.utimes() must be blocked when the permission model is enabled,
22+
// consistent with fs.futimes() / fs.futimesSync().
23+
(async () => {
24+
const fh = await open(regularFile, 'r');
25+
try {
26+
await assert.rejects(
27+
fh.utimes(Date.now(), Date.now()),
28+
common.expectsError({ code: 'ERR_ACCESS_DENIED' }),
29+
);
30+
} finally {
31+
await fh.close();
32+
}
33+
})().then(common.mustCall());

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.