Skip to content

Commit 9fc82b9

Browse files
committed
Raise ENOSYS if AT_SYMLINK_NOFOLLOW is used with chmod or chown in nodefs
1 parent 25dea46 commit 9fc82b9

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/library_fs.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,8 @@ FS.staticInit();
972972
}
973973
node.node_ops.setattr(node, {
974974
mode: (mode & {{{ cDefs.S_IALLUGO }}}) | (node.mode & ~{{{ cDefs.S_IALLUGO }}}),
975-
ctime: Date.now()
975+
ctime: Date.now(),
976+
dontFollow
976977
});
977978
},
978979
lchmod(path, mode) {
@@ -994,7 +995,8 @@ FS.staticInit();
994995
throw new FS.ErrnoError({{{ cDefs.EPERM }}});
995996
}
996997
node.node_ops.setattr(node, {
997-
timestamp: Date.now()
998+
timestamp: Date.now(),
999+
dontFollow
9981000
// we ignore the uid / gid for now
9991001
});
10001002
},

src/library_nodefs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ addToLibrary({
153153
};
154154
},
155155
setattr(node, attr) {
156+
if (attr.dontFollow) {
157+
throw new FS.ErrnoError({{{ cDefs.ENOSYS }}});
158+
}
156159
var path = NODEFS.realPath(node);
157160
NODEFS.tryFSOperation(() => {
158161
if (attr.mode !== undefined) {

test/stat/test_chmod.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ void test() {
9393
err = fchmodat(AT_FDCWD, "otherfile", S_IXUSR, 0);
9494
assert(!err);
9595

96+
assert(symlink("otherfile", "link") == 0);
97+
err = fchmodat(AT_FDCWD, "link", S_IXGRP, AT_SYMLINK_NOFOLLOW);
98+
#if defined(NODEFS) || defined(NODERAWFS)
99+
assert(err == -1);
100+
assert(errno == ENOTSUP);
101+
#else
102+
assert(err == 0);
103+
#endif
104+
96105
memset(&s, 0, sizeof s);
97106
stat("otherfile", &s);
98107
assert(s.st_mode == (S_IXUSR | S_IFREG));

test/test_core.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5524,8 +5524,7 @@ def test_fstatat(self):
55245524
self.do_runf('stat/test_fstatat.c', 'success')
55255525

55265526
@crossplatform
5527-
@also_with_wasmfs
5528-
@also_with_noderawfs
5527+
@with_all_fs
55295528
def test_stat_chmod(self):
55305529
if self.get_setting('NODERAWFS') and WINDOWS:
55315530
self.skipTest('mode bits work differently on windows')

0 commit comments

Comments
 (0)