Annotation of loncom/cgi/lonmodulecheck.pl, revision 1.2
1.1 raeburn 1: #!/usr/bin/perl
2: $|=1;
3: # Compares checksums for most installed files with expected values
4: # and reports discrepancies.
5: #
1.2 ! raeburn 6: # $Id: lonmodulecheck.pl,v 1.1 2013/02/02 00:22:34 raeburn Exp $
1.1 raeburn 7: #
8: # Copyright Michigan State University Board of Trustees
9: #
10: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
11: #
12: # LON-CAPA is free software; you can redistribute it and/or modify
13: # it under the terms of the GNU General Public License as published by
14: # the Free Software Foundation; either version 2 of the License, or
15: # (at your option) any later version.
16: #
17: # LON-CAPA is distributed in the hope that it will be useful,
18: # but WITHOUT ANY WARRANTY; without even the implied warranty of
19: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: # GNU General Public License for more details.
21: #
22: # You should have received a copy of the GNU General Public License
23: # along with LON-CAPA; if not, write to the Free Software
24: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25: #
26: # /home/httpd/html/adm/gpl.txt
27: #
28: # http://www.lon-capa.org/
29: #
30:
31: use strict;
32:
33: use lib '/home/httpd/lib/perl/';
34: use Apache::lonnet();
35: use Apache::lonlocal();
36: use LONCAPA::Configuration();
37: use LONCAPA::loncgi();
38: use LONCAPA::lonauthcgi();
39: use LONCAPA::Checksumming();
1.2 ! raeburn 40: use LONCAPA;
1.1 raeburn 41:
42: my $perlvar=&LONCAPA::Configuration::read_conf('loncapa.conf');
43: my ($londaemons,$lonlib,$lonincludes,$lontabdir,$lonhost);
44: if (ref($perlvar) eq 'HASH') {
45: $londaemons = $perlvar->{'lonDaemons'};
46: $lonlib = $perlvar->{'lonLib'};
47: $lonincludes = $perlvar->{'lonIncludes'};
48: $lontabdir = $perlvar->{'lonTabDir'};
49: $lonhost = $perlvar->{'lonHostID'};
50: }
51: undef($perlvar);
52:
53: print &LONCAPA::loncgi::cgi_header('text/html',1);
54: if ($londaemons ne '' && $lonlib ne '' && $lonincludes ne '' &&
55: $lontabdir ne '' && $lonhost ne '') {
56: &main($londaemons,$lonlib,$lonincludes,$lontabdir,$lonhost);
57: }
58:
59: sub main {
60: my ($londaemons,$lonlib,$lonincludes,$lontabdir,$lonhost) = @_;
61: if (!&LONCAPA::lonauthcgi::check_ipbased_access('checksums')) {
62: if (!&LONCAPA::loncgi::check_cookie_and_load_env()) {
63: &Apache::lonlocal::get_language_handle();
64: print(&LONCAPA::loncgi::missing_cookie_msg());
65: return;
66: }
67:
68: if (!&LONCAPA::lonauthcgi::can_view('checksums')) {
69: &Apache::lonlocal::get_language_handle();
70: print(&LONCAPA::lonauthcgi::unauthorized_msg('checksums'));
71: return;
72: }
73: }
74:
75: &print_differences($londaemons,$lonlib,$lonincludes,$lontabdir,$lonhost);
76: return;
77: }
78:
79: sub print_differences {
80: my ($londaemons,$lonlib,$lonincludes,$lontabdir,$lonhost) = @_;
81: my $machine_dom = &Apache::lonnet::host_domain($lonhost);
82: my $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom);
83: my ($version,$timestamp) = split(/\-/,$loncaparev);
1.2 ! raeburn 84: &Apache::lonlocal::get_language_handle();
! 85: print(&Apache::loncommon::start_page('Code integrity check'));
1.1 raeburn 86: if ($loncaparev =~ /CVS_HEAD/) {
1.2 ! raeburn 87: print('<h3>'.
! 88: &Apache::lonlocal::mt('Code checking unavailable for LON-CAPA CVS HEAD').
! 89: '</h3>');
1.1 raeburn 90: } else {
1.2 ! raeburn 91: print('<h3>'.
1.1 raeburn 92: &Apache::lonlocal::mt('Code integrity check -- LONCAPA version: [_1]',
93: $version).
1.2 ! raeburn 94: '</h3>');
! 95: my $distro = &LONCAPA::distro();
1.1 raeburn 96: if ($distro) {
97: my ($serversums,$serverversions) =
98: &LONCAPA::Checksumming::get_checksums($distro,$londaemons,$lonlib,
99: $lonincludes,$lontabdir);
100: if ((ref($serversums) eq 'HASH') && (ref($serverversions) eq 'HASH')) {
101: if (keys(%{$serversums}) > 0) {
102: my ($result,$numchg) =
103: &LONCAPA::Checksumming::compare_checksums('web',$lonhost,
104: $version,
105: $serversums,
106: $serverversions);
107: print($result);
108: } else {
109: print(&Apache::lonlocal::mt('No comparison attempted - failed to retrieve checksums for installed files.'));
110: }
111: } else {
112: print(&Apache::lonlocal::mt('No comparison attempted - failed to retrieve checksums for installed files.'));
113: }
114: } else {
115: print(&Apache::lonlocal::mt('No comparison attempted - unable to determine Linux distribution.'));
116: }
117: }
118: print(&Apache::loncommon::end_page());
119: return;
120: }
121:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>