|
|||||||||
| Home >> All >> org >> apache >> commons >> net >> [ bsd overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.commons.net.bsd
Class RExecClient

java.lang.Objectorg.apache.commons.net.SocketClient
org.apache.commons.net.bsd.RExecClient
- Direct Known Subclasses:
- RCommandClient
- public class RExecClient
- extends org.apache.commons.net.SocketClient
RExecClient implements the rexec() facility that first appeared in 4.2BSD Unix. This class will probably only be of use for connecting to Unix systems and only when the rexecd daemon is configured to run, which is a rarity these days because of the security risks involved. However, rexec() can be very useful for performing administrative tasks on a network behind a firewall.
As with virtually all of the client classes in org.apache.commons.net, this class derives from SocketClient, inheriting its connection methods. The way to use RExecClient is to first connect to the server, call the rexec() 55 method, and then fetch the connection's input, output, and optionally error streams. Interaction with the remote command is controlled entirely through the I/O streams. Once you have finished processing the streams, you should invoke disconnect() 55 to clean up properly.
By default the standard output and standard error streams of the
remote process are transmitted over the same connection, readable
from the input stream returned by
getInputStream() 55 . However, it is
possible to tell the rexecd daemon to return the standard error
stream over a separate connection, readable from the input stream
returned by getErrorStream() 55 . You
can specify that a separate connection should be created for standard
error by setting the boolean separateErrorStream
parameter of rexec() 55 to true .
The standard input of the remote process can be written to through
the output stream returned by
getOutputSream() 55 .
| Field Summary | |
private boolean |
__remoteVerificationEnabled
|
protected java.io.InputStream |
_errorStream_
If a separate error stream is requested, _errorStream_
will point to an InputStream from which the standard error of the
remote process can be read (after a call to rexec()). |
static int |
DEFAULT_PORT
The default rexec port. |
| Fields inherited from class org.apache.commons.net.SocketClient |
_defaultPort_, _input_, _isConnected_, _output_, _socket_, _socketFactory_, _timeout_, NETASCII_EOL |
| Constructor Summary | |
RExecClient()
The default RExecClient constructor. |
|
| Method Summary | |
(package private) java.io.InputStream |
_createErrorStream()
|
void |
disconnect()
Disconnects from the server, closing all associated open sockets and streams. |
java.io.InputStream |
getErrorStream()
Returns the InputStream from which the standard error of the remote process can be read if a separate error stream is requested from the server. |
java.io.InputStream |
getInputStream()
Returns the InputStream from which the standard outputof the remote process can be read. |
java.io.OutputStream |
getOutputStream()
Returns the OutputStream through which the standard input of the remote process can be written. |
boolean |
isRemoteVerificationEnabled()
Return whether or not verification of the remote host providing a separate error stream is enabled. |
void |
rexec(java.lang.String username,
java.lang.String password,
java.lang.String command)
Same as rexec(username, password, command, false); |
void |
rexec(java.lang.String username,
java.lang.String password,
java.lang.String command,
boolean separateErrorStream)
Remotely executes a command through the rexecd daemon on the server to which the RExecClient is connected. |
void |
setRemoteVerificationEnabled(boolean enable)
Enable or disable verification that the remote host connecting to create a separate error stream is the same as the host to which the standard out stream is connected. |
| Methods inherited from class org.apache.commons.net.SocketClient |
_connectAction_, connect, connect, connect, connect, connect, connect, getDefaultPort, getDefaultTimeout, getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort, getSoLinger, getSoTimeout, getTcpNoDelay, isConnected, setDefaultPort, setDefaultTimeout, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
DEFAULT_PORT
public static final int DEFAULT_PORT
- The default rexec port. Set to 512 in BSD Unix.
- See Also:
- Constant Field Values
__remoteVerificationEnabled
private boolean __remoteVerificationEnabled
_errorStream_
protected java.io.InputStream _errorStream_
- If a separate error stream is requested,
_errorStream_will point to an InputStream from which the standard error of the remote process can be read (after a call to rexec()). Otherwise,_errorStream_will be null.
| Constructor Detail |
RExecClient
public RExecClient()
- The default RExecClient constructor. Initializes the
default port to
DEFAULT_PORT.
| Method Detail |
_createErrorStream
java.io.InputStream _createErrorStream() throws java.io.IOException
getInputStream
public java.io.InputStream getInputStream()
- Returns the InputStream from which the standard outputof the remote
process can be read. The input stream will only be set after a
successful rexec() invocation.
getOutputStream
public java.io.OutputStream getOutputStream()
- Returns the OutputStream through which the standard input of the remote
process can be written. The output stream will only be set after a
successful rexec() invocation.
getErrorStream
public java.io.InputStream getErrorStream()
- Returns the InputStream from which the standard error of the remote
process can be read if a separate error stream is requested from
the server. Otherwise, null will be returned. The error stream
will only be set after a successful rexec() invocation.
rexec
public void rexec(java.lang.String username, java.lang.String password, java.lang.String command, boolean separateErrorStream) throws java.io.IOException
- Remotely executes a command through the rexecd daemon on the server
to which the RExecClient is connected. After calling this method,
you may interact with the remote process through its standard input,
output, and error streams. You will typically be able to detect
the termination of the remote process after reaching end of file
on its standard output (accessible through
getInputStream() 55 . Disconnecting
from the server or closing the process streams before reaching
end of file will not necessarily terminate the remote process.
If a separate error stream is requested, the remote server will connect to a local socket opened by RExecClient, providing an independent stream through which standard error will be transmitted. RExecClient will do a simple security check when it accepts a connection for this error stream. If the connection does not originate from the remote server, an IOException will be thrown. This serves as a simple protection against possible hijacking of the error stream by an attacker monitoring the rexec() negotiation. You may disable this behavior with setRemoteVerificationEnabled() 55 .
rexec
public void rexec(java.lang.String username, java.lang.String password, java.lang.String command) throws java.io.IOException
- Same as
rexec(username, password, command, false);
disconnect
public void disconnect()
throws java.io.IOException
- Disconnects from the server, closing all associated open sockets and
streams.
setRemoteVerificationEnabled
public final void setRemoteVerificationEnabled(boolean enable)
- Enable or disable verification that the remote host connecting to
create a separate error stream is the same as the host to which
the standard out stream is connected. The default is for verification
to be enabled. You may set this value at any time, whether the
client is currently connected or not.
isRemoteVerificationEnabled
public final boolean isRemoteVerificationEnabled()
- Return whether or not verification of the remote host providing a
separate error stream is enabled. The default behavior is for
verification to be enabled.
|
|||||||||
| Home >> All >> org >> apache >> commons >> net >> [ bsd overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC