#
# checks for what look like logfile rotations and looks to see if
# there's a umask 033 there, which is mildly insecure.
#

$failed = 0;
$file = '/usr/spool/cron/crontabs/root';
&pcheck('Root crontab umask settings');
if (-e $file) {
  open(FILE, $file);
  while (<FILE>) {
    if (substr($_, 0, 1) eq '#') { next; }
    @tmp = split(/\s+/, $_);
    $tmp = '';
    foreach $i (5..$#tmp) {
      $tmp .= "$tmp[$i] ";
      }
    if (($tmp =~ /^umask 033/) && (/wc -c/)) { ## umask is insecure
      $failed = 1;
      push(@tmp2, $.);
      }
    }
  close(FILE);
  }
if ($failed) {
  &report("WARNING:  in $file, the following\n");
  &report("  lines had what appear to be logfile rotations with umasks\n");
  &report("  of 033 (which should probably be 077)\n");
  foreach $i (0..$#tmp2) {
    &report("  line $tmp2[$i]\n");
    }
  &report("\n");
  &warn;
  }
else {
  &report("INFO:  There are no umask settings in root's crontab file\n",
          "       that look insecure.\n");
  &passed;
  }

exit 0;
