Only open those server ports that were explicitly set through command line options.

Updated version string.
This commit is contained in:
hns 2002-10-01 16:19:33 +00:00
parent 67c03ca7ae
commit 7bc5876c96

View file

@ -25,7 +25,7 @@ import org.mortbay.http.ajp.*;
public class Server implements IPathElement, Runnable {
public static final String version = "1.2pre3+ 2002/09/26";
public static final String version = "1.2pre3+ 2002/10/01";
public long starttime;
// if true we only accept RMI and XML-RPC connections from
@ -141,6 +141,13 @@ import org.mortbay.http.ajp.*;
usageError = true;
}
// check server ports. If no port is set, issue a warning and exit.
if (!usageError && (websrvPort | ajp13Port | rmiPort | xmlrpcPort) == 0) {
System.out.println (" Error: No server port specified.");
usageError = true;
}
if (usageError ) {
System.out.println ("usage: java helma.main.Server [-h dir] [-f file] [-p port] [-w port] [-x port]");
System.out.println (" -h dir Specify hop home directory");
@ -153,6 +160,22 @@ import org.mortbay.http.ajp.*;
System.exit (0);
}
// check if servers are already running on the given ports
try {
if (websrvPort > 0)
checkRunning (websrvPort);
if (rmiPort > 0)
checkRunning (rmiPort);
if (xmlrpcPort > 0)
checkRunning (xmlrpcPort);
if (ajp13Port > 0)
checkRunning (ajp13Port);
} catch (Exception running) {
System.out.println (running.getMessage ());
System.exit (1);
}
// get main property file from home dir or vice versa, depending on what we have.
// get property file from hopHome
if (propfile == null) {
@ -222,30 +245,6 @@ import org.mortbay.http.ajp.*;
dbSources = new Hashtable ();
// check server ports. If no port is set,
// use 5055 for RMI and 5056 for XML-RPC.
if ((websrvPort | ajp13Port | rmiPort) == 0) {
rmiPort = 5055;
if (xmlrpcPort == 0)
xmlrpcPort = 5056;
}
// check if servers are already running on the given ports
try {
if (websrvPort > 0)
checkRunning (websrvPort);
if (rmiPort > 0)
checkRunning (rmiPort);
if (xmlrpcPort > 0)
checkRunning (xmlrpcPort);
if (ajp13Port > 0)
checkRunning (ajp13Port);
} catch (Exception running) {
System.out.println (running.getMessage ());
System.exit (1);
}
// nmgr = new NodeManager (this, sysProps);
// try to load the extensions
extensions = new Vector ();
if (sysProps.getProperty ("extensions")!=null) {
@ -323,6 +322,7 @@ import org.mortbay.http.ajp.*;
getLogger().log ("Starting AJP13-Listener on port "+(ajp13Port));
}
if (xmlrpcPort > 0) {
String xmlparser = sysProps.getProperty ("xmlparser");
if (xmlparser != null)
XmlRpc.setDriver (xmlparser);
@ -338,9 +338,10 @@ import org.mortbay.http.ajp.*;
}
}
getLogger().log ("Starting XML-RPC server on port "+(xmlrpcPort));
}
// the following seems not to be necessary after all ...
// System.setSecurityManager(new RMISecurityManager());
if (rmiPort > 0) {
if (paranoid) {
HopSocketFactory factory = new HopSocketFactory ();
String rallow = sysProps.getProperty ("allowWeb");
@ -351,8 +352,6 @@ import org.mortbay.http.ajp.*;
}
RMISocketFactory.setSocketFactory (factory);
}
if (rmiPort > 0) {
getLogger().log ("Starting RMI server on port "+rmiPort);
LocateRegistry.createRegistry (rmiPort);
}