Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Aug 2001 00:54:27 -0700
From:      "Ted Mittelstaedt" <tedm@toybox.placo.com>
To:        "David Nickel" <dnickel@linuxmail.org>, <freebsd-questions@FreeBSD.ORG>
Subject:   RE: Moving passwds for Sun to FreeBSD
Message-ID:  <000001c1255f$81ee8d60$1401a8c0@tedm.placo.com>
In-Reply-To: <20010814202352.21839.qmail@linuxmail.org>

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

In order to migrate the Solaris password file to the FreeBSD system, the first
step is recombining the two passwd and shadow files.

For starters it's critical that the two Solaris password files, passwd and
shadow, are synchronized.  Solaris password tools do NOT check the password
files consistency!  vipw is the biggest offender, but there's
others.  You can get a Solaris box where the
first 300-500 lines between the regular and the shadow file
are in phase, then there was a missing entry from the shadow
and for a couple hundred more lines they were out of phase,
then there were 2 missing entries from the regular and
they were out of phase the other direction, etc.  Solaris will
never notice and neither will you as long as both files have
the same number of lines.

There's various ways to check this - one way is to sort both the
shadow and passwd files, then select some random line #'s in the
files and make sure they are the same username.  Another way is
to do the merge and then run a comparison of the merged result
against both the shadow and passwd files one after another using
the -a output to join, see the man page.

To crunch the two together you can use the following perl script that
was posted a few years back on Usenet:

#!/usr/bin/perl
open (SHADOW, "/etc/shadow") || die "Can't open /etc/shadow ($!)\n";
while ($line = <SHADOW>)
          {
          ($user, $password, $junk) = split (/:/, $line);
          $password{$user} = $password;
          }
close SHADOW;
open (PASSWD, "/etc/passwd") || die "Can't open /etc/passwd ($!)\n";
while ($line = <PASSWD>)
          {
          ($user, $password, @remainder) = split (/:/, $line);
if ($password eq "x")  {  if ($password{$user})  { $password =
$password{$user}; }  else  { warn "Can't find shadow password for
'$user'!\n"; }  }
          print join (":", $user, $password, @remainder);
          }
close PASSWD;

The next thing needed is to replace all of the commas with colons, and add the
additional colon fields that are present in FreeBSD.  This can be done with
the following command:

awk -F, '{print $1":"$2":"$3":"$4"::0:0:"$5":"$6":"$7}' <passwd.cvs>master

or

awk 'BEGIN {FS=","; OFS=":"} {print $1,$2,$3,$4,"",0,0,$5,$6,$7}'
<passwd.cvs>master

When this is completed open up the master file and verify that it’s lines
looks like the following:

.
.
hmfolk:PcjTEFdWeAxr6:513:60001::0:0:The Realtor:/home/hmfolk:/bin/sh
sjccstw:MCJBR96eZWsHM:519:60001::0:0:SJCC:/home/sjccstw:/bin/sh
.
.

Make sure to go through the entire password file and correct any syntax
errors.

When the password file has been verified to be correct in the editor, run the
vipw command and Read ( with vi, do a :r filename) in the new password file.
Delete any redundant usernames, and write it out and exit vipw.  The FreeBSD
hashed password files will be properly rebuilt.

Also note that by default as passwords are changed they will be changed to DES
ones.  You can stop this by changing a setting in login.conf  (I'll let you
read the man page to find out what that is)


Ted Mittelstaedt                                       tedm@toybox.placo.com
Author of:                           The FreeBSD Corporate Networker's Guide
Book website:                          http://www.freebsd-corp-net-guide.com


>-----Original Message-----
>From: owner-freebsd-questions@FreeBSD.ORG
>[mailto:owner-freebsd-questions@FreeBSD.ORG]On Behalf Of David Nickel
>Sent: Tuesday, August 14, 2001 1:24 PM
>To: freebsd-questions@FreeBSD.ORG
>Subject: Moving passwds for Sun to FreeBSD
>
>
>I am in the process of moving users from a SunOS 5.7 Ultra 1 server
>to a 4.2 FreeBSD server.  There are over a thousand users so I am
>looking for a good way to import the users passwds. I have bin
>looking at rebuilding the passwd database with pwd_mkdb command. But
>there are some differences in the Sun files (passwd and shadow) and
>FreeBSD(passwd and master.passwd). If any body can offer advice it
>would be much appreciated.
>Thanks
>
>--
>
>Get your free email from www.linuxmail.org
>
>
>Powered by Outblaze
>
>To Unsubscribe: send mail to majordomo@FreeBSD.org
>with "unsubscribe freebsd-questions" in the body of the message
>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000001c1255f$81ee8d60$1401a8c0>