openbsd-ports/security/crack/files/openbsd2spf
sturm 4760a9e63c cleanup and functional improvements mainly from
Tom Cosgrove <tom dot cosgrove at arches-consulting dot com>

bump PKGNAME
2003-11-18 19:07:53 +00:00

69 lines
1.7 KiB
Perl

#!/usr/bin/perl
#
# $OpenBSD: openbsd2spf,v 1.1 2003/11/18 19:07:54 sturm Exp $
#
# Copyright (c) 2003 Tom Cosgrove <tom.cosgrove@arches-consulting.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
use strict ;
for my $file (@ARGV)
{
if ( open(PASSWD, "<$file") )
{
while ( <PASSWD> )
{
chomp ;
my @f = split(/:/) ;
if ( scalar(@f) != 10 )
{
print "E:0:bad format: $file: $_\n" ;
}
else
{
if ( ($f[0] =~ /^\+/) && ($f[1] eq "") )
{
print "E:0:ignoring passwordless NIS entry: $_\n" ;
next ;
}
if ( ($f[1] =~ /^\*/) ||
($f[1] =~ /[\-\ ]/) )
{
print "E:0:ignoring locked entry: $f[0]\n" ;
next ;
}
if ( ($f[1] eq "x") ||
($f[1] =~ /^\[\#\!\]/) )
{
print "E:0:ignoring shadowed entry: $f[0]\n" ;
next ;
}
}
print join(":", "D", @f[1, 1, 0, 7], $file, @f[9, 0, 7]), "\n" ;
}
close(PASSWD) ;
}
else
{
warn("$0: $file: no such file\n") ;
}
}