#-----------------------------------------------------------------------------
#
# Check for network being on, and then check /etc/config/portmap.options
# for a "-a something" which is more secure than not having it there.
#

$file = '/etc/config/portmap.options';
$tmp = 0;
&pcheck($file);
if ($chkconfig{'network'}) {
  if (-e $file) {
    open(FILE, $file);
    while (@tmp = split(/\s+/, <FILE>)) {
      if ($tmp[0] eq '-a') {
        if ((!$tmp[1] =~ /^\d+\.\d+\.\d+\.\d+,\d+\.\d+\.\d+\.\d+$/) ||
            (!$tmp[1] =~ /^\d+\.\d+\.\d+\.\d+$/)) {
          $improper = 1;
          }
        }
      }
    close(FILE);
    }
  else {  ## file not present
    &report("WARNING: $file is not present.\n",
            "  You can specify that only hosts in your subnet are\n",
            "  listened to for RPC calls by specifying options in\n",
            "  this file.  See the man page for portmap for more\n",
            "  information.\n\n");
    &warn;
    }
  if ($improper && (-e $file)) {
    &report("WARNING: $file is present, but improperly\n",
            "  configured. You can specify that only hosts in your\n",
            "  subnet are listened to for RPC calls by specifying\n",
            "  options in this file.  See the man page for portmap\n",
            "  for more information.\n\n");
    &warn;
    }
  elsif ((!$improper) && (-e $file)) {
    &report("INFO:  /etc/config/portmap.options is present and is\n",
            "       properly configured.\n");
    &passed;
    }
  }
else {
  &report("INFO:  Networking is turned off.\n");
  &passed;
  }  ## not really a problem if they're not networking.

exit 0;

