From owner-freebsd-isp Mon Apr 15 14:54:43 1996 Return-Path: owner-isp Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id OAA11331 for isp-outgoing; Mon, 15 Apr 1996 14:54:43 -0700 (PDT) Received: from shell.aros.net (shell.aros.net [205.164.111.19]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id OAA11325 for ; Mon, 15 Apr 1996 14:54:38 -0700 (PDT) Received: (from angio@localhost) by shell.aros.net (8.7.5/Unknown) id PAA08093; Mon, 15 Apr 1996 15:53:14 -0600 (MDT) From: Dave Andersen Message-Id: <199604152153.PAA08093@shell.aros.net> Subject: Re: Converting Linux password files to FreeBSD master.passwd To: jvissers@monet.telebyte.nl (Jos Vissers) Date: Mon, 15 Apr 1996 15:53:13 -0600 (MDT) Cc: freebsd-isp@FreeBSD.ORG In-Reply-To: <199604151355.PAA08308@monet.telebyte.nl> from Jos Vissers at "Apr 15, 96 03:55:22 pm" X-Mailer: ELM [version 2.4ME+ PL13 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-isp@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Lo and behold, Jos Vissers once said: > Hello, > > We are converting from Linux to FreeBSD and need to merge the > Linux passwd and shadow files to a bsd master.passwd file. > Does anybody know of an existing script to do this? If you're using the Linux shadow-mk package, it comes with a program called "pwunconv" which will do the trick for you. One caveat: It's a horridly slow program. In fact, it's actually a bit worse than that. It does a "getspwnam()" on every entry in the passwd file, so it's a (number of entries)^2 kind of thing. Attached is a perl program which will do exactly the same thing in about 1/100th of the time, quite literally. Sorry about the huge disclaimer. Dave Andersen -- angio@aros.net Complete virtual hosting and business-oriented system administration Internet services. (WWW, FTP, email) http://www.aros.net/ http://www.aros.net/about/virtual "There are only two industries that refer to thier customers as 'users'." -------- script ---------- #!/usr/bin/perl ## #**************************************************************************** # This script is copyright (C) 1996 by David G. Andersen # All rights reserved. # This information is subject to change without notice and does not # represent a commitment on the part of David G. Andersen # This software is furnished under a license and a nondisclosure agreement. # This software may be used or copied only in accordance with the terms of # this agreement. It is against Federal Law to copy this software on magnetic # tape, disk, or any other medium for any purpose other than the purchaser's # use. David G. Andersen makes no warranty of any kind, expressed or implied, # with regard to these programs or documentation. David G. Andersen # shall not be liable in any event for incidental or consequential # damages in connection with, or arising out of, the furnishing, performance, # or use of these programs. #****************************************************************************/ $shadow = "/etc/shadow"; $passwd = "/etc/passwd"; $output = "bsd-passwd"; umask 077; open(SHADOW, $shadow) || die "Could not open shadow file\n"; while () { ($name, $enc) = split(/:/); $PASS{$name} = $enc; } close(SHADOW); open(PASSWD, $passwd) || die "Could not open passwd file\n"; open(OUT, ">$output") || die "Could not open output file\n"; while () { chop; ($name, $blah, $uid, $gid, $gecos, $homedir, $shell) = split(/:/); printf(OUT "%s:%s:%d:%d:%s:%s:%s\n", $name, $PASS{$name}, $uid, $gid, $gecos, $homedir, $shell); }