mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	[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 e81c4e84b3)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									d888f46fba
								
							
						
					
					
						commit
						cdf98c3b7e
					
				
					 4 changed files with 22 additions and 2 deletions
				
			
		
							
								
								
									
										19
									
								
								Python/emscripten_syscalls.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								Python/emscripten_syscalls.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,19 @@
 | 
			
		|||
#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.
 | 
			
		||||
// 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();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								configure
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								configure
									
										
									
										generated
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -19077,7 +19077,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'
 | 
			
		||||
   ;; #(
 | 
			
		||||
  *) :
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5131,7 +5131,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'])
 | 
			
		||||
  ],
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue