Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8267184: Add -Djava.security.manager=allow to tests calling System.setSecurityManager #4071

Closed
wants to merge 20 commits into from
Closed
@@ -47,8 +47,8 @@ public static void main(String args[]) throws Exception {
"--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Djava.security.manager=allow",
"-Xbootclasspath/a:.",
"-Djava.security.manager=allow",
Test.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("protection domain added");
@@ -31,6 +31,6 @@
*
* @library /vmTestbase
* /test/lib
* @run main/othervm -Djava.security.manager=allow -Xlog:gc=debug:gc.log gc.ArrayJuggle.Juggle01.Juggle01 -gp charArr -ms medium
* @run main/othervm -Xlog:gc=debug:gc.log -Djava.security.manager=allow gc.ArrayJuggle.Juggle01.Juggle01 -gp charArr -ms medium
*/

@@ -112,9 +112,9 @@ public void testLayer() throws Exception {
@Test
public void testDeniedClassLoaderAccess() throws Exception {
String[] options = new String[] {
"-Djava.security.manager=allow",
"--module-path", MOD_DEST_DIR.toString(),
"--add-modules", String.join(",", modules),
"-Djava.security.manager=allow",
"-m", "m3/p3.NoGetClassLoaderAccess"
};
assertTrue(executeTestJava(options)
@@ -65,7 +65,7 @@
* and call setAccessible(false) followed by setAccessible(true);
* @modules java.base/jdk.internal.module
* @run main/othervm --add-modules=ALL-SYSTEM FieldSetAccessibleTest UNSECURE
* @run main/othervm -Djava.security.manager=allow --add-modules=ALL-SYSTEM FieldSetAccessibleTest SECURE
* @run main/othervm --add-modules=ALL-SYSTEM -Djava.security.manager=allow FieldSetAccessibleTest SECURE
*
* @author danielfuchs
*/
@@ -82,8 +82,8 @@ public void runTest() throws Exception {
int exitValue
= executeTestJava("--module-path", MODS_DIR.toString(),
"--add-modules", "m1,m2",
"-Djava.security.manager=allow",
"-cp", CLASSES_DIR.toString(),
"-cp", CLASSES_DIR.toString(),
"-Djava.security.manager=allow",
"Main")
.outputTo(System.out)
.errorTo(System.out)
@@ -80,8 +80,8 @@ public void runTest() throws Exception {
int exitValue
= executeTestJava("--module-path", MODS_DIR.toString(),
"--add-modules", "m1,m2",
"-cp", CLASSES_DIR.toString(),
"-Djava.security.manager=allow",
"-cp", CLASSES_DIR.toString(),
"Main")
.outputTo(System.out)
.errorTo(System.out)
@@ -31,8 +31,8 @@
*
* @compile WithSecurityManager.java
*
* @run main/othervm -Djava.security.manager=allow -Xverify:all WithSecurityManager
* @run main/othervm -Djava.security.manager=allow -Xverify:all --limit-modules=java.base WithSecurityManager
* @run main/othervm -Xverify:all -Djava.security.manager=allow WithSecurityManager
* @run main/othervm -Xverify:all --limit-modules=java.base -Djava.security.manager=allow WithSecurityManager
*/
public class WithSecurityManager {
public static void main(String[] args) throws Throwable {
@@ -57,8 +57,8 @@
* @build CustomLoggerTest AccessSystemLogger
* @run driver AccessSystemLogger
* @run main/othervm -Xbootclasspath/a:boot CustomLoggerTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot CustomLoggerTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot CustomLoggerTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow CustomLoggerTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow CustomLoggerTest WITHPERMISSIONS
* @author danielfuchs
*/
public class CustomLoggerTest {
@@ -60,10 +60,10 @@
* @build DefaultLoggerTest AccessSystemLogger
* @run driver AccessSystemLogger
* @run main/othervm -Xbootclasspath/a:boot DefaultLoggerTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot DefaultLoggerTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot DefaultLoggerTest WITHPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot DefaultLoggerTest WITHCUSTOMWRAPPERS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot DefaultLoggerTest WITHREFLECTION
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow DefaultLoggerTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow DefaultLoggerTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow DefaultLoggerTest WITHCUSTOMWRAPPERS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow DefaultLoggerTest WITHREFLECTION
* @author danielfuchs
*/
public class DefaultLoggerTest {
@@ -49,8 +49,8 @@
* @build AccessSystemLogger BaseLoggerFinderTest CustomSystemClassLoader BaseLoggerFinder TestLoggerFinder
* @run driver AccessSystemLogger
* @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader BaseLoggerFinderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader BaseLoggerFinderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader BaseLoggerFinderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader BaseLoggerFinderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader BaseLoggerFinderTest WITHPERMISSIONS
* @author danielfuchs
*/
public class BaseLoggerFinderTest {
@@ -56,8 +56,8 @@
* @build AccessSystemLogger DefaultLoggerFinderTest
* @run driver AccessSystemLogger
* @run main/othervm -Xbootclasspath/a:boot DefaultLoggerFinderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot DefaultLoggerFinderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot DefaultLoggerFinderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow DefaultLoggerFinderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow DefaultLoggerFinderTest WITHPERMISSIONS
* @author danielfuchs
*/
public class DefaultLoggerFinderTest {
@@ -67,10 +67,10 @@
* @build AccessSystemLogger BaseDefaultLoggerFinderTest CustomSystemClassLoader BaseLoggerFinder
* @run driver AccessSystemLogger
* @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader BaseDefaultLoggerFinderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader BaseDefaultLoggerFinderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader BaseDefaultLoggerFinderTest WITHPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader BaseDefaultLoggerFinderTest WITHCUSTOMWRAPPERS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader BaseDefaultLoggerFinderTest WITHREFLECTION
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader BaseDefaultLoggerFinderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader BaseDefaultLoggerFinderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader BaseDefaultLoggerFinderTest WITHCUSTOMWRAPPERS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader BaseDefaultLoggerFinderTest WITHREFLECTION
* @author danielfuchs
*/
public class BaseDefaultLoggerFinderTest {
@@ -66,32 +66,32 @@
* @build AccessSystemLogger LoggerFinderLoaderTest CustomSystemClassLoader BaseLoggerFinder BaseLoggerFinder2
* @run driver AccessSystemLogger
* @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader LoggerFinderLoaderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true LoggerFinderLoaderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=ERROR LoggerFinderLoaderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=ERROR LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=ERROR LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=ERROR LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=ERROR LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=DEBUG LoggerFinderLoaderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=DEBUG LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=DEBUG LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=DEBUG LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=DEBUG LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Dtest.fails=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true LoggerFinderLoaderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=ERROR LoggerFinderLoaderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=ERROR LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=ERROR LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=ERROR LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=ERROR LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=DEBUG LoggerFinderLoaderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=DEBUG LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=DEBUG LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=DEBUG LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=DEBUG LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest NOSECURITY
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest WITHPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest NOPERMISSIONS
* @run main/othervm -Xbootclasspath/a:boot -Djava.security.manager=allow -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest WITHPERMISSIONS
* @author danielfuchs
*/
public class LoggerFinderLoaderTest {
@@ -76,9 +76,10 @@ public static void main(String... args) {
doprivJava.delete();
doprivClass.delete();
tr = doExec(JAVA_CMD.getAbsolutePath(),
"-Djava.security.manager=allow",
"-Xbootclasspath/a:foo.jar",
"-cp", ".", "Bar");
"-cp", ".",
"-Djava.security.manager=allow",
"Bar");
tr.assertZero("testDoPrivileged fails");
barJava.delete();
barClass.delete();
@@ -29,7 +29,7 @@
* @library /test/lib
* @build TestSecurityManagerChecks testPkg.Host testPkg.Singleton
* @run driver jdk.test.lib.helpers.ClassFileInstaller testPkg.Host testPkg.Host$Member testPkg.Singleton
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:. TestSecurityManagerChecks
* @run main/othervm -Xbootclasspath/a:. -Djava.security.manager=allow TestSecurityManagerChecks
*/

// ClassFileInstaller copies the testPkg files into the "current" directory
@@ -29,7 +29,7 @@
* @build PrivilegedThreadFactory Attack
* jdk.test.lib.util.JarUtils
* @run driver SetupJar
* @run main/othervm -Djava.security.manager=allow -Xbootclasspath/a:privileged.jar AsExecutor
* @run main/othervm -Xbootclasspath/a:privileged.jar -Djava.security.manager=allow AsExecutor
*/

import java.nio.channels.AsynchronousChannelGroup;
@@ -67,8 +67,7 @@ private static void testLargeFile() throws Exception {
File largeFile = new File("largeFileTest");
long testSize = ((long)Integer.MAX_VALUE) * 2;
initTestFile(largeFile, 10);
try (FileChannel fc = new RandomAccessFile(largeFile, "rw").getChannel())
{
try (FileChannel fc = new RandomAccessFile(largeFile, "rw").getChannel()) {
fc.size();
fc.map(FileChannel.MapMode.READ_WRITE, testSize, 10);
if (fc.size() != testSize + 10) {