| 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # Copyright 1996-2013 Ian Jackson <ijackson@chiark.greenend.org.uk> |
| 4 | # Copyright 1998 David Damerell <damerell@chiark.greenend.org.uk> |
| 5 | # Copyright 1999,2003 |
| 6 | # Chancellor Masters and Scholars of the University of Cambridge |
| 7 | # Copyright 2010 Tony Finch <fanf@dotat.at> |
| 8 | # |
| 9 | # This is free software; you can redistribute it and/or modify it |
| 10 | # under the terms of the GNU General Public License as published by |
| 11 | # the Free Software Foundation; either version 3 of the License, or |
| 12 | # (at your option) any later version. |
| 13 | # |
| 14 | # This program is distributed in the hope that it will be useful, but |
| 15 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | # General Public License for more details. |
| 18 | # |
| 19 | # You should have received a copy of the GNU General Public License |
| 20 | # along with userv-utils; if not, see http://www.gnu.org/licenses/. |
| 21 | |
| 22 | $minreaddays= 21; |
| 23 | $maxperuser= 250; |
| 24 | |
| 25 | open(CONF,"$ARGV[0]") or die $!; |
| 26 | while(<CONF>) { |
| 27 | next if m/^\#/ || !m/^\S/; |
| 28 | next if m/^(myfqdn|xref|server|server-nosearch|fetch|read|post|permit|believe|extrarc)\s/; |
| 29 | if (m/^minreaddays\s+(\d+)\s+$/) { |
| 30 | $minreaddays= $1; |
| 31 | } elsif (m/^maxperuser\s+(\d+)\s+$/) { |
| 32 | $maxperuser= $1; |
| 33 | } else { |
| 34 | die "$_ ?"; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | $newsrc= ".newsrc"; |
| 39 | exit 0 if -l $newsrc || ! -f _ || -M _ > $minreaddays; |
| 40 | |
| 41 | @g= (); |
| 42 | |
| 43 | open NEWSRC, $newsrc or die $!; |
| 44 | while (<NEWSRC>) { |
| 45 | next unless s/:.*\n$//; |
| 46 | next unless m/^[-a-z0-9+]+\.[-a-z0-9+._]+$/i; |
| 47 | push @g, "$_\n"; |
| 48 | } |
| 49 | close NEWSRC or die $!; |
| 50 | |
| 51 | exit 0 if @g > $maxperuser; |
| 52 | |
| 53 | print sort @g or die $!; |
| 54 | close STDOUT or die $!; |
| 55 | |
| 56 | exit 0; |