version 1.4, 2013/02/06 13:47:47
|
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 130 sub compare_checksums {
|
Line 149 sub compare_checksums {
|
} else { |
} else { |
$linefeed = "\n"; |
$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 148 sub compare_checksums {
|
Line 170 sub compare_checksums {
|
$numchg ++; |
$numchg ++; |
} |
} |
} else { |
} else { |
unless ((-e $key) && (-B $key)) { |
$missing{$key} = 1; |
$missing{$key} = 1; |
$numchg ++; |
$numchg ++; |
|
} |
|
} |
} |
} |
} |
foreach my $key (keys(%{$serversums})) { |
foreach my $key (keys(%{$serversums})) { |
Line 274 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 310 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 { |