From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 14 21:24:08 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BBDB016A41F; Fri, 14 Oct 2005 21:24:08 +0000 (GMT) (envelope-from fullermd@over-yonder.net) Received: from mortis.over-yonder.net (adsl-144-221-64.jan.bellsouth.net [70.144.221.64]) by mx1.FreeBSD.org (Postfix) with ESMTP id F3A2843D5E; Fri, 14 Oct 2005 21:24:07 +0000 (GMT) (envelope-from fullermd@over-yonder.net) Received: by mortis.over-yonder.net (Postfix, from userid 100) id 29E5B2102E; Fri, 14 Oct 2005 16:24:06 -0500 (CDT) Date: Fri, 14 Oct 2005 16:24:05 -0500 From: "Matthew D. Fuller" To: babkin@users.sf.net Message-ID: <20051014212405.GB66908@over-yonder.net> References: <21965586.1129290866618.JavaMail.root@vms071.mailsrvcs.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21965586.1129290866618.JavaMail.root@vms071.mailsrvcs.net> X-Editor: vi X-OS: FreeBSD User-Agent: Mutt/1.5.9i-fullermd.2 Cc: freebsd-hackers@freebsd.org, iwan@staff.usd.ac.id, Robert Watson Subject: Re: Re: system password's file X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2005 21:24:08 -0000 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() { chomp; my ($user,$hash,@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() { 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@over-yonder.net Systems/Network Administrator | http://www.over-yonder.net/~fullermd/ On the Internet, nobody can hear you scream.