--- loncom/cgi/lonauthcgi.pm 2010/04/14 18:06:22 1.6 +++ loncom/cgi/lonauthcgi.pm 2011/10/14 20:50:54 1.7 @@ -1,7 +1,7 @@ # # LON-CAPA authorization for cgi-bin scripts # -# $Id: lonauthcgi.pm,v 1.6 2010/04/14 18:06:22 raeburn Exp $ +# $Id: lonauthcgi.pm,v 1.7 2011/10/14 20:50:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -55,9 +55,11 @@ package LONCAPA::lonauthcgi; use strict; use lib '/home/httpd/lib/perl'; +use Socket; use Apache::lonnet; use Apache::lonlocal; use LONCAPA; +use LONCAPA::Configuration(); ############################################# ############################################# @@ -94,6 +96,10 @@ sub check_ipbased_access { return $allowed; } } + if (&is_manager_ip($ip)) { + $allowed = 1; + return $allowed; + } if ($page ne 'ping') { my @poss_domains = &Apache::lonnet::current_machine_domains(); foreach my $dom (@poss_domains) { @@ -115,6 +121,45 @@ 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 = ) { + 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