#-----------------------------------------------------------------------------
#
# First, lets look at sendmail's version and see what it says
#

## open sendmail in test mode and general debugging.
## we redirect /dev/null in so that it will exit right away.
open(SENDMAIL, "/usr/lib/sendmail -bt -d0 < /dev/null |");

$tmp = <SENDMAIL>;  ## first line should have "Version foo" in it
close(SENDMAIL);    ## and that's all we need.

@tmp = split(/\s+/, $tmp);
$sendmailversion = $tmp[1];

## md5 for SGI's sendmail
$md5{'/usr/lib/sendmail'} = '508f7e91c4714e08b7fb2f8d064389af';

## IRIX 4.0.5 sendmail version looks like 950215.405.SGI.8.6.10
## sgi sendmail version looks like YYMMDD.SGI.XX where XX is 52 if it's a 5.2 version
if ((split(/\./, $sendmailversion))[2] eq 'SGI') {
  
  &pcheck('CA-95:05 (general sendmail)');
  
  ## make sure it's the latest (post CA-95:05 version) of sendmail
  if (&getmd5('/usr/lib/sendmail') ne $md5{'/usr/lib/sendmail'}) {
    &report("DANGER: CERT CA-95:05 vulnerability\n",
      "  It is vulnerable to CA-95:05, which is :\n",
      "    ftp://ftp.cert.org/pub/cert_advisories/CA-95:05.sendmail.vulnerabilities\n\n",
      "  It may also be vulnerable to CA-93:16, whcih is:\n",
      "    ftp://ftp.cert.org/pub/cert_advisories/CA-93:16.sendmail.vulnerability\n",
      "  SGI's fixed sendmail is available from\n",
      "    ftp://sgigate.sgi.com/patches/4.0.5/sendmail*\n\n");
    &failed;
    }
  else {
    &report("INFO:  You have a good version of SGI's sendmail.\n");
    &passed;
    }
  }

## check for EA sendmail version 8.6.10 or greater, if not running SGI sendmail
else {
  &pcheck('CA-93:16, CA-95:05 (general sendmail)');
  @tmp = split(/\./, $sendmailversion);
  if (($tmp[0] == 8) && ($tmp[1] == 6) && ($tmp[2] >= 10)) {
    &report("INFO:  You have a good version of Allman's sendmail.\n");
    &passed;
    }
  else {
    &report("DANGER: CERT CA-95:05/CA-93:16 vulnerability\n",
      "  To fix: Get Allman sendmail 8.6.10 or later. Or install the\n",
      "  SGI sendmail and rescan the system.\n",
      "  It is vulnerable to CA-95:05, which is:\n",
      "    ftp://ftp.cert.org/pub/cert_advisories/CA-95:05.sendmail.vulnerabilities\n",
      "  It may also be vulnerable to CA-93:16, whcih is:\n",
      "    ftp://ftp.cert.org/pub/cert_advisories/CA-93:16.sendmail.vulnerability\n",
      "  SGI's sendmail is available from\n",
      "    ftp://sgigate.sgi.com/patches/4.0.5/sendmail*\n\n");
    &failed;
    }
  }

exit 0;

