Skip to content

Commit b63a474

Browse files
committed
[GR-12243] Do not set sys.executable if neither host nor native access are allowed
1 parent 422a51b commit b63a474

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void initialize(PythonCore core) {
104104
builtinConstants.put("byteorder", ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? "little" : "big");
105105
builtinConstants.put("copyright", LICENSE);
106106
builtinConstants.put("dont_write_bytecode", true);
107-
if (TruffleOptions.AOT) {
107+
if (TruffleOptions.AOT || !core.getContext().isExecutableAccessAllowed()) {
108108
// cannot set the path at this time since the binary is not yet known; will be patched
109109
// in the context
110110
builtinConstants.put("executable", PNone.NONE);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public void patch(Env newEnv) {
192192

193193
private void setupRuntimeInformation() {
194194
PythonModule sysModule = core.initializeSysModule();
195-
if (TruffleOptions.AOT && !language.isNativeBuildTime()) {
195+
if (TruffleOptions.AOT && !language.isNativeBuildTime() && isExecutableAccessAllowed()) {
196196
sysModule.setAttribute("executable", ProcessProperties.getExecutableName());
197197
}
198198
sysModules = (PDict) sysModule.getAttribute("modules");
@@ -260,4 +260,8 @@ public void initializeMainModule(String path) {
260260
public static Assumption getSingleNativeContextAssumption() {
261261
return singleNativeContext;
262262
}
263+
264+
public boolean isExecutableAccessAllowed() {
265+
return getEnv().isHostLookupAllowed() || getEnv().isNativeAccessAllowed();
266+
}
263267
}

0 commit comments

Comments
 (0)