Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-127146: Report uid in Emscripten + node as native uid
Fixes `test_netrc.NetrcTestCase.test_security`, which was getting mad
that we reported the uid of a file correctly but reported the user's uid
as 0.
  • Loading branch information
hoodmane committed Jul 10, 2025
commit f2a72027877e44434da4c264e17fa6475492988b
17 changes: 17 additions & 0 deletions Python/emscripten_syscalls.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// If we're running in node, report the UID of the user in the native system as
// the UID of the user. Since the nodefs will report the uid correctly, if we
// don't make getuid report it correctly too we'll see some permission errors.
// Normally __syscall_getuid32 is a stub that always returns 0 but it is
// defined with weak linkage so we can override it.
EM_JS(int, __syscall_getuid32_js, (void), {
// If we're in node and we can, report the native uid
if (typeof process !== "undefined" && typeof process.getuid === "function") {
return process.getuid();
}
// Fall back to the stub case of returning 0.
return 0;
})

int __syscall_getuid32(void) {
return __syscall_getuid32_js();
}
2 changes: 1 addition & 1 deletion configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5119,7 +5119,7 @@ PLATFORM_OBJS=

AS_CASE([$ac_sys_system],
[Emscripten], [
AS_VAR_APPEND([PLATFORM_OBJS], [' Python/emscripten_signal.o Python/emscripten_trampoline.o'])
AS_VAR_APPEND([PLATFORM_OBJS], [' Python/emscripten_signal.o Python/emscripten_trampoline.o Python/emscripten_syscalls.o'])
AS_VAR_APPEND([PLATFORM_HEADERS], [' $(srcdir)/Include/internal/pycore_emscripten_signal.h $(srcdir)/Include/internal/pycore_emscripten_trampoline.h'])
],
)
Expand Down
Loading