system password's file
Matthew D. Fuller
fullermd at over-yonder.net
Fri Oct 14 14:24:08 PDT 2005
On Fri, Oct 14, 2005 at 06:54:26AM -0500 I heard the voice of
Sergey Babkin, and lo! it spake thus:
>
> I don't know if it's fixed now or not.
I just converted a Mandrake box a month or so ago, which used MD5
hashes. Worked flawlessly.
> Hm, considering the we'd like people to migrate from Linux to
> FreeBSD, having such a conversion script/program (especially if
> someone writes it for their own use anyway) in the base system would
> make a lot of sense.
It's not that hard. Somebody mentioned an awk script. I slapped it
together in perl in about 5 minutes. I'll bet it's in /tmp
somewhere...
#!/usr/bin/perl -w
use strict;
# First, suck in the shadow
my %passes;
open(SHADOW, "shadow") or die "Can't open shadow: $!";
while(<SHADOW>)
{
chomp;
my ($user,$hash, at dummy) = split(/:/);
#print("Adding SHADOW: '$user' -> '$hash'\n");
$passes{$user} = $hash;
}
close(SHADOW);
# Now get the main data from the passwd
my @users;
my %uhash;
open(PASSWD, "passwd") or die "Can't open passwd: $!";
while(<PASSWD>)
{
chomp;
my ($user, $dummy, $uid, $gid, $gecos, $homedir, $shell)
= split(/:/);
my %thisuser;
#print("Adding PASSWD: '$user' ($uid,$gid) -> '$gecos', $shell in $homedir\n");
$uhash{$user}->{user} = $user;
$uhash{$user}->{uid} = $uid;
$uhash{$user}->{gid} = $gid;
$uhash{$user}->{gecos} = $gecos;
$uhash{$user}->{homedir} = $homedir;
$uhash{$user}->{shell} = $shell;
push(@users, $user);
}
close(PASSWD);
# Gen up a BSD master.passwd file
foreach my $user ( @users )
{
printf("%s:%s:%s:%s::0:0:%s:%s:%s\n",
$uhash{$user}->{user},
$passes{$uhash{$user}->{user}},
$uhash{$user}->{uid},
$uhash{$user}->{gid},
$uhash{$user}->{gecos},
$uhash{$user}->{homedir},
$uhash{$user}->{shell});
}
--
Matthew Fuller (MF4839) | fullermd at over-yonder.net
Systems/Network Administrator | http://www.over-yonder.net/~fullermd/
On the Internet, nobody can hear you scream.
More information about the freebsd-hackers
mailing list