summaryrefslogtreecommitdiffstats
path: root/usr/local/sbin/pfSsh.php
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2007-11-19 04:30:04 +0000
committerScott Ullrich <sullrich@pfsense.org>2007-11-19 04:30:04 +0000
commit7116ab7f87b46f68b166a03f7ee393d4e818acc5 (patch)
tree9eb67a26ab03d3287e865471bd2a520a59ee0217 /usr/local/sbin/pfSsh.php
parent3d3be83663b7156f109a11500f82c079558000e9 (diff)
downloadpfsense-7116ab7f87b46f68b166a03f7ee393d4e818acc5.zip
pfsense-7116ab7f87b46f68b166a03f7ee393d4e818acc5.tar.gz
* Allow shell commands to be executed if you proceed the command with =
* Clean up carriage returns and make presentation look nicer
Diffstat (limited to 'usr/local/sbin/pfSsh.php')
-rwxr-xr-xusr/local/sbin/pfSsh.php38
1 files changed, 35 insertions, 3 deletions
diff --git a/usr/local/sbin/pfSsh.php b/usr/local/sbin/pfSsh.php
index 72e313b..41603ba 100755
--- a/usr/local/sbin/pfSsh.php
+++ b/usr/local/sbin/pfSsh.php
@@ -13,6 +13,18 @@ require("config.inc");
echo ".";
$g['booting'] = false;
+$shell_cmds = array("alias", "alloc", "bg", "bind", "bindkey", "break",
+ "breaksw", "builtins", "case", "cd", "chdir", "command", "complete", "continue", "default",
+ "dirs", "do", "done", "echo", "echotc", "elif", "else", "end", "endif", "endsw", "esac", "eval",
+ "exec", "exit", "export", "false", "fc", "fg", "filetest", "fi", "for", "foreach", "getopts",
+ "glob", "goto", "hash", "hashstat", "history", "hup", "if", "jobid", "jobs", "kill", "limit",
+ "local", "log", "login", "logout", "ls-F", "nice", "nohup", "notify", "onintr", "popd",
+ "printenv", "pushd", "pwd", "read", "readonly", "rehash", "repeat", "return", "sched", "set",
+ "setenv", "settc", "setty", "setvar", "shift", "source", "stop", "suspend", "switch",
+ "telltc", "test", "then", "time", "trap", "true", "type", "ulimit", "umask", "unalias",
+ "uncomplete", "unhash", "unlimit", "unset", "unsetenv", "until", "wait", "where", "which",
+ "while");
+
if(!function_exists("readline")) {
function readline() {
$fp = fopen('php://stdin', 'r');
@@ -106,16 +118,37 @@ $pkg_interface='console';
$shell_active = true;
-echo "Type \"help\" to show common usage scenarios.";
+echo "Welcome to the pfSense php shell system\n";
+echo "Written by Scott Ullrich (sullrich@gmail.com)\n";
+echo "\nType \"help\" to show common usage scenarios.\n";
while($shell_active == true) {
- $command = readline("\n\npfSense shell: ");
+ $command = readline("\npfSense shell: ");
if($command == "exit") {
$shell_active = false;
echo "\n";
break;
}
readline_add_history($command);
+ $command_split = split(" ", $command);
+ $first_command = $command_split[0];
+ switch($first_command) {
+ case "=":
+ $newcmd = "";
+ $counter = 0;
+ foreach($command_split as $cs) {
+ if($counter > 0)
+ $newcmd .= " {$cs}";
+ $counter++;
+ }
+ system("$newcmd");
+ if($command_split[1] == "cd") {
+ echo "\nChanging working directory to {$command_split[2]}.";
+ chdir($command_split[2]);
+ }
+ $command = "";
+ break;
+ }
if($command == "help") {
show_help();
$command = "";
@@ -140,7 +173,6 @@ while($shell_active == true) {
$command = $mlcommand;
}
if($command) {
- echo "\n";
eval($command);
}
}
OpenPOWER on IntegriCloud