--- loncom/cgi/lonauthcgi.pm 2011/10/21 20:00:30 1.9 +++ loncom/cgi/lonauthcgi.pm 2021/01/04 03:57:04 1.14.2.2 @@ -1,7 +1,7 @@ # # LON-CAPA authorization for cgi-bin scripts # -# $Id: lonauthcgi.pm,v 1.9 2011/10/21 20:00:30 raeburn Exp $ +# $Id: lonauthcgi.pm,v 1.14.2.2 2021/01/04 03:57:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -92,7 +92,7 @@ sub check_ipbased_access { my ($page,$ip) = @_; my $allowed; if (!defined($ip)) { - $ip = $ENV{'REMOTE_ADDR'}; + $ip = &Apache::lonnet::get_requestor_ip(); } if ($ip eq '127.0.0.1') { $allowed = 1; @@ -197,10 +197,10 @@ sub check_domain_ip { my %remote_doms; my $allowed; if ($remote_ip ne '') { - if (&Apache::lonnet::hostname($remote_ip) ne '') { + my @remote_hosts = &Apache::lonnet::get_hosts_from_ip($remote_ip); + if (@remote_hosts) { my @poss_domains = &Apache::lonnet::current_machine_domains(); if (@poss_domains > 0) { - my @remote_hosts = &Apache::lonnet::get_hosts_from_ip($remote_ip); foreach my $hostid (@remote_hosts) { my $hostdom = &Apache::lonnet::host_domain($hostid); if ($hostdom ne '') { @@ -280,12 +280,13 @@ sub can_view { } } unless ($allowed) { + my %alloweddoms; foreach my $dom (@poss_domains) { my %domconfig = &Apache::lonnet::get_dom('configuration',['serverstatuses'], $dom); if ($Apache::lonnet::env{'request.role'} eq "dc./$dom/") { if ($page eq 'domconf') { - $allowed .= $dom.'&'; + $alloweddoms{$dom} = 1; } else { $allowed = 1; } @@ -295,7 +296,7 @@ sub can_view { my @okusers = split(/,/,$domconfig{'serverstatuses'}{$page}{'namedusers'}); if (grep(/^\Q$Apache::lonnet::env{'user.name'}:$Apache::lonnet::env{'user.domain'}\E$/,@okusers)) { if ($page eq 'domconf') { - $allowed .= $dom.'&'; + $alloweddoms{$dom} = 1; } else { $allowed = 1; } @@ -307,7 +308,9 @@ sub can_view { } } } - $allowed =~ s/\&$//; + if (($page eq 'domconf') && (!$allowed)) { + $allowed = join('&',sort(keys(%alloweddoms))); + } } } return $allowed; @@ -377,6 +380,8 @@ sub serverstatus_titles { 'loncron' => 'Generate Detailed Report', 'server-status' => 'Apache Status Page', 'codeversions' => 'LON-CAPA Module Versions', + 'checksums' => 'LON-CAPA Module Checking', + 'diskusage' => 'Course/Community Disk Usage', 'clusterstatus' => 'Domain status', 'metadata_keywords' => 'Display Metadata Keywords', 'metadata_harvest' => 'Harvest Metadata Searches', @@ -386,6 +391,8 @@ sub serverstatus_titles { 'toggledebug' => 'Toggle debug messages', 'ping' => 'Cause server to ping another server', 'domconf' => 'Text Display of Domain Configuration', + 'uniquecodes' => 'Six-character Course Codes', + 'coursecatalog' => 'Course/Community Catalog with enrollment data', ); return \%titles; }