From f2a72027877e44434da4c264e17fa6475492988b Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 10 Jul 2025 16:06:31 +0200 Subject: [PATCH 1/3] 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. --- Python/emscripten_syscalls.c | 17 +++++++++++++++++ configure | 2 +- configure.ac | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 Python/emscripten_syscalls.c diff --git a/Python/emscripten_syscalls.c b/Python/emscripten_syscalls.c new file mode 100644 index 00000000000000..6cd3fc5bf06063 --- /dev/null +++ b/Python/emscripten_syscalls.c @@ -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(); +} diff --git a/configure b/configure index 94a0b810333ce9..cc868bf47d441c 100755 --- a/configure +++ b/configure @@ -19060,7 +19060,7 @@ PLATFORM_OBJS= case $ac_sys_system in #( Emscripten) : - as_fn_append PLATFORM_OBJS ' Python/emscripten_signal.o Python/emscripten_trampoline.o' + as_fn_append PLATFORM_OBJS ' Python/emscripten_signal.o Python/emscripten_trampoline.o Python/emscripten_syscalls.o' as_fn_append PLATFORM_HEADERS ' $(srcdir)/Include/internal/pycore_emscripten_signal.h $(srcdir)/Include/internal/pycore_emscripten_trampoline.h' ;; #( *) : diff --git a/configure.ac b/configure.ac index ade71bc011eb87..727bfb1b3bf681 100644 --- a/configure.ac +++ b/configure.ac @@ -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']) ], ) From 789681e1c662bb23a3546cff201cd42bcdb01353 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sun, 13 Jul 2025 14:24:30 +0200 Subject: [PATCH 2/3] Add missing include --- Python/emscripten_syscalls.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/emscripten_syscalls.c b/Python/emscripten_syscalls.c index 6cd3fc5bf06063..7875bfc8fe56ae 100644 --- a/Python/emscripten_syscalls.c +++ b/Python/emscripten_syscalls.c @@ -1,3 +1,5 @@ +#include "emscripten.h" + // 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. From b8df7eacce1f072154e82c179ef84f9966c3ee11 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 15 Jul 2025 16:29:38 +0200 Subject: [PATCH 3/3] Add emscripten_syscalls.c to excludes for Tools/c-analyzer/cpython/_parser.py --- Tools/c-analyzer/cpython/_parser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py index 037fe11ea223c7..cfbf0d14348499 100644 --- a/Tools/c-analyzer/cpython/_parser.py +++ b/Tools/c-analyzer/cpython/_parser.py @@ -66,6 +66,7 @@ def clean_lines(text): Python/dynload_dl.c # dl.h Python/dynload_hpux.c # dl.h Python/emscripten_signal.c +Python/emscripten_syscalls.c Python/thread_pthread.h Python/thread_pthread_stubs.h 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