8326898: NSK tests should listen on loopback addresses only
Reviewed-by: sspitsyn, cjplummer, dholmes, lmesnik
This commit is contained in:
parent
e6a8fdd82c
commit
2482a505e5
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -102,7 +102,7 @@ public class attach004t {
|
|||||||
SocketIOPipe pipe = null;
|
SocketIOPipe pipe = null;
|
||||||
try {
|
try {
|
||||||
int portNumber = readPortNumber(log);
|
int portNumber = readPortNumber(log);
|
||||||
pipe = SocketIOPipe.createClientIOPipe(log, "localhost", portNumber, 0);
|
pipe = SocketIOPipe.createClientIOPipe(log, portNumber, 0);
|
||||||
log.display("Send message to debugger: " + attach004.messageOK);
|
log.display("Send message to debugger: " + attach004.messageOK);
|
||||||
pipe.println(attach004.messageOK);
|
pipe.println(attach004.messageOK);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -54,7 +54,7 @@ public class DummyTargetApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runTargetApplication() {
|
public void runTargetApplication() {
|
||||||
pipe = SocketIOPipe.createClientIOPipe(log, "localhost", argParser.getPort(), 0);
|
pipe = SocketIOPipe.createClientIOPipe(log, argParser.getPort(), 0);
|
||||||
log.display("Sending signal '" + AODTestRunner.SIGNAL_READY_FOR_ATTACH + "'");
|
log.display("Sending signal '" + AODTestRunner.SIGNAL_READY_FOR_ATTACH + "'");
|
||||||
pipe.println(AODTestRunner.SIGNAL_READY_FOR_ATTACH);
|
pipe.println(AODTestRunner.SIGNAL_READY_FOR_ATTACH);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -341,7 +341,7 @@ public class TargetApplicationWaitingAgents {
|
|||||||
/*
|
/*
|
||||||
* When target application initialized send signal to AODTestRunner
|
* When target application initialized send signal to AODTestRunner
|
||||||
*/
|
*/
|
||||||
pipe = SocketIOPipe.createClientIOPipe(log, "localhost", argParser.getPort(), 0);
|
pipe = SocketIOPipe.createClientIOPipe(log, argParser.getPort(), 0);
|
||||||
log.display("Sending signal '" + AODTestRunner.SIGNAL_READY_FOR_ATTACH + "'");
|
log.display("Sending signal '" + AODTestRunner.SIGNAL_READY_FOR_ATTACH + "'");
|
||||||
pipe.println(AODTestRunner.SIGNAL_READY_FOR_ATTACH);
|
pipe.println(AODTestRunner.SIGNAL_READY_FOR_ATTACH);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -108,12 +108,12 @@ public class DebugeeArgumentHandler extends ArgumentParser {
|
|||||||
/**
|
/**
|
||||||
* Return name of the host where test executes, specified by
|
* Return name of the host where test executes, specified by
|
||||||
* <code>-test.host</code> command line option or
|
* <code>-test.host</code> command line option or
|
||||||
* "<i>localhost</i>" string by default.
|
* empty string (represents an address of the loopback interface) by default.
|
||||||
*
|
*
|
||||||
* @see #setRawArguments(String[])
|
* @see #setRawArguments(String[])
|
||||||
*/
|
*/
|
||||||
public String getTestHost() {
|
public String getTestHost() {
|
||||||
return options.getProperty("test.host", "localhost");
|
return options.getProperty("test.host", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -180,7 +180,7 @@ public class DebugeeBinder extends Log.Logger implements Finalizable {
|
|||||||
try {
|
try {
|
||||||
pipeServerSocket = new ServerSocket();
|
pipeServerSocket = new ServerSocket();
|
||||||
pipeServerSocket.setReuseAddress(false);
|
pipeServerSocket.setReuseAddress(false);
|
||||||
pipeServerSocket.bind(null);
|
pipeServerSocket.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace(getOutStream());
|
e.printStackTrace(getOutStream());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,6 +23,7 @@
|
|||||||
package nsk.share.jpda;
|
package nsk.share.jpda;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import nsk.share.*;
|
import nsk.share.*;
|
||||||
@ -35,13 +36,13 @@ import nsk.share.*;
|
|||||||
*
|
*
|
||||||
* Server and client objects should be created using special static methods provided by this class,
|
* Server and client objects should be created using special static methods provided by this class,
|
||||||
* for example 'createServerIOPipe(Log log, int port, long timeout)' for server SocketIOPipe
|
* for example 'createServerIOPipe(Log log, int port, long timeout)' for server SocketIOPipe
|
||||||
* and 'createClientIOPipe(Log log, String host, int port, long timeout)' for client SocketIOPipe.
|
* and 'createClientIOPipe(Log log, int port, long timeout)' for client SocketIOPipe.
|
||||||
*
|
*
|
||||||
* When SocketIOPipe is created it can be used to send and receive strings using methods 'readln()' and 'println(String s)'.
|
* When SocketIOPipe is created it can be used to send and receive strings using methods 'readln()' and 'println(String s)'.
|
||||||
* TCP/IP connection is established at the first attempt to read or write data.
|
* TCP/IP connection is established at the first attempt to read or write data.
|
||||||
*
|
*
|
||||||
* For example, if client process should send string 'OK' to the server process which is run
|
* For example, if client process should send string 'OK' to the server process,
|
||||||
* at the host 'SERVER_HOST' following code can be written:
|
* the following code can be written:
|
||||||
*
|
*
|
||||||
* Server side:
|
* Server side:
|
||||||
*
|
*
|
||||||
@ -53,8 +54,8 @@ import nsk.share.*;
|
|||||||
*
|
*
|
||||||
* Client side:
|
* Client side:
|
||||||
*
|
*
|
||||||
* // initialize SocketIOPipe with given values of server host name and port
|
* // initialize SocketIOPipe with given port
|
||||||
* SocketIOPipe pipe = SocketIOPipe.createClientIOPipe(log, 'SERVER_HOST', port, timeoutValue);
|
* SocketIOPipe pipe = SocketIOPipe.createClientIOPipe(log, port, timeoutValue);
|
||||||
*
|
*
|
||||||
* String command = "OK";
|
* String command = "OK";
|
||||||
* // SocketIOPipe tries to create socket and send command to the server
|
* // SocketIOPipe tries to create socket and send command to the server
|
||||||
@ -123,7 +124,7 @@ public class SocketIOPipe extends Log.Logger implements Finalizable {
|
|||||||
// then we should retry the bind() a few times.
|
// then we should retry the bind() a few times.
|
||||||
ss.setReuseAddress(false);
|
ss.setReuseAddress(false);
|
||||||
}
|
}
|
||||||
ss.bind(new InetSocketAddress(port));
|
ss.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), port));
|
||||||
pipe.setServerSocket(ss);
|
pipe.setServerSocket(ss);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace(log.getOutStream());
|
e.printStackTrace(log.getOutStream());
|
||||||
@ -143,8 +144,9 @@ public class SocketIOPipe extends Log.Logger implements Finalizable {
|
|||||||
/**
|
/**
|
||||||
* Create attaching SocketIOPipe using given port and timeout
|
* Create attaching SocketIOPipe using given port and timeout
|
||||||
*/
|
*/
|
||||||
public static SocketIOPipe createClientIOPipe(Log log, String host, int port, long timeout) {
|
public static SocketIOPipe createClientIOPipe(Log log, int port, long timeout) {
|
||||||
return new SocketIOPipe(log, DEFAULT_PIPE_LOG_PREFIX, host, port, timeout, false);
|
// use null for host to connect to loopback address
|
||||||
|
return new SocketIOPipe(log, DEFAULT_PIPE_LOG_PREFIX, null, port, timeout, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user