#!/opt/bin/perl # ########################################################################### # # # Tool for re-generating old passwd file from new passwd file # # # ########################################################################### # # # Version 1.0 - Written 04.05.95 by Steffen Beyer # # # ########################################################################### # # # Copyright (C) 1995 by software design & management GmbH & Co. KG # # # ########################################################################### # # Some important default settings... # $version = 'version 1.0'; # $self = $0; # if ($self =~ m!/([^/]+)$!) { $self = $1; } # $PWD_FILE = '/etc/passwd'; # $pwd_file = $PWD_FILE; # # Get and check command line options: # while (@ARGV) { $_ = shift; if (/^-p$/) { $pwd_file = shift; } elsif (/^-p\S+$/) { $pwd_file = substr($_,$[+2); } elsif (/^-\?$/) { $help = 1; } elsif (/^-h$/) { $help = 1; } else { $error = 1; unless (defined $option) { $option = $_; } } } # # Was help requested? # if ($help) { print <<"@@"; Usage: $self [ ]* where is one of the following: -p specifies the name of the passwd file (default is '$PWD_FILE') -h produces this help screen -? produces this help screen @@ exit; } # # Unknown option encountered? # if ($error) { die "Error: Unknown option '$option' encountered!\n", "Enter '$self -h' for help.\n"; } # # Does the input file exist? # unless (($pwd_file ne "") && (-f $pwd_file)) { die "Error: Can't find file '$pwd_file'!\n"; } # # Prepare output filename: # $out_file = "$pwd_file.$self"; # # Process input file: # open(IN_FILE, "<$pwd_file") || die "Can't open '$pwd_file': $!\n"; open(OUT_FILE, ">$out_file") || die "Can't write '$out_file': $!\n"; # while () { chop; undef @field; @field = split(/:/, $_, 10); $field[$[+2] %= 1000; $field[$[+3] %= 1000; $_ = join(':', @field); print OUT_FILE $_, "\n"; } # close(IN_FILE); close(OUT_FILE); # # Print acknowledgement: # printf("\n'%s' %s\n\n", $self, $version); printf("Input file = '%s'\n", $pwd_file); printf("Output file = '%s'\n\n", $out_file); # # Done. #