#!/usr/bin/perl # Disable Password Entries. # Copyright 1998 by Chris Lappe # This program is released under GNU General Public License use Getopt::Long; my $version = 1.03; my %exceptions; my $conffile = './passwd.exceptions'; my $passfile = '/etc/shadow'; my $outfile = '>/home/sysadmin/secure/shadow.mod'; GetOptions("conffile|c=s", "exceptions|e=s", "passfile|p=s", "outfile|o=s", "help|h"); if ($opt_help) { print "usage: pasflip [OPTIONS]\n"; print "Disable password entries except the exceptions specified on the command line or in a conf file.\n"; print "\n"; print "-c, --conffile=FILE Configuration File to read\n"; print "-e, --exceptions=NAME,NAME,.... List of Names to make exceptions for.\n"; print "-p, --passfile=FILE Password File to use.\n"; print "-o, --outfile=FILE File to output to.\n"; print "\n"; print "\n"; print "passdisable $version. Copyright (C) 1998 Chris Lappe\n"; print "This is free software; see the GNU General Public Licence\n"; print "version 2 or later for copying conditions. There is NO warranty.\n"; die "\n"; } if ($opt_conffile) { $conffile = $opt_conffile }; if ($opt_passfile) { $passfile = $opt_passfile }; if ($opt_outfile) {$outfile = $opt_outfile }; if ($opt_exceptions) { foreach (split /,/, $opt_exceptions) { $exceptions{$_} = 1; } } open IN, "$passfile" or die "Couldn't open password file: $!"; open OUT, ">$outfile" or die "Couldn't open output: $!"; open EXCEPTIONS, "$conffile" or die "No exceptions. What are you stupid. This would remove root. :$!"; while () { chomp; $exceptions{$_} = 1; } close EXCEPTIONS; while () { chomp; my ($name,$passwd,$remainder) = split /:/, $_, 3; unless ($exceptions{$name}) { $passwd = '*'; } $_ = join (':', $name,$passwd,$remainder); print OUT "$_\n"; } close IN; close OUT;