From 79894dd2f526b62612cf0cebfa8773da4cb9fe3f Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 27 Apr 2011 15:16:39 -0700 Subject: [PATCH] Add option to login immediately, reduce latency by simplifying proxy.cgi --- ajaxterm/config | 1 + ajaxterm/config.info | 1 + ajaxterm/index.cgi | 5 ++++- ajaxterm/proxy.cgi | 7 +++++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ajaxterm/config b/ajaxterm/config index 6091b45d2..a31edabcb 100644 --- a/ajaxterm/config +++ b/ajaxterm/config @@ -1 +1,2 @@ +autologin=0 timeout=120 diff --git a/ajaxterm/config.info b/ajaxterm/config.info index 7472cef64..e70c333be 100644 --- a/ajaxterm/config.info +++ b/ajaxterm/config.info @@ -1 +1,2 @@ +autologin=Login mode,1,0-Prompt for username and password,1-Open root shell timeout=Idle timeout before closing connection,0,5,,seconds diff --git a/ajaxterm/index.cgi b/ajaxterm/index.cgi index 45a0ef9d0..b5d731c15 100755 --- a/ajaxterm/index.cgi +++ b/ajaxterm/index.cgi @@ -36,7 +36,10 @@ if (!$pid) { untie(*STDIN); open(STDIN, "$logfile"); untie(*STDERR); open(STDERR, ">$logfile"); - exec($python, "ajaxterm.py", "--port", $port, "--log"); + $shell = &has_command("bash") || + &has_command("sh") || "/bin/sh"; + exec($python, "ajaxterm.py", "--port", $port, "--log", + $config{'autologin'} ? ("--command", $shell) : ( )); exit(1); } diff --git a/ajaxterm/proxy.cgi b/ajaxterm/proxy.cgi index 02377a35a..29dc31d7a 100755 --- a/ajaxterm/proxy.cgi +++ b/ajaxterm/proxy.cgi @@ -3,7 +3,10 @@ BEGIN { push(@INC, ".."); }; use WebminCore; -&init_config(); + +# Since this script is run on every keypress, init_config is intentionally +# not called to reduce startup time. +#&init_config(); # Parse out port $ENV{'PATH_INFO'} =~ /^\/(\d+)(.*)$/ || @@ -46,7 +49,7 @@ while($buf = &read_http_connection($con, 1024)) { &close_http_connection($con); # Touch status file to indicate it is still running -$statusdir = $ENV{'WEBMIN_VAR'}."/".$module_name; +$statusdir = $ENV{'WEBMIN_VAR'}."/ajaxterm"; if (!-d $statusdir) { &make_dir($statusdir, 0700); }