diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLauncher.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLauncher.java index c5d88e19a23..a7e1ba61862 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLauncher.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLauncher.java @@ -32,7 +32,6 @@ import java.util.ArrayList; import javax.net.ssl.HandshakeCompletedEvent; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; @@ -292,13 +291,13 @@ public class ServerLauncher extends Thread } else { - //read over stuff coming from the login shell invocation + // look for the server startup string, it needs to occur somewhere in the line. String status = _errReader.readLine(); - while (status!=null && !status.equals(ServerReturnCodes.RC_DSTORE_SERVER_MAGIC)) + while (status!=null && (status.indexOf(ServerReturnCodes.RC_DSTORE_SERVER_MAGIC) < 0)) { status = _errReader.readLine(); } - //now read the real server status + // now read the real server status if (status != null) { status = _errReader.readLine(); diff --git a/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/auth.pl b/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/auth.pl new file mode 100644 index 00000000000..bf5a88bddda --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/auth.pl @@ -0,0 +1,46 @@ +#!/usr/bin/perl -w + +# Assumes the $CLASSPATH environment variable is set. +# Assumes password is supplied on STDIN. +# Sets return code of 0 on failure, 1 on success. + +$user=`whoami`; chomp($user); +if ($user ne "root") { + print "The root user must run the authorization script.\n"; + exit 0; +} + +$argc = @ARGV; +if ($argc < 5 || $argc > 6) { + print("command usage:\n"); + print("auth.pl USER PATH PORT TIMEOUT TICKET [JAVA_HOME]\n"); + exit 0; +} + +$user = $ARGV[0]; +$plugin_path = $ARGV[1]; +$port = $ARGV[2]; +$timeout = $ARGV[3]; +$ticket = $ARGV[4]; +if ($argc == 6) { + $java = $ARGV[5]."/bin/java"; +} else { + $java = "java"; +} + +$password = ; chomp($password); +open(CHECK, "su $user -c 'perl check.pl $password'|"); +$rc = ; chomp($rc); +close(CHECK); +if ($rc > 0) { + printf("Invalid password.\n"); + exit 0; +} +print "success\n"; + +$classpath = $ENV{CLASSPATH}; +$server = "org.eclipse.dstore.core.server.Server"; +$inner_command = "$java -cp $classpath -DA_PLUGIN_PATH=$plugin_path -DDSTORE_SPIRIT_ON=true $server $port $timeout $ticket"; +$outer_command = "su $user -l -c '$inner_command'"; +system($outer_command); +exit 1; diff --git a/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/check.pl b/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/check.pl new file mode 100644 index 00000000000..781168d7ccf --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/check.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl -w + +# On MacOS X the password check must be run under the user's uid. +# If the password is OK, prints "0\n" to STDOUT. +# If not OK, prints "1\n" on STDOUT. +# Password prompt and errors are sent to the bit bucket. + +$password = $ARGV[0]; +$user = `whoami`; chomp($user); +$rc = system ("echo $password | su $user -c 'echo 0' 2> /dev/null"); +if ($rc > 0) { + print "1\n"; +} diff --git a/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/daemon.pl b/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/daemon.pl new file mode 100644 index 00000000000..c8e2b975925 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/daemon.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl -w + +# Arguments: +# ARGV[0] is the port number for the daemon to listen on. Default is 4035. +# ARGV[1] is the directory that contains RSE Dstore server jar files and +# installation supplied miner class files. The default is the working +# directory. +# +# Environment Variables: +# CLASSPATH - used to form the tail of the classpath for the daemon and server execution. +# DSTORE_TRACING_ON - 0 means to not trace, 1 means to trace. +# DSTORE_DEBUG_ON - 0 means to start in normal mode, 1 means to start in debug mode. +# +# Results: +# Returns 1 if there is a startup error of some sort. +# Does not return if the daemon starts successfully. Terminate the +# daemon with a signal such as TERM or INT. + +$port = $ARGV[0] || "4035"; +$plugin_dir = $ARGV[1] || $ENV{PWD}; +$trace = $ENV{DSTORE_TRACING_ON} || "0"; +$debug = $ENV{DSTORE_DEBUG_ON} || "0"; + +$user=`whoami`; chomp($user); +if ($user ne "root") { + print "The root user must run the RSE DStore server daemon.\n"; + exit 1; +} + +if ($debug) { + $debug_options = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"; +} else { + $debug_options = ""; +} + +$classpath_old = $ENV{CLASSPATH}; +$classpath = "$plugin_dir"; +$classpath .= ":$plugin_dir/dstore_extra_server.jar"; +$classpath .= ":$plugin_dir/dstore_core.jar"; +$classpath .= ":$plugin_dir/dstore_miners.jar"; +$classpath .= ":$plugin_dir/clientserver.jar"; +if ($classpath_old) { + $classpath .= ":$classpath_old"; +} + + +$ENV{CLASSPATH} = $classpath; +$launcher = "org.eclipse.dstore.core.server.ServerLauncher"; +$command = "java $debug_options -DA_PLUGIN_PATH=$plugin_dir -DDSTORE_TRACING_ON=$trace $launcher $port"; +print "$command\n"; +system($command); diff --git a/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/server.sh b/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/server.sh new file mode 100644 index 00000000000..b437e06c33e --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.dstore/serverruntime/scripts/macosx/server.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Shell script to start RSE communications server +# This script will start the datastore server listening on an available socket +export serverpath=.; +export CLASSPATH=.:dstore_extra_server.jar:dstore_core.jar:dstore_miners.jar:clientserver.jar:$CLASSPATH; +if [ $1 ] +then java -DA_PLUGIN_PATH=$serverpath -DDSTORE_TRACING_ON=false -Dclient.username=$1 -DDSTORE_SPIRIT_ON=true org.eclipse.dstore.core.server.Server 0 60000 & +else java -DA_PLUGIN_PATH=$serverpath -DDSTORE_TRACING_ON=false -DDSTORE_SPIRIT_ON=true org.eclipse.dstore.core.server.Server 0 60000 & +fi