I am mostly guessing on this but it looks like this
pulls the user name and uid from the passwd file and
the encrypted password from the shadow file and runs
adduser to put them into the linux versions of passwd
and shadow?
I am not the best perl programmer in the world (far from)
and I am not sure how you are getting the encrypted password
working here. I am guessing it is in the push and system
calls but not sure how that works.
Thanks for the script though. I will definatly put it to
test and very possibly use.
Bill Warner
> There's a mistake in that script (I missed a curly bracket in the system()
> call). This is the fixed version:
>
> #!/usr/bin/perl
> use strict;
>
> my $passwd = "/tmp/passwd";
> my $shadow = "/tmp/shadow";
> my $start_uid = 200;
>
> open(PASSWD, $passwd) || die "Can't open $passwd: $!";
> open(SHADOW, $shadow) || die "Can't open $shadow: $!";
>
> my @users;
> PASSWD: while(<PASSWD>) {
> my @passwd = split(/:/, $_);
> my $user = $passwd[0];
> my $uid = $passwd[2];
> while (<SHADOW>) {
> my @shadow = split(/:/, $_);
> if ($shadow[0] eq $user) {
> my $crypt = $shadow[1];
> push(@users, { user => $user, uid=>$uid, crypt=>$crypt});
> next PASSWD;
> }
> }
> }
>
> foreach my $user (@users) {
> if ($user->{uid} >= $start_uid) {
> print "useradd $user->{user} -p $user->{crypt}\n";
> system("useradd $user->{user} -p $user->{crypt}");
> }
> }
>
> ----- Original Message -----
> From: "Mike Cantrell" <mikec@autodispatch.com>
> To: <plug-discuss@lists.PLUG.phoenix.az.us>
> Sent: Thursday, August 10, 2000 11:15 AM
> Subject: Re: passwd files (solved sort of)
>
>
> > Hmmm.. I wonder if there are any security implications in doing so. SCO's
> > shadow file is highly specialized for it's OS not to mention the special
> > accounts each system has. While it might allow them to log in, etc.., it
> > might end up giving you a headache in the long run.
> >
> > I'd restore the original files, copy the shadow and passwd files to /tmp
> on
> > the linux box and run this script (I'm bored... very bored). You'll want
> to
> > make sure the start_uid variable is what you want. Most SCO system's
> regular
> > users start at 200 but you'll probably want to double check.
> >
> > (depending on where your perl is installed, you may need to change the 1st
> > line to point to the location of your perl executable)
> >
> > #!/usr/bin/perl
> > use strict;
> >
> > my $passwd = "/tmp/passwd";
> > my $shadow = "/tmp/shadow";
> > my $start_uid = 200;
> >
> > open(PASSWD, $passwd) || die "Can't open $passwd: $!";
> > open(SHADOW, $shadow) || die "Can't open $shadow: $!";
> >
> > my @users;
> > PASSWD: while(<PASSWD>) {
> > my @passwd = split(/:/, $_);
> > my $user = $passwd[0];
> > my $uid = $passwd[2];
> > while (<SHADOW>) {
> > my @shadow = split(/:/, $_);
> > if ($shadow[0] eq $user) {
> > my $crypt = $shadow[1];
> > push(@users, { user => $user, uid=>$uid, crypt=>$crypt});
> > next PASSWD;
> > }
> > }
> > }
> >
> > foreach my $user (@users) {
> > if ($user->{uid} >= $start_uid) {
> > print "useradd $user->{user} -p $user->{crypt}\n";
> > system("useradd $user->{user} -p $user->{crypt");
> > }
> > }
> >
> >
> >
> > }----- Original Message -----
> > From: "Bill Warner" <wwarner@direct-alliance.com>
> > To: <plug-discuss@lists.PLUG.phoenix.az.us>
> > Sent: Thursday, August 10, 2000 9:36 AM
> > Subject: Re: passwd files (solved sort of)
> >
> >
> > > unfortantly this wont keep the passwords
> > >
> > > but it does seem to work by copying the passwd and shadow
> > > files over from sco to linux. i tried copying individual
> > > lines at first and it didn't work. Once i decided to try
> > > copying the entire thing it seems to work. Strange, ohh
> > > well. problem solved
> > >
> > > Bill Warner
> > >
> > > > Copy the /etc/passwd from the SCO box over to the Linux box in /tmp
> and
> > do
> > > > something like this:
> > > >
> > > >
> > > > for i in `cat /tmp/passwd|cut -d":" -f1`;do useradd $i;done
> > > >
> > > >
> > > > man useradd for more options (such as home dir's, etc)..
> > > >
> > > >
> > > > Regards,
> > > > Mike Cantrell
> > > >
> > > > ----- Original Message -----
> > > > From: "Bill Warner" <wwarner@direct-alliance.com>
> > > > To: <plug-discuss@lists.PLUG.phoenix.az.us>
> > > > Sent: Wednesday, August 09, 2000 2:49 PM
> > > > Subject: Re: passwd files
> > > >
> > > >
> > > > > I have tried this but it doesnt seem to work. I can't
> > > > > really even find any good docs on this I have skimmed through
> > > > > several howtos that I thought might give a clue. I am still
> > > > > doing some testing and rtfming I just really dont want to have
> > > > > to change passwords for over 300 users by hand.
> > > > >
> > > > > Bill Warner
> > > > >
> > > > > > I'm gonna say just copy the files :-) we've taken entrioes from
> > linux to
> > > > > > solaris to BSD to....and have had no issues, so I'd imagine you
> > wouldn't
> > > > > > :-)
> > > > > >
> > > > > >
> > > > > > _______________
> > > > > > Jonathan Furrer
> > > > > > jonny@jofu.com
> > > > > > http://www.jofu.com/
> > > > > >
> > > > > > On 10 Aug 2000, Bill Warner wrote:
> > > > > >
> > > > > > > I am currently converting a SCO system over to Linux and
> > > > > > > am wondering if there is a way to keep the password and
> > > > > > > shadow files without having to recreate over 300 users.
> > > > > > >
> > > > > > > Does anyone know of the least painfull way of doing this?
> > > > > > >
> > > > > > > Bill Warner
> > > > > > >
> > > > > > >
> > > > > > > ________________________________________________
> > > > > > > See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail
> > > > doesn't post to the list quickly and you use Netscape to write mail.
> > > > > > >
> > > > > > > Plug-discuss mailing list -
> > Plug-discuss@lists.PLUG.phoenix.az.us
> > > > > > > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> > > > > > >
> > > > > >
> > > > > >
> > > > > > ________________________________________________
> > > > > > See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail
> > doesn't
> > > > post to the list quickly and you use Netscape to write mail.
> > > > > >
> > > > > > Plug-discuss mailing list -
> Plug-discuss@lists.PLUG.phoenix.az.us
> > > > > > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> > > > > >
> > > > >
> > > > >
> > > > > ________________________________________________
> > > > > See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail
> > doesn't
> > > > post to the list quickly and you use Netscape to write mail.
> > > > >
> > > > > Plug-discuss mailing list - Plug-discuss@lists.PLUG.phoenix.az.us
> > > > > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> > > >
> > > >
> > > > ________________________________________________
> > > > See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail
> doesn't
> > post to the list quickly and you use Netscape to write mail.
> > > >
> > > > Plug-discuss mailing list - Plug-discuss@lists.PLUG.phoenix.az.us
> > > > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> > > >
> > >
> > >
> > > ________________________________________________
> > > See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't
> > post to the list quickly and you use Netscape to write mail.
> > >
> > > Plug-discuss mailing list - Plug-discuss@lists.PLUG.phoenix.az.us
> > > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> >
>
>
> ________________________________________________
> See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't post to the list quickly and you use Netscape to write mail.
>
> Plug-discuss mailing list - Plug-discuss@lists.PLUG.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>