org.iids.aos.agentserver.jailing
Class Jail

java.lang.Object
  extended by org.iids.aos.agentserver.jailing.Jail

public class Jail
extends java.lang.Object

Process jail. TODO description

Author:
rjtimmer

Field Summary
static java.lang.String defaultJailBinary
           
static java.lang.String defaultJailPolicy
           
static boolean JAIL_ENABLED
           
static int JF_EXEC_BACKGROUND
          Jail execution in foreground/background.
static int JF_EXEC_JAILED
          Enable or disable process jailing.
 
Constructor Summary
Jail()
          Create Jail with default options (all flags disabled).
Jail(int flags)
          Create jail with flags.
 
Method Summary
 void addIpcEscape(int port)
          Add IPC escape to jailer for local TCP port.
 void addIpcEscape(java.lang.String ipv4, int port)
           
 boolean canJail()
          Query if the platform is able to do jailing.
 boolean checkFlag(int flag)
           
 java.lang.Process exec(java.lang.String... args)
          Start the (possibly jailed) process.
 java.lang.String getCommand()
          Get the complete command to execute the (possibly jailed) agent.
 void setArgs(java.lang.String args)
           
 boolean setCode(byte[] code, java.lang.String path)
          Set the binary code for this agent and store it in path.
 void setEnv(java.util.Map<java.lang.String,java.lang.String> env)
           
 void setFlag(int flag)
           
 void setRuntimeDir(java.lang.String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAIL_ENABLED

public static final boolean JAIL_ENABLED
See Also:
Constant Field Values

JF_EXEC_BACKGROUND

public static final int JF_EXEC_BACKGROUND
Jail execution in foreground/background. If this flag is enabled then Jail.exec() returns immediately without waiting for process termination.

See Also:
Constant Field Values

JF_EXEC_JAILED

public static final int JF_EXEC_JAILED
Enable or disable process jailing. If this flag is set then the process is executed inside the jailer. The jailer is only used if it is supported by the platform, and if a jailer binary is available. Otherwise this flag is ignored.

See Also:
Constant Field Values

defaultJailPolicy

public static final java.lang.String defaultJailPolicy

defaultJailBinary

public static final java.lang.String defaultJailBinary
Constructor Detail

Jail

public Jail(int flags)
Create jail with flags. Possible flags are defined in Jail.JF_*


Jail

public Jail()
Create Jail with default options (all flags disabled).

Method Detail

canJail

public boolean canJail()
Query if the platform is able to do jailing. This depends on a number of things, like availability of the jailer and platform support of the jailer itself. If this returns false, any exec using the Jail will never be actually jailed.


getCommand

public java.lang.String getCommand()
Get the complete command to execute the (possibly jailed) agent. If jailing is disabled, or for some reason impossible, then this command also takes care of disabling the jailer in the command.

Otherwise it returns the complete command (including necessary IPC escapes) so that the agent in the jail can still contact the necessary TCP ports, provided these were all set with addIpcEscape().


setCode

public boolean setCode(byte[] code,
                       java.lang.String path)
Set the binary code for this agent and store it in path.


checkFlag

public boolean checkFlag(int flag)

setFlag

public void setFlag(int flag)

setRuntimeDir

public void setRuntimeDir(java.lang.String path)

setEnv

public void setEnv(java.util.Map<java.lang.String,java.lang.String> env)

setArgs

public void setArgs(java.lang.String args)

addIpcEscape

public void addIpcEscape(int port)
                  throws java.lang.IllegalArgumentException
Add IPC escape to jailer for local TCP port.

Throws:
java.lang.IllegalArgumentException

addIpcEscape

public void addIpcEscape(java.lang.String ipv4,
                         int port)
                  throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

exec

public java.lang.Process exec(java.lang.String... args)
Start the (possibly jailed) process. Depending on the properties, this returns immediately (if the Jail.JF_EXEC_BACKGROUND was specified) or not.

Returns:
The process


Copyright © 2003, 2004 IIDS Group. All Rights Reserved.