diff --git a/ajaxterm/index.cgi b/ajaxterm/index.cgi
index bc3ffd8f8..47e5ad6f4 100755
--- a/ajaxterm/index.cgi
+++ b/ajaxterm/index.cgi
@@ -1,24 +1,31 @@
#!/usr/local/bin/perl
# Start the Ajaxterm webserver on a random port, then print an iframe for
# a URL that proxies to it
+use strict;
+use warnings;
BEGIN { push(@INC, ".."); };
use WebminCore;
use Socket;
+our(%text, %config, %gconfig);
+our $module_root_directory;
+our $module_name;
+
&init_config();
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
# Check for python
-$python = &has_command("python");
+my $python = &has_command("python");
if (!$python) {
&ui_print_endpage(&text('index_epython', "python"));
}
# Pick a free port
+my %miniserv;
&get_miniserv_config(\%miniserv);
-$port = $miniserv{'port'} + 1;
-$proto = getprotobyname('tcp');
+my $port = $miniserv{'port'} + 1;
+my $proto = getprotobyname('tcp');
socket(TEST, PF_INET, SOCK_STREAM, $proto) ||
&error("Socket failed : $!");
setsockopt(TEST, SOL_SOCKET, SO_REUSEADDR, pack("l", 1));
@@ -29,17 +36,17 @@ while(1) {
close(TEST);
# Run the Ajaxterm webserver
-$pid = fork();
+my $pid = fork();
if (!$pid) {
chdir("$module_root_directory/ajaxterm");
- $logfile = $ENV{'WEBMIN_VAR'}.'/ajaxterm.log';
- untie(*STDIN); open(STDIN, "$logfile");
- untie(*STDERR); open(STDERR, ">$logfile");
- $shell = &has_command("bash") ||
+ my $logfile = $ENV{'WEBMIN_VAR'}.'/ajaxterm.log';
+ untie(*STDIN); open(STDIN, "<", "/dev/null");
+ untie(*STDOUT); open(STDOUT, ">", $logfile);
+ untie(*STDERR); open(STDERR, ">", $logfile);
+ my $shell = &has_command("bash") ||
&has_command("sh") || "/bin/sh";
- @uinfo = getpwnam("root");
- $home = $uinfo[7] || "/";
+ my @uinfo = getpwnam("root");
+ my $home = $uinfo[7] || "/";
$shell = "$shell -c ".quotemeta("cd '$home' ; exec $shell");
exec($python, "ajaxterm.py", "--port", $port, "--log",
$config{'autologin'} ? ("--command", $shell) : ( ));
@@ -47,7 +54,9 @@ if (!$pid) {
}
# Wait for it to come up
-$try = 0;
+my $try = 0;
+no strict "subs"; # TEST2 is weird. I dunno how to make it lexical without breaking.
+no warnings;
while(1) {
my $err;
&open_socket("localhost", $port, TEST2, \$err);
@@ -59,6 +68,8 @@ while(1) {
sleep(1);
}
close(TEST2);
+use strict "subs";
+use warnings;
# Show the iframe
print "
\n";
@@ -74,7 +85,7 @@ if (!fork()) {
untie(*STDIN); close(STDIN);
untie(*STDOUT); close(STDOUT);
untie(*STDERR); close(STDERR);
- $statfile = "$ENV{'WEBMIN_VAR'}/ajaxterm/$port";
+ my $statfile = "$ENV{'WEBMIN_VAR'}/ajaxterm/$port";
while(1) {
my @st = stat($statfile);
if (@st && time() - $st[9] > $config{'timeout'}) {
diff --git a/ajaxterm/proxy.cgi b/ajaxterm/proxy.cgi
index 29dc31d7a..13d9e4f1e 100755
--- a/ajaxterm/proxy.cgi
+++ b/ajaxterm/proxy.cgi
@@ -1,5 +1,7 @@
#!/usr/local/bin/perl
# Proxy an Ajaxterm request to the real port
+use strict;
+use warnings;
BEGIN { push(@INC, ".."); };
use WebminCore;
@@ -11,29 +13,33 @@ use WebminCore;
# Parse out port
$ENV{'PATH_INFO'} =~ /^\/(\d+)(.*)$/ ||
&error("Missing or invalid PATH_INFO");
-$port = $1;
-$path = $2;
+my $port = $1;
+my $path = $2;
$| = 1;
-$meth = $ENV{'REQUEST_METHOD'};
+my $meth = $ENV{'REQUEST_METHOD'};
# Connect to the Ajaxterm server, send HTTP request
-$con = &make_http_connection("localhost", $port, 0, $meth, $path);
+my $con = &make_http_connection("localhost", $port, 0, $meth, $path);
&error($con) if (!ref($con));
&write_http_connection($con, "Host: localhost\r\n");
&write_http_connection($con, "User-agent: Webmin\r\n");
-$cl = $ENV{'CONTENT_LENGTH'};
+my $cl = $ENV{'CONTENT_LENGTH'};
&write_http_connection($con, "Content-length: $cl\r\n") if ($cl);
&write_http_connection($con, "Content-type: $ENV{'CONTENT_TYPE'}\r\n")
if ($ENV{'CONTENT_TYPE'});
&write_http_connection($con, "\r\n");
+my $post;
if ($cl) {
- &read_fully(STDIN, \$post, $cl);
+ &read_fully(\*STDIN, \$post, $cl);
&write_http_connection($con, $post);
}
# read back the headers
-$dummy = &read_http_connection($con);
+my $dummy = &read_http_connection($con);
+my %header;
+my $headers;
while(1) {
+ my $headline;
($headline = &read_http_connection($con)) =~ s/\r|\n//g;
last if (!$headline);
$headline =~ /^(\S+):\s+(.*)$/ || &error("Bad header");
@@ -43,16 +49,17 @@ while(1) {
print $headers,"\n";
# read back contents
-while($buf = &read_http_connection($con, 1024)) {
+while(my $buf = &read_http_connection($con, 1024)) {
print $buf;
}
&close_http_connection($con);
# Touch status file to indicate it is still running
-$statusdir = $ENV{'WEBMIN_VAR'}."/ajaxterm";
+my $statusdir = $ENV{'WEBMIN_VAR'}."/ajaxterm";
if (!-d $statusdir) {
&make_dir($statusdir, 0700);
}
-&open_tempfile(TOUCH, ">$statusdir/$port", 0, 1);
-&close_tempfile(TOUCH);
+my $TOUCH;
+&open_tempfile($TOUCH, ">$statusdir/$port", 0, 1);
+&close_tempfile($TOUCH);
diff --git a/apache/apache-lib.pl b/apache/apache-lib.pl
index 49ed4808a..a3dbfbe69 100755
--- a/apache/apache-lib.pl
+++ b/apache/apache-lib.pl
@@ -676,8 +676,8 @@ elsif (!$olddir && $newdir) {
# Update the line numbers and filenames in a list of directives
sub recursive_set_lines_files
{
-local ($dirs, $line, $file) = @_;
-foreach my $d (@$dirs) {
+my ($dirs, $line, $file) = @_;
+foreach my $dir (@$dirs) {
$dir->{'line'} = $line;
$dir->{'file'} = $file;
if ($dir->{'type'}) {