Annotation of loncom/cgi/lonmodulecheck.pl, revision 1.5
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.5 ! raeburn 6: # $Id: lonmodulecheck.pl,v 1.4 2013/09/10 17:44:01 bisitz 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) = @_;
1.3 raeburn 61: if (&LONCAPA::lonauthcgi::check_ipbased_access('checksums')) {
62: &LONCAPA::loncgi::check_cookie_and_load_env();
63: } else {
1.1 raeburn 64: if (!&LONCAPA::loncgi::check_cookie_and_load_env()) {
65: &Apache::lonlocal::get_language_handle();
66: print(&LONCAPA::loncgi::missing_cookie_msg());
67: return;
68: }
69:
70: if (!&LONCAPA::lonauthcgi::can_view('checksums')) {
71: &Apache::lonlocal::get_language_handle();
72: print(&LONCAPA::lonauthcgi::unauthorized_msg('checksums'));
73: return;
74: }
75: }
76:
77: &print_differences($londaemons,$lonlib,$lonincludes,$lontabdir,$lonhost);
78: return;
79: }
80:
81: sub print_differences {
82: my ($londaemons,$lonlib,$lonincludes,$lontabdir,$lonhost) = @_;
83: my $machine_dom = &Apache::lonnet::host_domain($lonhost);
1.5 ! raeburn 84: my $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom,$lonhost);
1.1 raeburn 85: my ($version,$timestamp) = split(/\-/,$loncaparev);
1.2 raeburn 86: &Apache::lonlocal::get_language_handle();
87: print(&Apache::loncommon::start_page('Code integrity check'));
1.1 raeburn 88: if ($loncaparev =~ /CVS_HEAD/) {
1.2 raeburn 89: print('<h3>'.
90: &Apache::lonlocal::mt('Code checking unavailable for LON-CAPA CVS HEAD').
91: '</h3>');
1.1 raeburn 92: } else {
1.2 raeburn 93: print('<h3>'.
1.4 bisitz 94: &Apache::lonlocal::mt('Code integrity check -- LON-CAPA version: [_1]',
1.1 raeburn 95: $version).
1.2 raeburn 96: '</h3>');
97: my $distro = &LONCAPA::distro();
1.1 raeburn 98: if ($distro) {
99: my ($serversums,$serverversions) =
100: &LONCAPA::Checksumming::get_checksums($distro,$londaemons,$lonlib,
101: $lonincludes,$lontabdir);
102: if ((ref($serversums) eq 'HASH') && (ref($serverversions) eq 'HASH')) {
103: if (keys(%{$serversums}) > 0) {
104: my ($result,$numchg) =
105: &LONCAPA::Checksumming::compare_checksums('web',$lonhost,
106: $version,
107: $serversums,
108: $serverversions);
109: print($result);
110: } else {
111: print(&Apache::lonlocal::mt('No comparison attempted - failed to retrieve checksums for installed files.'));
112: }
113: } else {
114: print(&Apache::lonlocal::mt('No comparison attempted - failed to retrieve checksums for installed files.'));
115: }
116: } else {
117: print(&Apache::lonlocal::mt('No comparison attempted - unable to determine Linux distribution.'));
118: }
119: }
120: print(&Apache::loncommon::end_page());
121: return;
122: }
123:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>