--- loncom/lonnet/perl/londns.pm 2007/03/28 00:12:59 1.1 +++ loncom/lonnet/perl/londns.pm 2017/11/30 14:33:35 1.4 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # A debugging harness. # -# $Id: londns.pm,v 1.1 2007/03/28 00:12:59 albertel Exp $ +# $Id: londns.pm,v 1.4 2017/11/30 14:33:35 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,13 +36,16 @@ use Apache::lonnet; sub serve_file { my ($r,$file,$type)=@_; - open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/$file"); - my $file = join('',<$config>); - $r->content_type($type); - $r->send_http_header; - return OK if $r->header_only; - $r->print($file); - return OK; + if (open(my $config,"<","$Apache::lonnet::perlvar{'lonTabDir'}/$file")) { + my $contents = join('',<$config>); + $r->content_type($type); + $r->send_http_header; + return OK if $r->header_only; + $r->print($contents); + return OK; + } else { + return FORBIDDEN; + } } sub handler { @@ -53,6 +56,9 @@ sub handler { return &serve_file($r,'dns_hosts.tab','loncapa/hosts'); } elsif ($command eq 'domain') { return &serve_file($r,'dns_domain.tab','loncapa/domain'); + } elsif ($command eq 'checksums') { + my $version = (split('/',$r->uri))[4]; + return &serve_file($r,"dns_checksums/$version.tab",'loncapa/versions'); } return FORBIDDEN; }