Skip to content

Commit cdf98c3

Browse files
[3.14] gh-127146: Report uid in Emscripten + node as native uid (GH-136509) (#136699)
Corrects the handling of getuid on emscripten, which was consistently reporting as 0. (cherry picked from commit e81c4e8) Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
1 parent d888f46 commit cdf98c3

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

Python/emscripten_syscalls.c

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

Tools/c-analyzer/cpython/_parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def clean_lines(text):
6666
Python/dynload_dl.c # dl.h
6767
Python/dynload_hpux.c # dl.h
6868
Python/emscripten_signal.c
69+
Python/emscripten_syscalls.c
6970
Python/thread_pthread.h
7071
Python/thread_pthread_stubs.h
7172

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
@@ -5131,7 +5131,7 @@ PLATFORM_OBJS=
51315131

51325132
AS_CASE([$ac_sys_system],
51335133
[Emscripten], [
5134-
AS_VAR_APPEND([PLATFORM_OBJS], [' Python/emscripten_signal.o Python/emscripten_trampoline.o'])
5134+
AS_VAR_APPEND([PLATFORM_OBJS], [' Python/emscripten_signal.o Python/emscripten_trampoline.o Python/emscripten_syscalls.o'])
51355135
AS_VAR_APPEND([PLATFORM_HEADERS], [' $(srcdir)/Include/internal/pycore_emscripten_signal.h $(srcdir)/Include/internal/pycore_emscripten_trampoline.h'])
51365136
],
51375137
)

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