Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Feb 2004 00:30:11 +1000
From:      Mark Sergeant <msergeant@snsonline.net>
To:        "Eric L. Howard" <elh@outreachnetworks.com>
Cc:        freebsd-isp@freebsd.org
Subject:   Re: Conversion to FreeBSD from Linux
Message-ID:  <1077719411.1351.6.camel@localhost>
In-Reply-To: <20040225141355.GA1519@outreachnetworks.com>
References:  <200402251339.i1PDdc2B011071@cah.talon.net> <20040225141355.GA1519@outreachnetworks.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
-- Begin perl script --


#!/usr/bin/perl -w

use AcctInfo;

my $acct = new AcctInfo;

my @realusers = $acct->GetNonSystemUsers;

umask(066);
$pwfile = "/tmp/temppasswd";
open(PWFILE, ">$pwfile") || die "Unable to open $pwfile";

foreach $user (@realusers) {
    $acct->SetUser($user);
    $acct->cache;
    $passwd = $acct->GetPassword;
    $uid = $acct->GetUid;
    $gid = $acct->GetGid;
    $realname = $acct->GetRealName;
    $homedir = $acct->GetHomeDir;
    $shell = $acct->GetShell;
    # Get rid of extraneous , used in Solaris gcos field.
    ($realname,$junk) = split(/,/, $realname);

    # Output data in bsd password format.
    print PWFILE $user . ":" . $passwd . ":" . $uid . ":" . $gid .
"::0:0:" . $realname . ":" . $homedir . ":" . $shell . "\n";

}

close(PWFILE);

exit;

-- End perl script

Should work well enough on linux as well. ohh and of course if you
intend to use it more than once drop in some error checking / catching,
something to remove the system accounts and of course "use strict"

Cheers,

Mark



On Thu, 2004-02-26 at 00:13, Eric L. Howard wrote:
> At a certain time, now past [Feb.25.2004-08:43:20AM -0500], ssj@scottah.com spake thusly:
> > I have been searching the net for a simple answer and I will continue to
> > look, but if anyone has a link, please pass it along.
> > 
> > Two years ago I converted my BSDi password file to Linux with a simple
> > script to replace fields.  For obvious reasons I want to move back to
> > FreeBSD, but of course I need to convert the Linux passwd file of 2,000+
> > users to FreeBSD.
> > 
> > Any links will be appreciated!
> 
> man pwconv on Linux and Google/BSD[0] for linux password.
> 
>        ~elh
> 
> 0. http://www.google.com/bsd
-- 
Mark Sergeant <msergeant@snsonline.net>
SNSOnline Technical Services

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQBAPLFybS4ZEpHb8t0RAoiEAJwO83DUt1ippN9c8rzEWgPV+xqjhgCfagtv
PhULxc7+Q5+D73Npv/gdIAE=
=HPMp
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1077719411.1351.6.camel>