Index...
Centrallix Documentation
|
11.6 Shell Command Connector
The Shell Command connector is used for system integration with the host operating system, allowing applications running under Centrallix to run commands on the host operating system.
Cautions
Enabling shell objects comes with some risks, and you should understand these considerations before proceeding.
First, make sure any .shl object has an appropriate require_endorsements setting, such as:
require_endorsements = "system:from_application";
The above setting requires that the shell object be triggered only from a running Centrallix application, as verified by a CSRF token.
Second, by default environment variables passed to the command cannot be modified. For limited environment variables that should be able to be specified in the call to the .shl object, place those variable names in the "changeable" setting, such as:
changeable = "EMAIL_SUBJECT", "EMAIL_REPLY_TO";
Third, any shell command will be run as the user currently logged in to Centrallix. If the command should be run as a different user, such as root, do that only with careful consideration and by using a properly configured tool like "sudo" rather than by creating setuid programs.
Enabling Shell Objects
Shell objects by default are disabled in the Centrallix build. To enable them, you need to add an option to "configure".
$ ./configure --enable-shell-os
Of course, before running configure, look at the first several lines of config.log to see what other options may need to be included as well.
Then, re-build Centrallix. Use 'make' and 'make install', and/or if you are using the Kardia Virtual Appliance, use the 'Build' option in the 'Devel' menu.
Configuring Shell Objects
Here is a sample shell object:
$Version=2$
my_shell_command "system/shell"
{
program = "/bin/ls";
arg = "ls", "-la";
changeable = "LS_COLORS";
TERM="xterm";
LS_COLORS="";
require_endorsements = "system:from_application";
}
The above object runs the "ls" command with the "-la" parameter passed to it. Note that argument zero is also required to be passed (the "ls" in the "arg" setting). If you're not familiar with argument zero usage, just set it as identical to the command name, without the leading path.
In the above sample, two environment variables are passed to the "ls" command, XTERM and LS_COLORS. Only LS_COLORS may be modified by the user invoking the shell object; XTERM is readonly.
Invoking Shell Objects
To invoke a shell object, you need to open it and read from its content. To invoke a shell object from a SQL script, you need to read its 'objcontent' attribute:
select
:objcontent
from
object /path/to/my_shell_command.shl?LS_COLORS=test
In the above case, 'objcontent' will contain the output of the shell command when it completes.
Comments...
(none yet)
Add a Comment...
|