version 1.1, 2013/02/02 00:22:43
|
version 1.11, 2023/05/15 02:34:51
|
Line 34 use strict;
|
Line 34 use strict;
|
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use Apache::lonlocal(); |
use Apache::lonlocal(); |
use Apache::loncommon(); |
use Apache::loncommon(); |
|
use Digest::SHA; |
|
|
sub get_checksums { |
sub get_checksums { |
my ($distro,$londaemons,$lonlib,$lonincludes,$lontabdir) = @_; |
my ($distro,$londaemons,$lonlib,$lonincludes,$lontabdir) = @_; |
Line 48 sub get_checksums {
|
Line 49 sub get_checksums {
|
} |
} |
if ($lonlib) { |
if ($lonlib) { |
push(@paths,($lonlib.'/perl/Apache/*.pm', |
push(@paths,($lonlib.'/perl/Apache/*.pm', |
|
$lonlib.'/perl/Apache/math_parser/*.pm', |
$lonlib.'/perl/Apache/localize/*.pm', |
$lonlib.'/perl/Apache/localize/*.pm', |
$lonlib.'/perl/LONCAPA/*.pm', |
$lonlib.'/perl/LONCAPA/*.pm', |
$lonlib.'/perl/AlgParser.pm', |
$lonlib.'/perl/AlgParser.pm', |
Line 62 sub get_checksums {
|
Line 64 sub get_checksums {
|
} |
} |
push(@paths,('/home/httpd/cgi-bin/*.pl','/home/httpd/cgi-bin/*.png')); |
push(@paths,('/home/httpd/cgi-bin/*.pl','/home/httpd/cgi-bin/*.png')); |
my $confdir = '/etc/httpd/conf'; |
my $confdir = '/etc/httpd/conf'; |
my $sha = 'SHA1'; |
|
if ($distro =~ /^(ubuntu|debian)(\d+)$/) { |
if ($distro =~ /^(ubuntu|debian)(\d+)$/) { |
$confdir = '/etc/apache2'; |
$confdir = '/etc/apache2'; |
if (($1 eq 'ubuntu') && ($2 >= 12)) { |
|
$sha = 'SHA'; |
|
} |
|
} elsif ($distro =~ /^sles(\d+)$/) { |
} elsif ($distro =~ /^sles(\d+)$/) { |
if ($1 >= 10) { |
if ($1 >= 10) { |
$confdir = '/etc/apache2'; |
$confdir = '/etc/apache2'; |
Line 78 sub get_checksums {
|
Line 76 sub get_checksums {
|
} |
} |
} |
} |
push(@paths,("$confdir/loncapa_apache.conf","$confdir/startup.pl")); |
push(@paths,("$confdir/loncapa_apache.conf","$confdir/startup.pl")); |
if ($sha eq 'SHA1') { |
if ($lontabdir) { |
require Digest::SHA1; |
push(@paths,$lontabdir.'/mydesk.tab'); |
} else { |
|
require Digest::SHA; |
|
} |
} |
if (@paths) { |
if (@paths) { |
my $pathstr = join (' ',@paths); |
my $pathstr = join (' ',@paths); |
if (open($dirh,"grep '$revtag' $pathstr |")) { |
if (open($dirh,"grep '$revtag' $pathstr 2>&1 |")) { |
while (my $line=<$dirh>) { |
while (my $line=<$dirh>) { |
if ($line =~ m{^([^#]+):#\s\\s[\w.]+,v\s([\d.]+)\s}) { |
if ($line =~ m{^([^#]+):#\s\\s[\w.]+,v\s([\d.]+)\s}) { |
$versions{$1} = $2; |
$versions{$1} = $2; |
Line 93 sub get_checksums {
|
Line 89 sub get_checksums {
|
} |
} |
close($dirh); |
close($dirh); |
} |
} |
|
if ($londaemons) { |
|
my @binaries = qw (apachereload lchttpdlogs lcinstallfile lciptables lcnfsoff lcnfson lcpasswd lcuserdel pwchange); |
|
foreach my $file (@binaries) { |
|
next if ($versions{"$londaemons/$file"}); |
|
if (-B "$londaemons/$file") { |
|
if (-T $londaemons.'/.'.$file) { |
|
if (open(my $fh,'<',$londaemons.'/.'.$file)) { |
|
while (my $line=<$fh>) { |
|
if ($line =~ m{^#\s\\s[\w.]+,v\s([\d.]+)\s}) { |
|
$versions{"$londaemons/$file"} = $1; |
|
last; |
|
} |
|
} |
|
close($fh); |
|
} |
|
if ($versions{"$londaemons/$file"}) { |
|
if (open(my $fh,'<',$londaemons.'/.'.$file)) { |
|
binmode $fh; |
|
my $sha_obj = Digest::SHA->new(); |
|
$sha_obj->addfile($fh); |
|
$chksums{"$londaemons/$file"} = $sha_obj->hexdigest; |
|
close($fh); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
foreach my $key (sort(keys(%versions))) { |
foreach my $key (sort(keys(%versions))) { |
next if ($key =~ /\.lpmlsave$/); |
next if ($key =~ /\.lpmlsave$/); |
my $sum; |
unless (exists($chksums{$key})) { |
if (open(my $fh,"<$key")) { |
if (open(my $fh,"<$key")) { |
binmode $fh; |
binmode $fh; |
my $sha_obj; |
my $sha_obj = Digest::SHA->new(); |
if ($sha eq 'SHA') { |
$sha_obj->addfile($fh); |
$sha_obj = Digest::SHA->new(); |
$chksums{$key} = $sha_obj->hexdigest; |
} else { |
close($fh); |
$sha_obj = Digest::SHA1->new(); |
|
} |
} |
$sha_obj->addfile($fh); |
|
$sum = $sha_obj->hexdigest; |
|
close($fh); |
|
$chksums{$key} = $sum; |
|
} |
} |
$output .= "$key,$versions{$key},$sum\n"; |
$output .= "$key,$versions{$key},$chksums{$key}\n"; |
} |
} |
} |
} |
if ($lontabdir ne '') { |
if ($lontabdir ne '') { |
Line 124 sub get_checksums {
|
Line 143 sub get_checksums {
|
|
|
sub compare_checksums { |
sub compare_checksums { |
my ($target,$lonhost,$version,$serversums,$serverversions) = @_; |
my ($target,$lonhost,$version,$serversums,$serverversions) = @_; |
my ($message,$numchg); |
my ($message,$numchg,$linefeed); |
|
if ($target eq 'web') { |
|
$linefeed = '<br />'; |
|
} else { |
|
$linefeed = "\n"; |
|
} |
|
if (!$Apache::lonlocal::lh) { |
|
&Apache::lonlocal::get_language_handle(); |
|
} |
if ((ref($serversums) eq 'HASH') && (keys(%{$serversums}))) { |
if ((ref($serversums) eq 'HASH') && (keys(%{$serversums}))) { |
my $checksums = &Apache::lonnet::fetch_dns_checksums(); |
my $checksums = &Apache::lonnet::fetch_dns_checksums(); |
my (%extra,%missing,%diffs,%stdsums,%stdversions); |
my (%extra,%missing,%diffs,%stdsums,%stdversions); |
Line 155 sub compare_checksums {
|
Line 182 sub compare_checksums {
|
} |
} |
} |
} |
if ($numchg) { |
if ($numchg) { |
$message = |
$message = |
&Apache::lonlocal::mt('[quant,_1,difference was,differences were] found'. |
&Apache::lonlocal::mt('[quant,_1,difference was,differences were] found'. |
' between LON-CAPA modules installed on your server ([_2])'. |
' between LON-CAPA modules installed on your server [_2]'. |
' and those expected for the LON-CAPA version ([_3])'. |
' and those expected for the LON-CAPA version you are'. |
' which you are running.',$numchg,$lonhost,$version); |
' currently running.',$numchg,"($lonhost)$linefeed"); |
if ($target eq 'web') { |
if ($target eq 'web') { |
$message = '<p>'.$message.'</p>'; |
$message = '<p>'.$message.'</p>'; |
} else { |
} else { |
Line 175 sub compare_checksums {
|
Line 202 sub compare_checksums {
|
} |
} |
} |
} |
if (@diffversion > 0) { |
if (@diffversion > 0) { |
my $text = |
my $text = |
&Apache::lonlocal::mt('The following [quant,_1,local file is a,local files are]'. |
&Apache::lonlocal::mt('The following [quant,_1,file is a,files are]'. |
' different version(s) from that expected for LON-CAPA [_2]:', |
' different version(s) from that expected for LON-CAPA [_2]:', |
scalar(@diffversion),$version); |
scalar(@diffversion),$version); |
if ($target eq 'web') { |
if ($target eq 'web') { |
Line 194 sub compare_checksums {
|
Line 221 sub compare_checksums {
|
my $revnum = $stdversions{$file}; |
my $revnum = $stdversions{$file}; |
if ($target eq 'web') { |
if ($target eq 'web') { |
$message .= &Apache::loncommon::start_data_table_row(). |
$message .= &Apache::loncommon::start_data_table_row(). |
'<td>'.$file.'<td>'."\n". |
'<td>'.$file.'</td>'."\n". |
'<td>'.$serverversions->{$file}.'</td>'."\n". |
'<td>'.$serverversions->{$file}.'</td>'."\n". |
'<td>'.$revnum.'</td>'."\n". |
'<td>'.$revnum.'</td>'."\n". |
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
Line 210 sub compare_checksums {
|
Line 237 sub compare_checksums {
|
$message .= "\n"; |
$message .= "\n"; |
} |
} |
} |
} |
|
if ($target eq 'web') { |
|
$message .= &Apache::loncommon::end_data_table().'<br />'; |
|
} else { |
|
$message .= "\n"; |
|
} |
} |
} |
if (@modified > 0) { |
if (@modified > 0) { |
my $text = |
my $text = |
&Apache::lonlocal::mt('The following [quant,_1,file appears,files appear]'. |
&Apache::lonlocal::mt('The following [quant,_1,file appears,files appear]'. |
' to have been modified locally:',scalar(@modified)); |
' to have been modified locally:',scalar(@modified)); |
if ($target eq 'web') { |
if ($target eq 'web') { |
Line 238 sub compare_checksums {
|
Line 270 sub compare_checksums {
|
"\n"; |
"\n"; |
} |
} |
} |
} |
|
if ($target eq 'web') { |
|
$message .= &Apache::loncommon::end_data_table().'<br />'; |
|
} else { |
|
$message .= "\n"; |
|
} |
} |
} |
} |
} |
if (keys(%missing) > 0) { |
if (keys(%missing) > 0) { |
Line 257 sub compare_checksums {
|
Line 294 sub compare_checksums {
|
foreach my $file (sort(keys(%missing))) { |
foreach my $file (sort(keys(%missing))) { |
my $revnum = $stdversions{$file}; |
my $revnum = $stdversions{$file}; |
if ($target eq 'web') { |
if ($target eq 'web') { |
$message .= '<td>'.$file.'<td>'."\n". |
$message .= &Apache::loncommon::start_data_table_row()."\n". |
|
'<td>'.$file.'</td>'."\n". |
'<td>'.$revnum.'</td>'."\n". |
'<td>'.$revnum.'</td>'."\n". |
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
} else { |
} else { |
Line 270 sub compare_checksums {
|
Line 308 sub compare_checksums {
|
$message .= "\n"; |
$message .= "\n"; |
} |
} |
} |
} |
|
if ($target eq 'web') { |
|
$message .= &Apache::loncommon::end_data_table(); |
|
} else { |
|
$message .= "\n"; |
|
} |
} |
} |
if (keys(%extra) > 0) { |
if (keys(%extra) > 0) { |
my $text = |
my $text = |
Line 288 sub compare_checksums {
|
Line 331 sub compare_checksums {
|
} |
} |
foreach my $file (sort(keys(%extra))) { |
foreach my $file (sort(keys(%extra))) { |
if ($target eq 'web') { |
if ($target eq 'web') { |
$message .= '<td>'.$file.'<td>'."\n". |
$message .= &Apache::loncommon::start_data_table_row()."\n". |
|
'<td>'.$file.'</td>'."\n". |
'<td>'.$serverversions->{$file}.'</td>'."\n". |
'<td>'.$serverversions->{$file}.'</td>'."\n". |
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
} else { |
} else { |
Line 298 sub compare_checksums {
|
Line 342 sub compare_checksums {
|
"\n"; |
"\n"; |
} |
} |
} |
} |
|
if ($target eq 'web') { |
|
$message .= &Apache::loncommon::end_data_table().'<br />'; |
|
} else { |
|
$message .= "\n"; |
|
} |
} |
} |
} else { |
} else { |
$message = &Apache::lonlocal::mt('No differences detected between installed files and files expected for LON-CAPA [_1]',$version); |
$message = &Apache::lonlocal::mt('No differences detected between installed files and files expected for LON-CAPA [_1]',$version); |