Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!dispatch.news.demon.net!demon!rill.news.pipex.net!pipex!uunet!in3.uu.net!207.67.253.7!atmnet.net!news.lightside.com!dcs74.dcs-chico.com!user
From: fred@lightside.net (Fred Condo)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Copying user accounts from BSDI to FreeBSD
Date: Fri, 21 Feb 1997 11:20:38 -0800
Organization: Lightside, Inc. - Internet Access
Message-ID: <fred-2102971120380001@dcs74.dcs-chico.com>
References: <330d301f.28086296@news.sanasys.com>
NNTP-Posting-Host: dcs74.dcs-chico.com
Mime-Version: 1.0
Content-Type: text/plain;charset=US-ASCII
Content-Transfer-Encoding: 7bit
x-no-archive: yes
Lines: 73
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:35911
In article <330d301f.28086296@news.sanasys.com>, nschuler@sanasys.com wrote:
>We are currently using BSDI 2.0 on our servers with kerberos security
>and wish to copy the user accounts to a new FreeBSD server. First of
>all, is this possible? Second, how? I will tar out to tape and
>restore to the FreeBSD server for the user files, but have no idea on
>the kerberos database. Any help is appreciated.
>
>
>Nathan Schuler, Systems Administrator
>nschuler@sanasys.com
>support@sanasys.com
I used the following script to transfer accounts from A/UX to FreeBSD.
You will have to make some changes to deal with at least two issues:
1. You're not converting from A/UX
2. This script was made for moving POP-only accounts, and you are
moving login accounts.
I hope it helps.
#!/usr/bin/perl
# A/UX format:
# name:encrypto:1376:2315:name name name,,,:/splunge:/usr/local/bin/dont
# FreeBSD format:
# name:encrypto:1001:999::0:0:System Maintenance:/nonexistent:/usr/local/bin/dont
%LOCK = ('SH',1,'EX',2, 'NB',4,'UN',8);
USER: while (<>) { # input should be A/UX formatted passwd file (remove system accounts)
($username, $encryptedPassword, $uid, $gid, $gecos, $dir, $shell) = split(':');
if (&UserExists($username)) {
warn "$0: user $username already exists.\n";
next USER;
}
($realname) = $gecos =~ /^([^,]*)/;
$uid = &NextUID();
$result = system qq+/usr/bin/chpass -a "$username:$encryptedPassword:$uid:999::0:0:$gecos:/nonexistent:/usr/local/bin/dont"+;
die "$0: chpass failed for $username ($result)\n" if $result;
chop($date = `date`);
print "$date: added new user $username ($realname, UID: $uid)\n";
open(LOG, ">>/root/newuser.log") || die "$0: cannot append to newuser log\n";
flock(LOG, $LOCK{'EX'});
seek(LOG, 0, 2);
print LOG "$date: added new user $username ($realname, UID: $uid)\n";
}
sub UserExists {
local($name,$passwd,$uid,$gid, $quota,$comment,$gcos,$dir,$shell);
while (($name,$passwd,$uid,$gid, $quota,$comment,$gcos,$dir,$shell) = getpwent()) {
return 1 if $name eq $username;
}
endpwent();
0;
}
sub NextUID {
local($name,$passwd,$uid,$gid, $quota,$comment,$gcos,$dir,$shell);
$uidMax = 50000;
$i = 0;
while (($name,$passwd,$uid,$gid, $quota,$comment,$gcos,$dir,$shell) = getpwent()) {
$uid[$i++] = $uid;
}
endpwent();
@uid = sort {$b <=> $a} @uid;
for ($i = 0; $uid[$i] > $uidMax; $i++) {}
$uid[$i] + 1;
}
--
http://www.lightside.net/~fred/ + net access + http://www.lightside.net/
"Attempts to control the use of encryption technology are wrong in
principle, unworkable in practice, and damaging to the long term economic
value of the information networks." - UK Labour Party