home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/perl
- #
- # $Log
-
- ($me = $0) =~ s,^.*/([^/]+)$,$1,;
- $v=1;
-
- while (<>) {
- chop;
- unless ( /^[^#]/ && /^(\S+):(.*)/ ) {
- print $_, "\n";
- next;
- }
- $aliases{$alias = $1}++;
- if (! ($rhs = $2)) {
- print stderr "null rhs to $alias, assuming nobody\n";
- print "$alias: nobody\n";
- $errors++;
- next;
- }
- if ($aliases{$alias} > 1) {
- $errors++;
- if ($aliases{$alias} == 2) {
- print stderr "skipping dup lhs: $_\n";
- } else {
- $suppressed++;
- }
- next;
- }
- if ( /:include:(\S+)$/ ) {
- $file = $1;
- if ((($st_dev, $st_ino, $st_mode, $st_nlink,
- $st_uid, $st_gid, $st_rdev, $st_size,
- $st_atime, $st_mtime, $st_ctime,
- $st_blksize, $st_blocks) = stat($file)) != 13) {
- print stderr "error expanding $alias: stat $file: $!\n";
- $errors++;
- next;
- } ;
- if ($st_size > 1024) {
- #printf stderr
- #"include file for \"%s\" too big (%d) -- expansion would break dbm\n",
- #$alias, $st_size;
- printf "%s\n", $_;
- $count++;
- $errors++;
- $toobig++;
- next;
- }
- if (!open file) {
- print stderr "error expanding $alias: open $file: $!\n";
- $errors++;
- next;
- }
- $newalias = "";
- $printed = 0;
- reset 'n'; # clear name array of people seen on this alias
- $len = length($alias) + 2;
- while ($lhs = <file>) {
- chop($lhs);
- $lhs =~ s/#.*//;
- next unless $lhs;
- next if $name{$lhs}++;;
- if (! $printed) {
- $newalias .= "$alias: ";
- } else { # continuation
- if ($len + length($lhs) > 77) {
- $newalias .= ",\n\t";
- $len = 8;
- } else {
- $newalias .= "," if $printed;
- $len += 2;
- }
- }
- $newalias .= $lhs;
- $len += length($lhs);
- $printed++;
- }
- close file;
- if (($alisize = length($newalias)) > 1024) {
- #printf stderr
- #"post-burst alias \"%s\" too big (%d) -- expansion would break dbm\n",
- #$alias, $alisize;
- printf "%s\n", $_;
- $count++;
- $errors++;
- $toobig++;
- next;
- }
- printf "%s\n", $newalias;
- if (!$printed) {
- print stderr "null rhs to $alias, assuming nobody\n";
- print "$alias: nobody\n";
- $errors++;
- } else {
- print "\n";
- }
- $count++;
- next;
- }
- if ( s/(\s+)$// ) {
- print stderr "trimmed trailing whitespace on $alias\n";
- $errors++;
- }
- if ($rhs eq 'nonuser' || $rhs eq 'exuser') {
-
- }
- printf "%s\n", $_;
- $count++;
- }
-
- printf stderr "%s: processed %d legit alias%s",
- $me, $count, ($count != 1) ? "es" : "";
-
- if ($errors) {
- printf stderr ": %d problem%s", $errors, do S($errors);
- if ($suppressed || $toobig) {
- $serious = $errors - ($suppressed + $toobig);
- printf stderr "\n\t%4d serious error%s",$serious,do S($serious);
- $suppressed &&
- (printf stderr "\n\t%4d dup%s not printed",
- $suppressed, do S($suppressed));
- $toobig &&
- printf stderr "\n\t%4d include%s too big for dbm to swallow",
- $toobig, do S($toobig);
- }
- }
-
- print stderr "\n";
-
- exit ($errors != 0);
-
- sub S {
- local($count) = @_;
- ($count == 1) ? "" : "s";
- }
-