Skip to content

Commit f2a7202

Browse files
committed
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.
1 parent f519918 commit f2a7202

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Python/emscripten_syscalls.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// If we're running in node, report the UID of the user in the native system as
2+
// the UID of the user. Since the nodefs will report the uid correctly, if we
3+
// don't make getuid report it correctly too we'll see some permission errors.
4+
// Normally __syscall_getuid32 is a stub that always returns 0 but it is
5+
// defined with weak linkage so we can override it.
6+
EM_JS(int, __syscall_getuid32_js, (void), {
7+
// If we're in node and we can, report the native uid
8+
if (typeof process !== "undefined" && typeof process.getuid === "function") {
9+
return process.getuid();
10+
}
11+
// Fall back to the stub case of returning 0.
12+
return 0;
13+
})
14+
15+
int __syscall_getuid32(void) {
16+
return __syscall_getuid32_js();
17+
}

configure

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5119,7 +5119,7 @@ PLATFORM_OBJS=
51195119

51205120
AS_CASE([$ac_sys_system],
51215121
[Emscripten], [
5122-
AS_VAR_APPEND([PLATFORM_OBJS], [' Python/emscripten_signal.o Python/emscripten_trampoline.o'])
5122+
AS_VAR_APPEND([PLATFORM_OBJS], [' Python/emscripten_signal.o Python/emscripten_trampoline.o Python/emscripten_syscalls.o'])
51235123
AS_VAR_APPEND([PLATFORM_HEADERS], [' $(srcdir)/Include/internal/pycore_emscripten_signal.h $(srcdir)/Include/internal/pycore_emscripten_trampoline.h'])
51245124
],
51255125
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy