/usr/lib/arc/arc-config-check is in nordugrid-arc-arex 5.0.5-1ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | #!/usr/bin/perl -w
=head1 NAME
arc-config-check - checks the arc.conf for inconsistencies, known problems
or (in a future development) just general bad taste.
=head1 SYNOPSIS
arc-config-check --printall
=head1 DESCRIPTION
The motivation behind this little script was to have a repository for
automated tests on issues that came up on the NorduGrid developers
mailing list. As such this script indicates directories that are not
present, checks host certificates, CA certificates and CRLs, validates
the sanity of ARC configuration and tests for clock skew.
BECAUSE EVERY INSTALLATION OF ARC IS DIFFERENT THIS UTILITY ONLY SUGGESTS
WHAT COULD BE WRONG. SOMETIMES IT IS OVERRESTRICTIVE. AND SOMETIMES IT
CAN MISS SOME MISCONFIGURATION. NEVER TREAT RESULTS PRODUCED BY IT AS
ULTIMATE TRUTH.
=head1 OPTIONS
=over 4
=item --config <string>
Specifies the location of the config file, by default it is /etc/arc.conf
=item --printall
Lists all variable names of the config file together with their values.
=item --timeserver <server>
Allows the specification of a server against which to test the local
system's time.
=item --skip-warnings
Do not show warnings.
=item --help
Quick summary of options,
=item --man
Detailed man page.
=item --openssl-path <filename>
Path to openssl binary, determined with 'which openssl' if not set.
=back
=cut
#################### P R E A M B E L and options parsing ####################
use strict;
use warnings;
use Getopt::Long;
my ($conffile,$printall,$skip_warnings,$help,$man)=("/etc/arc.conf",0,0,0,0);
#Please make sure this reference server is not one you administer yourself.\n";
my $timeserver="europe.pool.ntp.org";
my $globusloc = $ENV{"GLOBUS_LOCATION"};
my $arcloc = undef;
if (defined $ENV{"ARC_LOCATION"}) {
$arcloc = $ENV{"ARC_LOCATION"};
} else {
$arcloc = "/usr";
}
my $OS = `uname`;
chomp $OS;
my $usercert;
my $hostcert;
my $CApath;
my $opensslpath;
my $verbose=0;
my $debug=0;
GetOptions(
"config:s" => \$conffile,
"printall" => \$printall,
"skip-warnings" => \$skip_warnings,
"timeserver:s" => \$timeserver,
"openssl-path:s" => \$opensslpath,
"verbose" => \$verbose,
"debug" => \$debug,
"help" => \$help,
"man" => \$man
) or die "Could not parse options.\n";
if ( $man or $help ) {
# Load Pod::Usage only if needed.
require "Pod/Usage.pm";
import Pod::Usage;
pod2usage(1) if $help;
pod2usage(VERBOSE => 2) if $man;
}
# key counters
my $warnings=0;
my $errors=0;
$verbose=1 if $debug;
########## S E E D A S S U M P T I O N S F O R R U L E S ############
# Some bits of the configuration are dynamic and may cross-reference other
# bits of the configuration. This hash shall keep track of these.
my %introducedSections = (
"group" => [],
"gridftpd" => [],
"queue" => [],
"infosys/cluster/registration" => [],
"infosys/index" => [],
"infosys/se" => [],
"infosys/site" => [],
"janitor" => [],
"queue" => [],
"se" => []
);
print STDERR "The following sections have configurable subgroups: "
. join(", ",keys %introducedSections)."\n" if $verbose;
################ U T I L R O U T I N E S #################################
$opensslpath=`which openssl | tr -d '\n'` unless defined($opensslpath);
# prints and counts a warning
sub w($) {
my $s = shift;
if (!$skip_warnings) {
print STDERR "W: $s";
$warnings++;
}
}
# prints and counts an error
sub e($) {
my $s = shift;
print STDERR "E: $s";
$errors++;
}
sub v($) {
return unless $verbose or $debug;
my $s = shift;
print STDERR "$s";
}
####################### C H E C K S #######################################
=head1 PERFORMED TESTS
=over 4
=item timecheck
The current time is compared with an external time server. A clock
shift higher than a maximally allowed maxtimediff results in an error.
=cut
sub timecheck($$$) {
my ($timeserver, $maxtimediff, $maxtimediffwarn) = @_;
my $timeoffset = undef;
my $ntpdate = "/usr/sbin/ntpdate";
unless ( -x $ntpdate ) {
w("Could not find location of 'ntpdate'.\n");
return;
}
unless (open(NTPDATE, "$ntpdate -q $timeserver |")) {
w("Could not properly invoke 'ntpdate'.\n");
return;
}
while (<NTPDATE>) {
next unless m/^server/;
if (m/offset *[-+]?([0-9]*\.[0-9]*)/) {
$timeoffset = $1;
}
}
close NTPDATE;
if (defined $timeoffset) {
if (abs($timeoffset)>=$maxtimediff) {
e("Timecheck: Your time differs by more than " .
"$maxtimediff seconds ($timeoffset seconds) from the " .
"public time server '$timeserver'\n");
} elsif (abs($timeoffset)>=$maxtimediffwarn) {
w("Timecheck: Your time differs slightly " .
"($timeoffset seconds) from the public time " .
"server '$timeserver'.\n");
}
} else {
w("Timecheck: Can't check the time\n");
}
}
=item check of permissions
The permission to access several different directories are checked.
The first argument is the file to be checked. The second is the permission
that is should have. The third is a binary mask that selects the bits
that are to be inspected.
=cut
sub permcheck($$$) {
my ($filename, $p, $mask) = @_;
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);
$mode &= 07777;
printf "$filename: mode %04o to be compared with %04o at mask %04o\n",$mode,$p,$mask if $debug;
$mode &= $mask;
return ($p == $mode);
}
# this performs simple stateless checks of configuration entries
sub confchecktripel($$$) {
my ($block, $name, $value) = @_;
printf STDOUT "Checking in block %s, name %s, value %s\n",$block,$name,$value if ($verbose);
# check the certificate
if ($block eq "common" and $name eq "x509_user_cert") {
if (! -e $value) {
e("The host certificate '$value' does not exist or is unreadable.\n");
} elsif (! -O $value) {
e("The host certificate '$value' is not owned by this user.\n");
} elsif (!permcheck($value,0644,0777) and !permcheck($value,0444,0777)) {
e("Permission of '$value' must be 'rw-r--r--' or 'r--r--r--'\n");
}
else {
$hostcert=$value;
}
}
# check the key
elsif ($block eq "common" and $name eq "x509_user_key") {
if (! -e $value) {
e("The host key '$value' does not exist or is unreadable.\n");
} elsif (! -O $value) {
e("The host key '$value' is not owned by this user.\n");
} elsif (!permcheck($value,0400,0777)) {
e("Permission of '$value' must be 'r--------'\n");
}
}
# check the certificate direcotry
elsif ($block eq "common" and $name eq "x509_cert_dir") {
if (! -d $value) {
e("$name: The certificate directory does not exist.\n");
} else {
my @r0s=glob($value."/*.r0");
if ($#r0s == -1) {
w("$name: There are no certificate revocation lists.\n")
unless $skip_warnings;
} else {
require File::stat;
my $t=time();
my $maxdiffsecs=60*60*24*2; # two days
foreach my $r0 (@r0s) {
my ($dev,$ino,$mode,$nlink,
$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,
$blksize,$blocks)
= stat($r0);
if ($t < $mtime ) {
e("$r0: mtime in future\n");
} elsif ($t > $mtime + $maxdiffsecs) {
w("$r0: Older than $maxdiffsecs seconds. rerun fetch-crl\n");
}
}
}
$CApath=$value;
}
}
# check the cache directory
elsif ($block eq "grid-manager" and $name eq "cachedir") {
my @dirs=split(/\s+/,$value);
# If available, second dir is on workernode
my $d = $dirs[0];
if (! -d $d) {
e("cachedir: not existing at '$d'\n");
}
}
# check the controldir
elsif ($block eq "grid-manager" and $name eq "controldir") {
if (! -d $value) {
e("$value: control directory ($name) does not exist\n");
} elsif (!permcheck($value,0755,0777)) {
e("$value: directory ($name) should be 755\n");
}
}
# check all remaining directory entries of the grid-manager block for existence
elsif ($block eq "grid-manager" and $name =~ m/dir$/) {
if (! -d $value) {
e("$value: directory ($name) does not exist\n");
}
else {
v("$name exists.");
}
if ($name =~ /^(tmpdir)$/) {
if (! permcheck($value,0777,0777)) {
e("The tmpdir directory must be writable and have the sticky bit set (chmod +t \"$name\")\n");
}
}
}
# Check for logrotate paths
if ($block =~ /common|grid-manager|gridftp/ and $name eq 'logfile') {check_logrotate($block,$name,$value)};
# check for any mount dirs
if ($name eq "mount") {
if (! -d "$value") {
e("$value: directory ($name) does not exist\n");
}
else {
v("$name exists.");
}
}
# check few infosys commands
if ($block eq "infosys") {
if ($name eq "slapd_loglevel" and $value gt 0) {
w("slapd_loglevel > 0 should only be used for development. DO NOT USE for production and testing.\nConfigure bdii_debug_level=\"DEBUG\" instead.\n");
}
if ($name ne "bdii_debug_level" and $name =~ /^bdii/ ) {
e("Starting from release 13.02, BDII configuration commands are strongly deprecated. Use only for Development.\nThe only allowed command is bdii_debug_level\n");
}
# check logs locations for logrotation
if ($name =~ /providerlog|registrationlog/) {check_logrotate($block,$name,$value)};
}
# check compliance of AdminDomain name as a LDAP DNs
# TODO: add to startup script the capability of escaping special
# chars.
if ($block eq "infosys/admindomain") {
if ($name eq "name") {
w("Warning: $block $name not configured. Default AdminDomain name is UNDEFINEDVALUE.\n") if $value eq '';
# bad symbols from RFC 4514
my @syntaxerrors;
push (@syntaxerrors, ("\n\tThe following unicode chars are not allowed:", $&)) while ( $value =~ /\x{0022}|\x{002B}|\x{002C}|\x{003B}|\x{003C}|\x{003E}|\x{005C}/g );
push (@syntaxerrors, ("\n\tBlank space or \"#\" symbol at the beginning of name are not allowed")) if ( $value =~ /^#|^\s/ );
push (@syntaxerrors, ("\n\tBlank space at the end of name is not allowed")) if ( $value =~ /\s$/ );
push (@syntaxerrors, ("\n\tNull character unicode (U+0000) not allowed")) if ( $value =~ /\x{0000}/ );
e("$block option $name contains the following errors: @syntaxerrors \n\tLDAP Infosys will not start. \n\tPlease change AdminDomain name accordingly *\n") if @syntaxerrors;
}
}
}
# Checks log locations for standard location
sub check_logrotate($$$$) {
my ($block, $name, $value, $defaultlocation) = @_;
my $defaultpath = '/var/log/arc/';
my $defaultlocations = {
'commonlogfile' => $defaultpath.'gridftpd.log',
'grid-managerlogfile' => $defaultpath.'grid-manager.log',
'gridftpdlogfile' => $defaultpath.'gridftpd.log',
'infosysproviderlog' => $defaultpath.'infoprovider.log',
'infosysregistrationlog' => $defaultpath.'inforegistration.log'
};
$defaultlocation = $defaultlocations->{$block.$name} || $defaultpath;
if ($value ne $defaultlocation ) {
w("[$block] $name: $value is not in the default location ($defaultlocation). Logrotation will not work, check your system logrotation configuration files\n");
if ( $block =~ /common|grid-manager|gridftp/ ) {
w("[$block] supports independent logrotation. Check ARC CE System Administrator manual to configure. Disable system logrotate configuration for it if you do this!\n");
}
}
}
# Get all valid configuration parameters and blocks from arc.conf.reference.
# Dynamic blocks which match those in %introducedSections are not included.
sub validconfparams() {
my @validparams;
my @validblocks;
unless (open (ARCREF, "<$arcloc/share/arc/examples/arc.conf.reference")) {
w("Could not open arc.conf.reference. No arc.conf parameter checking will be done\n");
return ( \@validparams, \@validblocks );
}
while (my $line = <ARCREF>) {
if ($line =~ m/^#(\w*)\s*=(.*)$/) { # match #parameter="value"
my $name = $1;
# take out spaces and quotes
$name =~ s/^\s*//;
$name =~ s/\s*$//;
$name =~ s/^"(.*)"$/$1/;
$name =~ s/^'(.*)'$/$1/;
if (!grep(/^$name$/, @validparams)) {
push(@validparams, $name);
}
} elsif ($line =~ m|^#\[(.*)\]$|) { # match #[section]
my $blockname = $1;
my $dynamic = 0;
foreach my $k (keys %introducedSections) {
if ($blockname =~ m/^$k.*/) {
$dynamic = 1;
}
}
push(@validblocks, $blockname) if !$dynamic;
}
}
return ( \@validparams, \@validblocks );
}
=item configuration check
General checks on the sensibility of the arc.conf
=cut
sub confcheck($) {
my ($arcconf) = @_;
my $config = {};
unless (open (CONFIGFILE, "<$conffile")) {
e("Could not open '$arcconf' for reading.\n");
return;
}
# parameters which are allowed more than once
# taken from arc.conf.reference - somehow this needs to be kept in sync
my @multiple = ("voms_trust_chain", "source", "filter", "subject",
"file", "voms", "sessiondir", "cachedir",
"remotecachedir", "jobreport", "share_limit", "authplugin",
"allowsubmit", "copyurl", "linkurl", "definedshare",
"deliveryservice", "unixmap", "unixgroup", "unixvo", "dir",
"remotegmdirs", "allowreg", "cluster_owner", "authorizedvo",
"clustersupport", "opsys", "benchmark", "nodeaccess",
"localse", "cacheserver");
# valid parameter names and blocks
my ($validparams, $validblocks) = validconfparams();
my $blockname = undef;
my $blockcontents = 0;
my $c = 0;
my $vo_counter = 0;
while (my $line = <CONFIGFILE>) {
if ($line =~ m/^<\?xml version=.*\?>$/) {
w("XML configuration can not yet be validated\n");
return;
}
$c++;
next if $line =~ m/^#/;
next if $line =~ m/^\s*$/;
# a new block?
if ($line =~ m/^\s*\[(.+)\]\s*$/) {
if (defined $blockname and $blockcontents == 0) {
e("$arcconf: Block \"$blockname\" is empty\n");
}
$blockname = $1;
$blockcontents = 0;
# blocknames must be unique
# but there is a special case of vo-blocks...
if ($blockname eq "vo") {
$blockname .= "|" . ++$vo_counter;
}
if (defined $config->{$blockname}) {
if (!$skip_warnings) {
w("$arcconf:$c: Block '"
. $blockname
."' is defined multiple times\n");
}
$warnings++;
}
$config->{$blockname}{">]|found|[<"} = $c;
next;
}
my $name;
my $value;
# look out for crap
unless ($line =~ m/^([^=]*)=(.*)$/) {
e("$arcconf: $c: Line is erroneous!\n");
next;
}
$name = $1;
$value = $2;
$name =~ s/^\s*//;
$name =~ s/\s*$//;
$name =~ s/^"(.*)"$/$1/;
$name =~ s/^'(.*)'$/$1/;
$value =~ s/^\s*//;
$value =~ s/\s*$//;
$value =~ s/^"(.*)"$/$1/;
$value =~ s/^'(.*)'$/$1/;
if ($name =~ m/^"/ and $name !~ m/"$/
or $name =~ m/^'/ and $name !~ m/'$/
or $name !~ m/^"/ and $name =~ m/"$/
or $name !~ m/^'/ and $name =~ m/'$/) {
w("$arcconf: $c: badly quoted attribute name?\n");
}
if ($value =~ m/^"/ and $value !~ m/"$/
or $value =~ m/^'/ and $value !~ m/'$/
or $value !~ m/^"/ and $value =~ m/"$/
or $value !~ m/^'/ and $value =~ m/'$/) {
w("$arcconf: $c: badly quoted value?\n");
$warnings++;
}
# are we within a block?
unless (defined $blockname) {
e("$arcconf:$c: found value=name pair which is " .
"not part of a block\n");
next;
}
# check we have a valid parameter name
if (@$validparams != 0 and !grep(/^$name$/, @$validparams)) {
w("$arcconf:$c: found unknown parameter $name\n");
next;
}
# check if we know more about this kind of tripel
confchecktripel($blockname, $name, $value);
#count
$blockcontents++;
if ($config->{$blockname}{$name}) {
if (grep(/^$name$/, @multiple)) {
$config->{$blockname}{$name} .= ">]|sep|[<" . $value;
} else {
w("$arcconf:$c: duplicate parameter: ".$name."\n");
}
} else {
$config->{$blockname}{$name} = $value;
}
}
close CONFIGFILE;
check_completeness($config);
if ($printall) {
foreach my $key (sort { $config->{$a}{">]|found|[<"} <=> $config->{$b}{">]|found|[<"} } keys %$config) {
printf "\n# line: %d\n", $config->{$key}{">]|found|[<"};
if ($key =~ m/^(.*)\|[0-9]+$/) {
printf "[%s]\n", $1;
} else {
printf "[%s]\n", $key;
}
my $x = $config->{$key};
foreach my $item (sort keys %$x) {
next if $item eq ">]|found|[<";
foreach my $val (split />\]\|sep\|\[</, $config->{$key}{$item}) {
printf "%s=\"%s\"\n", $item, $val;
}
}
}
}
}
=item check for completeness
Return error if the presence of one value implies one of another
=cut
sub check_completeness() {
my $config=shift;
my @required=("common", "grid-manager", "infosys", "cluster");
my ($validparams, $validblocks) = validconfparams();
# testing for unknown
foreach my $k (keys %$config) {
next if grep(/^$k$/,@$validblocks);
my @secs;
map { push(@secs,$_) if $k=~/^$_/;} keys %introducedSections;
print STDERR "$k -> " . join(":",@secs)."\n" if $debug;
if (0 == @secs) {
unless ($skip_warnings) {
w("Unknown group identifier '$k'\n");
}
next;
}
elsif (1 < @secs) {
die "Programming error: found multiple sections "
.join(",",@secs)." to be prefixes of secion '$k'.\n";
}
my $secs1 = $secs[0];
unless (exists($introducedSections{$secs1})) {
die "Programming error: section '$secs1' not amongs keys of hash %introducedSections: "
. join(",",keys %introducedSections)."\n";
}
my $listref=$introducedSections{$secs1};
push @$listref,$k;
}
# testing for the missing
foreach my $k (@required) {
unless (exists($config->{$k})) {
e("Missing group identifier '$k'\n");
}
}
# hostname
my $hn=`hostname -f`;
chomp($hn);
my $hn_conf;
if (exists($config->{common}{hostname})) {
$hn_conf = $config->{common}{hostname};
}
elsif (exists($config->{cluster}{hostname})) {
$hn_conf = $config->{cluster}{hostname};
}
if ($hn_conf) {
if ($hn_conf ne "$hn") {
e("The entry of the full hostname (".$hn_conf
. ") is better\n"
." equal to `hostname -f` ($hn).\n"
." Also test reverse lookup of the hostname.\n");
}
}
else {
e("The entry hostname must not be missed.\n");
}
# lrms
if (!exists($config->{common}{lrms}) && !exists($config->{"grid-manager"}{lrms})) {
e("The entry lrms must not be missed.\n");
}
}
=item check of applications
Some applications are required for the server to be functional.
=cut
sub check_applications() {
unless ( -x "/usr/bin/time" ) {
e("Could not find GNU time utility (or a substitute) at /usr/bin/time.");
}
}
=item check of libraries
uses ldd to check if all libraries are installed
=cut
sub check_libraries() {
my $prob=0;
if (! defined($globusloc)) {
v("check_libraries: interpreting undefined GLOBUS_LOCATION as /usr\n");
$globusloc="/usr";
}
unless ( -e $globusloc) {
e("Cannot find Globus at $globusloc: no such file or directory\n");
$prob++;
}
if (defined($arcloc)) {
unless (-e $arcloc) {
e("Cannot find ARC at $arcloc: no such file or directory\n");
if (defined $ENV{"ARC_LOCATION"}) {
w("The location was retrieved from the environment variable 'ARC_LOCATION'. Maybe this needs an update.");
}
$prob++;
}
}
return if ($prob);
my @globmes = ( $arcloc . "/bin/arc*",
$arcloc . "/libexec/arc/gm*",
$arcloc . "/sbin/arc*",
$arcloc . "/sbin/grid*",
);
push(@globmes, $arcloc . "/lib/*") if "/usr" ne "$arcloc"; # takes too long, little gain expected
my @to_check;
foreach my $d (@globmes) {
@to_check = ( @to_check , glob $d );
}
if ($verbose) {
print "Checking the following files for their dependencies:\n";
print join("\n",@to_check);
print "\n";
}
my %missing;
foreach my $file ( @to_check ) {
next unless -f $file;
next if $file =~ m/\.a$/;
next if $file =~ m/\.la$/;
my $command = "LC_ALL=C ";
$command .= "LD_LIBRARY_PATH=";
$command .= "$arcloc/lib:" if "/usr" ne "$arcloc" and "/usr/" ne "$arcloc";
$command .= "\$LD_LIBRARY_PATH ";
$command .= "ldd $file 2>/dev/null |";
my %libs;
if (open LDD, $command) {
while (<LDD>) {
chomp;
my $lib = $_;
if ($lib =~ m/^\s*([^\s]+)\.so\.([^\s]+)\s*=>/) {
my $a=$1;
my $b=$2;
my $index=$a;
$index =~ s/_(gcc)(16|32|64|128|256)(dbg)?(pthr)?\././;
if (defined $libs{$index}) {
e("$file: uses multiple versions of lib " .
"$a: ".$libs{$index}." and $b. This might not work\n");
} else {
$libs{$index} = $b;
}
}
next unless /not found/;
$lib =~ m/^\s*([^\s]+)\s*=>/;
my $missing = $1;
unless (defined $missing{$missing}) {
$missing{$missing} = 1;
e("$file: needs $missing. Not found.\n");
}
}
close LDD;
} else {
if (!$skip_warnings) {
w("Cannot check used libraries of $file.\n");
}
}
}
}
sub check_certificates() {
# check if CAdir is present
if (!defined($CApath)) {
e("The x509_cert_dir was not set.\n");
$CApath="/etc/grid-security/certificates";
if ( ! -d $CApath) {
return;
}
}
elsif ( ! -d "$CApath") {
e("CApath does not exist at '$CApath");
return;
}
unless (defined($opensslpath) and "" ne "$opensslpath") {
w("openssl application not in path and not specified.\n");
return;
}
unless ( -x "$opensslpath") {
e("Cannot execute openssl application at '$opensslpath'");
}
# check of host certificate
if (!defined($hostcert)) {
$hostcert="/etc/grid-security/hostcert.pem";
}
if ( -f $hostcert) {
if (system("$opensslpath verify -CApath $CApath $hostcert | grep 'OK'")) {
e("Verification of host cert at $hostcert with $opensslpath failed.\n");
}
if (!system("$opensslpath verify -CApath $CApath $hostcert | grep 'expired'")) {
e("Host certificate $hostcert has expired.\n");
}
}
else {
if (!$skip_warnings) {
w("Not verifying host cert which is not present at $hostcert (should already be reported).\n");
}
}
}
timecheck($timeserver, 0.2, 0.01);
confcheck($conffile);
check_applications();
check_libraries();
check_certificates();
if (0 == $errors) {
print "Found no apparent failures.\n";
} else {
printf "Found %d failure%s.\n", $errors, ($errors > 1) ? "s" : "";
}
if ($warnings) {
printf "Found %d non-critical issue%s%s.\n",
$warnings, ($warnings > 1) ? "s" : "",
($skip_warnings?" (not shown)":"");
}
exit $errors;
=back
=head1 SEE ALSO
http://www.nordugrid.org and our mailing lists.
=cut
# EOF
|