Report host uid/gid credentials under NODERAWFS#27319
Conversation
b30b265 to
48377fc
Compare
| #else | ||
| // Every other backend reports 0. | ||
| assert(getuid() == 0); | ||
| assert(geteuid() == 0); |
There was a problem hiding this comment.
Aren't these already tested in test/unistd/misc.c?
There was a problem hiding this comment.
Good point, removed that branch to just test the NODERAWFS path only.
getuid/geteuid/getgid/getegid report the real host process credentials under NODERAWFS (via node's process.get*id()), rather than always 0. These move from weak C stubs to the JS syscall layer, since a weak C definition would otherwise win over the JS override and the syscall would keep returning 0. Other backends (and Windows, which has no uid/gid concept) continue to report 0. The set* variants remain EPERM: musl routes them through __setxid, which emscripten stubs out because it relies on dynamic (numeric) syscall dispatch. Adds test/fs coverage across MEMFS/NODEFS/NODERAWFS: test_fs_getuid.
48377fc to
bbf2ad2
Compare
| # The default backends report 0 and are covered by unistd/misc.c. This test | ||
| # verifies NODERAWFS reports the real host process credentials. | ||
| self.setup_noderawfs_test() | ||
| self.do_runf('fs/test_getuid.c', 'done\n') |
There was a problem hiding this comment.
Maybe rename the test and the source file test_getuid_noderaws?
|
Would it make more sense to do this under |
I'm not sure. These uid/gid settings seems like they should probably also go hand in hard with |
|
I see. I thought that decoupling it from emscripten/src/lib/libsyscall.js Lines 331 to 333 in bd5b72d That would make me assume that Lines 89 to 91 in bd5b72d (i.e. && WASMFS == 0 always evaluates to true)
That said, adding new features like this (and 16fa2c6) only to the legacy JS filesystem would make it more difficult to enable |
While its true that extending the old FS makes more work for the WASMFS transition, I don't think that means we shouldn't do it. I think we are still at the point where its reasonable for some folks to work on the old FS (and make changes like this) while other try to improve WASMFS. I'm personally not 100% convinced the WASMFS even makes sense for NODERAWFS case. For example there is no point the WASMFS in-memory FS cache when using NODERAWFS.. we just want the system calls to be mapped as directly ass possible to the OS in this case. |
Reports the real host process credentials for
getuid/geteuid/getgid/getegidunder NODERAWFS (via node'sprocess.get*id()), rather than the hardcoded0.These move from weak C stubs into the JS syscall layer, since a weak C definition otherwise wins over the JS override and the syscall would keep returning
0. Other backends — and Windows, which has no uid/gid concept — continue to report0. Theset*variants stayEPERM: musl routes them all through__setxid, which emscripten stubs out because it relies on dynamic (numeric) syscall dispatch that the compile-time syscall mapping can't provide.Tested across MEMFS/NODEFS/NODERAWFS (
test_fs_getuid).Made with AI assistance under my review