version 1.6, 2010/04/14 18:06:22
|
version 1.7, 2011/10/14 20:50:54
|
Line 55 package LONCAPA::lonauthcgi;
|
Line 55 package LONCAPA::lonauthcgi;
|
|
|
use strict; |
use strict; |
use lib '/home/httpd/lib/perl'; |
use lib '/home/httpd/lib/perl'; |
|
use Socket; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use LONCAPA; |
use LONCAPA; |
|
use LONCAPA::Configuration(); |
|
|
############################################# |
############################################# |
############################################# |
############################################# |
Line 94 sub check_ipbased_access {
|
Line 96 sub check_ipbased_access {
|
return $allowed; |
return $allowed; |
} |
} |
} |
} |
|
if (&is_manager_ip($ip)) { |
|
$allowed = 1; |
|
return $allowed; |
|
} |
if ($page ne 'ping') { |
if ($page ne 'ping') { |
my @poss_domains = &Apache::lonnet::current_machine_domains(); |
my @poss_domains = &Apache::lonnet::current_machine_domains(); |
foreach my $dom (@poss_domains) { |
foreach my $dom (@poss_domains) { |
Line 115 sub check_ipbased_access {
|
Line 121 sub check_ipbased_access {
|
} |
} |
|
|
############################################# |
############################################# |
|
############################################# |
|
|
|
sub is_manager_ip { |
|
my ($remote_ip) = @_; |
|
return if ($remote_ip eq ''); |
|
my ($directory,$is_manager); |
|
my $config=LONCAPA::Configuration::read_conf(); |
|
if (ref($config) eq 'HASH') { |
|
$directory = $config->{'lonTabDir'}; |
|
} |
|
if (defined($directory)) { |
|
if (open(MANAGERS, "$directory/managers.tab")) { |
|
while(my $host = <MANAGERS>) { |
|
chomp($host); |
|
next if ($host =~ /^\#/); |
|
my $ip = &Apache::lonnet::get_host_ip($host); |
|
if (defined($ip)) { |
|
if ($remote_ip eq $ip) { |
|
$is_manager = 1; |
|
last; |
|
} |
|
} else { |
|
my ($cluname,$dnsname) = split(/:/, $host); |
|
$ip = gethostbyname($dnsname); |
|
if (defined($ip)) { |
|
my $hostip = inet_ntoa($ip); |
|
if ($hostip = $remote_ip) { |
|
$is_manager = 1; |
|
} |
|
} |
|
} |
|
} |
|
close(MANAGERS); |
|
} |
|
} |
|
return $is_manager; |
|
} |
|
|
|
############################################# |
############################################# |
############################################# |
|
|
=pod |
=pod |