[95533] in RedHat Linux List
RE: comparing Two different passwd=?ISO-8859-1?Q?=B4s?=
daemon@ATHENA.MIT.EDU (Charles Galpin)
Mon Oct 19 10:00:58 1998
Date: Mon, 19 Oct 1998 10:06:24 -0400
From: Charles Galpin <cgalpin@lighthouse-software.com>
To: Psychotron <redhat-list@redhat.com>
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com
=3D=3D=3D=3D=3D Original Message from Psychotron <redhat-list@redhat.com> at 10/19/98
7:55 am
>Hello All!!
>
>=09My machine is going down and I need to move the passwd file to another
>server, which has a different passwd. Both of them are huge files. All I
>need is just to find a way to discover wich user names are common to both
>of them, in order for me to change them. But I can=B4t find anyway to do this
>:( Any help will be greatly appreciated!!!
>
Try this. call it comthing like passdiff, and make it executable. invoke
with
./passdiff passfile1 passfile2
It will make a hash of all user passwords in both files, and then using the
fist file as a reference, compare the user's passwords. If the user is not
in the second, or the password is different, you will know.
hth
charles
#!/usr/bin/perl
open( FILE1, $ARGV[0] ) or die $!;
# build hash of users/passwords for first passwd file
while ( <FILE1> )
{
if ( /^(.*?):(.*?):/ )
{
=09$pass1{$1} =3D $2;
}
}
open( FILE2, $ARGV[1] ) or die $!;
# build hash of users/passwords for second passwd file
while ( <FILE2> )
{
if ( /^(.*?):(.*?):/ )
{
=09$pass2{$1} =3D $2;
}
}
# compare second set of user passwords against the first
foreach $key ( keys %pass1 )
{
$password =3D $pass1{$key};
if ( $password ne $pass2{$key} )
{
=09print "passwords for $key are NOT equal\n";
}
else
{
=09print "passwords for $key are equal\n";
}
}
--
PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com http://archive.redhat.com
To unsubscribe: mail redhat-list-request@redhat.com with
"unsubscribe" as the Subject.