Update pam.d files with FISMA complia...

Update pam.d files with FISMA compliant options

 
#!/usr/bin/perl
my $outpdir = '/etc/pam.d';
my $inpdir = '/etc/pam.d';
opendir(my $pamd, $inpdir);
my @pamddir = readdir($pamd);
closedir($pamd);
foreach my $file (@pamddir) {
        my $fileabs = "$inpdir/$file";
        if (-r $fileabs && ! -d $fileabs) {
                print "Processing $file:\n";
                open(PAMFILE, $fileabs) or die "Failed to open $fileabs: $!";
                my @pfLines = <PAMFILE>;
                close PAMFILE;
                open(DESTFILE, ">$outpdir/$file") or die "Could not write $outpdir/$file: $!";
                foreach my $line (@pfLines) {
                        chomp $line;
                        if ($line =~ /pam_rhosts_auth\.so/) { print DESTFILE "#$line\n"; }
                        else { print DESTFILE "$line\n"; }
                }
                close DESTFILE;
        }
}

No comments: