8343958: Remove security manager impl in java.lang.Process and java.lang.Runtime.exec

Reviewed-by: jpai, mullan, alanb
This commit is contained in:
Roger Riggs 2024-11-13 20:49:59 +00:00
parent 5ac330b1ac
commit 168b18ec68
4 changed files with 55 additions and 169 deletions

View file

@ -42,14 +42,10 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import jdk.internal.access.JavaIOFileDescriptorAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.util.OperatingSystem;
import jdk.internal.util.StaticProperty;
import sun.security.action.GetPropertyAction;
/**
* java.lang.Process subclass in the UNIX environment.
@ -95,7 +91,7 @@ final class ProcessImpl extends Process {
* @throws Error if the requested launch mechanism is not found or valid
*/
private static LaunchMechanism launchMechanism() {
String s = GetPropertyAction.privilegedGetProperty("jdk.lang.Process.launchMechanism");
String s = System.getProperty("jdk.lang.Process.launchMechanism");
if (s == null) {
return LaunchMechanism.POSIX_SPAWN;
}
@ -282,7 +278,6 @@ final class ProcessImpl extends Process {
boolean redirectErrorStream)
throws IOException;
@SuppressWarnings("removal")
private ProcessImpl(final byte[] prog,
final byte[] argBlock, final int argc,
final byte[] envBlock, final int envc,
@ -302,14 +297,7 @@ final class ProcessImpl extends Process {
redirectErrorStream);
processHandle = ProcessHandleImpl.getInternal(pid);
try {
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
initStreams(fds, forceNullOutputStream);
return null;
});
} catch (PrivilegedActionException ex) {
throw (IOException) ex.getCause();
}
initStreams(fds, forceNullOutputStream);
}
static FileDescriptor newFileDescriptor(int fd) {
@ -507,11 +495,6 @@ final class ProcessImpl extends Process {
@Override
public ProcessHandle toHandle() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new RuntimePermission("manageProcess"));
}
return processHandle;
}