#!/usr/bin/perl # # $OpenBSD: openbsd2spf,v 1.1 2003/11/18 19:07:54 sturm Exp $ # # Copyright (c) 2003 Tom Cosgrove # # 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 ( ) { 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") ; } }