#-----------------------------------------------------------------------------
#
# Check for presence of patch #65.
# It corrects the bug in sgihelp that is _VERY_ bad.
#

&pcheck('Patch 65');

@tmp = ('/usr/sbin/printers', '/usr/Cadmin/bin/clogin', '/usr/sbin/scanners');

$md5{'/usr/sbin/printers'}     = 'b4400aad8c1778f29c30371414977a6d';
$md5{'/usr/sbin/printers.o'}   = '117be86ea3021a42994c49c2a839734a';
$md5{'/usr/Cadmin/bin/clogin'} = 'b9f2d8e997181f5235fbcd62589f522a';
$md5{'/usr/sbin/scanners'}     = '236bffea44a50c93526d7127d48fcb87';

## this section builds the test dynamically
$test = "1 ";
foreach $i (@tmp) {
  if ((-e $i) && $md5{"$i.o"}) {
    $test .= '&& ((&getmd5(' . "'$i'" . ') eq $md5{' . "'$i'" .
      '}) || (&getmd5(' . "'$i'" . ') eq $md5{' . "'$i.o'" . '}))';
    }
  elsif (-e $i) {
    $test .= '&& (&getmd5(' . "'$i'" . ') eq $md5{' . "'$i'" . '}) ';
    }
  }

if ($versions{'patchSG0000065'} || (eval $test)) {
  &report("INFO:  Congradulations, Patch 65 is installed properly.\n");
  &passed;
  }
else {
  &report("DANGER: Patch 65 vulnerability (VERY, VERY BAD)\n",
    "  To fix: get patch 65 from the TAC.\n");
  &failed;
  }

exit 0;

