8227587: Add internal privileged System.loadLibrary

Reviewed-by: rriggs, mchung, chegar
This commit is contained in:
Claes Redestad 2019-07-17 12:35:46 +02:00
parent ec7f1c13d9
commit 78a1c8ea0a
26 changed files with 97 additions and 218 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,7 +25,7 @@
package sun.net;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
/**
* Determines the ephemeral port range in use on this system.
@ -41,35 +41,29 @@ public final class PortConfig {
private PortConfig() {}
static {
AccessController.doPrivileged(
new java.security.PrivilegedAction<>() {
public Void run() {
System.loadLibrary("net");
String os = System.getProperty("os.name");
if (os.startsWith("Linux")) {
defaultLower = 32768;
defaultUpper = 61000;
} else if (os.startsWith("SunOS")) {
defaultLower = 32768;
defaultUpper = 65535;
} else if (os.contains("OS X")) {
defaultLower = 49152;
defaultUpper = 65535;
} else if (os.startsWith("AIX")) {
// The ephemeral port is OS version dependent on AIX:
// http://publib.boulder.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.rsct315.admin/bl503_ephport.htm
// However, on AIX 5.3 / 6.1 / 7.1 we always see the
// settings below by using:
// /usr/sbin/no -a | fgrep ephemeral
defaultLower = 32768;
defaultUpper = 65535;
} else {
throw new InternalError(
"sun.net.PortConfig: unknown OS");
}
return null;
}
});
jdk.internal.loader.BootLoader.loadLibrary("net");
String os = GetPropertyAction.privilegedGetProperty("os.name");
if (os.startsWith("Linux")) {
defaultLower = 32768;
defaultUpper = 61000;
} else if (os.startsWith("SunOS")) {
defaultLower = 32768;
defaultUpper = 65535;
} else if (os.contains("OS X")) {
defaultLower = 49152;
defaultUpper = 65535;
} else if (os.startsWith("AIX")) {
// The ephemeral port is OS version dependent on AIX:
// http://publib.boulder.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.rsct315.admin/bl503_ephport.htm
// However, on AIX 5.3 / 6.1 / 7.1 we always see the
// settings below by using:
// /usr/sbin/no -a | fgrep ephemeral
defaultLower = 32768;
defaultUpper = 65535;
} else {
throw new InternalError(
"sun.net.PortConfig: unknown OS");
}
int v = getLower0();
if (v == -1) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -259,13 +259,7 @@ public class ResolverConfigurationImpl
static native String fallbackDomain0();
static {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<>() {
public Void run() {
System.loadLibrary("net");
return null;
}
});
jdk.internal.loader.BootLoader.loadLibrary("net");
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,8 +33,6 @@ import java.nio.file.FileAlreadyExistsException;
import java.nio.file.LinkOption;
import java.nio.file.LinkPermission;
import java.nio.file.StandardCopyOption;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@ -628,12 +626,7 @@ class UnixCopyFile {
throws UnixException;
static {
AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Void run() {
System.loadLibrary("nio");
return null;
}});
jdk.internal.loader.BootLoader.loadLibrary("nio");
}
}

View file

@ -25,9 +25,6 @@
package sun.nio.fs;
import java.security.AccessController;
import java.security.PrivilegedAction;
/**
* Unix system and library calls.
*/
@ -630,11 +627,7 @@ class UnixNativeDispatcher {
private static native int init();
static {
AccessController.doPrivileged(new PrivilegedAction<>() {
public Void run() {
System.loadLibrary("nio");
return null;
}});
jdk.internal.loader.BootLoader.loadLibrary("nio");
capabilities = init();
}
}