94
94
import java .util .Locale ;
95
95
import java .util .Map ;
96
96
import java .util .Set ;
97
+ import java .util .concurrent .ConcurrentHashMap ;
97
98
import java .util .concurrent .TimeUnit ;
98
99
import java .util .logging .Level ;
99
100
@@ -243,7 +244,7 @@ public final class EmulatedPosixSupport extends PosixResources {
243
244
private static final int S_IFREG = 0100000 ;
244
245
245
246
private final PythonContext context ;
246
- private final Map <String , String > environ = new HashMap <>();
247
+ private final ConcurrentHashMap <String , String > environ = new ConcurrentHashMap <>();
247
248
private int currentUmask = 0022 ;
248
249
private boolean hasDefaultUmask = true ;
249
250
@@ -1606,9 +1607,13 @@ public String ctermid() {
1606
1607
1607
1608
@ ExportMessage
1608
1609
@ TruffleBoundary
1609
- public synchronized void setenv (Object name , Object value , boolean overwrite ) {
1610
- if (overwrite || !environ .containsKey (name )) {
1611
- environ .put ((String ) name , (String ) value );
1610
+ public void setenv (Object name , Object value , boolean overwrite ) {
1611
+ String nameStr = pathToJavaStr (name );
1612
+ String valueStr = pathToJavaStr (value );
1613
+ if (overwrite ) {
1614
+ environ .put (nameStr , valueStr );
1615
+ } else {
1616
+ environ .putIfAbsent (nameStr , valueStr );
1612
1617
}
1613
1618
}
1614
1619
@@ -1620,12 +1625,6 @@ public int forkExec(Object[] executables, Object[] args, Object cwd, Object[] en
1620
1625
// TODO there are a few arguments we ignore, we should throw an exception or report a
1621
1626
// compatibility warning
1622
1627
1623
- if (!context .isExecutableAccessAllowed ()) {
1624
- // TODO is this check relevant to NFI backend as well?
1625
- // TODO raise an exception instead of returning an invalid pid
1626
- return -1 ;
1627
- }
1628
-
1629
1628
// TODO do we need to do this check (and the isExecutable() check later)?
1630
1629
TruffleFile cwdFile = cwd == null ? context .getEnv ().getCurrentWorkingDirectory () : getTruffleFile (pathToJavaStr (cwd ));
1631
1630
if (!cwdFile .exists ()) {
@@ -1782,9 +1781,6 @@ private void handleIOError(int errpipe_write, IOException e) {
1782
1781
@ ExportMessage
1783
1782
public void execv (Object pathname , Object [] args ) throws PosixException {
1784
1783
assert args .length > 0 ;
1785
- if (!context .isExecutableAccessAllowed ()) {
1786
- throw posixException (OSErrorEnum .EPERM );
1787
- }
1788
1784
String [] cmd = new String [args .length ];
1789
1785
// ProcessBuilder does not accept separate executable name, we must overwrite the 0-th
1790
1786
// argument
@@ -1834,9 +1830,6 @@ private void execvInternal(String[] cmd) throws IOException {
1834
1830
@ TruffleBoundary
1835
1831
public int system (Object commandObj ) {
1836
1832
String cmd = pathToJavaStr (commandObj );
1837
- if (!context .isExecutableAccessAllowed ()) {
1838
- return -1 ;
1839
- }
1840
1833
LOGGER .fine (() -> "os.system: " + cmd );
1841
1834
1842
1835
String [] command ;
0 commit comments