--- loncom/configuration/Checksumming.pm 2013/02/02 15:20:02 1.2
+++ loncom/configuration/Checksumming.pm 2023/05/15 02:31:01 1.10
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Checksum installed LON-CAPA modules and some configuration files
#
-# $Id: Checksumming.pm,v 1.2 2013/02/02 15:20:02 raeburn Exp $
+# $Id: Checksumming.pm,v 1.10 2023/05/15 02:31:01 raeburn Exp $
#
# The LearningOnline Network with CAPA
#
@@ -34,6 +34,7 @@ use strict;
use lib '/home/httpd/lib/perl/';
use Apache::lonlocal();
use Apache::loncommon();
+use Digest::SHA;
sub get_checksums {
my ($distro,$londaemons,$lonlib,$lonincludes,$lontabdir) = @_;
@@ -48,6 +49,7 @@ sub get_checksums {
}
if ($lonlib) {
push(@paths,($lonlib.'/perl/Apache/*.pm',
+ $lonlib.'/perl/Apache/math_parser/*.pm,
$lonlib.'/perl/Apache/localize/*.pm',
$lonlib.'/perl/LONCAPA/*.pm',
$lonlib.'/perl/AlgParser.pm',
@@ -62,12 +64,8 @@ sub get_checksums {
}
push(@paths,('/home/httpd/cgi-bin/*.pl','/home/httpd/cgi-bin/*.png'));
my $confdir = '/etc/httpd/conf';
- my $sha = 'SHA1';
if ($distro =~ /^(ubuntu|debian)(\d+)$/) {
$confdir = '/etc/apache2';
- if (($1 eq 'ubuntu') && ($2 >= 12)) {
- $sha = 'SHA';
- }
} elsif ($distro =~ /^sles(\d+)$/) {
if ($1 >= 10) {
$confdir = '/etc/apache2';
@@ -78,14 +76,12 @@ sub get_checksums {
}
}
push(@paths,("$confdir/loncapa_apache.conf","$confdir/startup.pl"));
- if ($sha eq 'SHA1') {
- require Digest::SHA1;
- } else {
- require Digest::SHA;
+ if ($lontabdir) {
+ push(@paths,$lontabdir.'/mydesk.tab');
}
if (@paths) {
my $pathstr = join (' ',@paths);
- if (open($dirh,"grep '$revtag' $pathstr |")) {
+ if (open($dirh,"grep '$revtag' $pathstr 2>&1 |")) {
while (my $line=<$dirh>) {
if ($line =~ m{^([^#]+):#\s\\s[\w.]+,v\s([\d.]+)\s}) {
$versions{$1} = $2;
@@ -93,23 +89,46 @@ sub get_checksums {
}
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))) {
next if ($key =~ /\.lpmlsave$/);
- my $sum;
- if (open(my $fh,"<$key")) {
- binmode $fh;
- my $sha_obj;
- if ($sha eq 'SHA') {
- $sha_obj = Digest::SHA->new();
- } else {
- $sha_obj = Digest::SHA1->new();
+ unless (exists($chksums{$key})) {
+ if (open(my $fh,"<$key")) {
+ binmode $fh;
+ my $sha_obj = Digest::SHA->new();
+ $sha_obj->addfile($fh);
+ $chksums{$key} = $sha_obj->hexdigest;
+ close($fh);
}
- $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 '') {
@@ -125,11 +144,14 @@ sub get_checksums {
sub compare_checksums {
my ($target,$lonhost,$version,$serversums,$serverversions) = @_;
my ($message,$numchg,$linefeed);
- if ($target = 'web') {
+ if ($target eq 'web') {
$linefeed = '
';
} else {
$linefeed = "\n";
}
+ if (!$Apache::lonlocal::lh) {
+ &Apache::lonlocal::get_language_handle();
+ }
if ((ref($serversums) eq 'HASH') && (keys(%{$serversums}))) {
my $checksums = &Apache::lonnet::fetch_dns_checksums();
my (%extra,%missing,%diffs,%stdsums,%stdversions);
@@ -272,7 +294,8 @@ sub compare_checksums {
foreach my $file (sort(keys(%missing))) {
my $revnum = $stdversions{$file};
if ($target eq 'web') {
- $message .= '