Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Aug 2000 18:59:32 -0400
From:      "Eric W. Bates" <ericx@vineyard.net>
To:        <kwoody@citytel.net>, <freebsd-isp@FreeBSD.ORG>
Subject:   Re: BSDI -> Freebsd
Message-ID:  <021101c00967$f995cf00$68c311cc@vineyard.net>
References:  <Pine.BSI.3.95.1000816154318.26745B-100000@rosencrantz.citytel.net>

next in thread | previous in thread | raw e-mail | index | archive | help
We are still in transition from BSDI to freebsd.  For a number of reasons,
we routinely propagate the authentications from BSDI to freebsd.  The
following code is from our general "copy from the old box to the new box"
program.  k1 is the new machine.  apache is the old one.  It is a pretty
straight forward process of rewriting the group, passwd, and master.passwd
files and running pwd_mkdb.  Some care is taken to filter out "system" uids.

Hope the snippet helps.

sub do_accounts {
    #
    # Update the /etc/passwd, /etc/master.passwd files on k1
    #

    # First grab the entries for UIDs less than 100

    # get k1's password file
    &get_passwd(\@passwd,"$ssh k1 cat /etc/passwd|",sub {$_[2] < 100} );
    &get_passwd(\@master,"$ssh k1 cat /etc/master.passwd|",sub {$_[2] <
100});

    # Now append the UID entries from apache

    &get_passwd(\@passwd,"/etc/passwd",       sub {$_[2] >= 100 });
    &get_passwd(\@master,"/etc/master.passwd",sub {$_[2] >= 100 });

    # Get the group file from local machine
    &get_passwd(\@group,"/etc/group",sub {1});

    # permute the group file as necessary
    foreach $_ (@groups_remove){
        &passwd_remove(\@group,$_);
    }

    # Add the groups from the remote machine that we don't have
    &get_passwd(\@group,"$ssh k1 cat /etc/group|",
               sub { !has_entry(\@group,$_[0])});


    # Now send the files to the remote machine with the new names
    my $np = "/etc/passwd.new.$$";
    my $nm = "/etc/master.passwd.new.$$";
    my $ng = "/etc/group.new.$$";

    &send_passwd(\@passwd,"|$ssh k1 'cat > $np'");
    &send_passwd(\@master,"|$ssh k1 'cat > $nm'");
    &send_passwd(\@group, "|$ssh k1 'cat > $ng'");

    # Now move the files into place and run the program
    my $cmd =("mv $np /etc/passwd;mv $nm /etc/master.passwd;" .
              "mv $ng /etc/group;pwd_mkdb /etc/master.passwd");
    system("$ssh k1 '$cmd'");
}

# get_passwd(\@array,$file,$function) - get all passwd entries from file
where t
he UID is approved by function
#
sub get_passwd {
    my($array,$file,$fun) = @_;
    open(PASS,$file) || die "Cannot get $file, $!, ";
    while(<PASS>){
        if(&$fun(split(/:/,$_))){
            push(@$array,$_);
        }
    }
    close(PASS);
    return;
}

# send_passwd(\@array,$file)
#
sub send_passwd {
    my($array,$file) = @_;
    open(PASS,$file) || die "Cannot open $file, $!, ";
    foreach $_ (@$array){
        print PASS $_;
    }
    close(PASS);
}



----- Original Message -----
From: Keith Woodworth <kwoody@citytel.net>
To: <freebsd-isp@FreeBSD.ORG>
Sent: Wednesday, August 16, 2000 7:08 PM
Subject: BSDI -> Freebsd


>
> We will be moving part of our ISP services to some rackmount 1u's that
> have been ordered from BSDI. They will have FreeBSD installed on them of
> course.
>
> The services we will be moving are web, mail and radius authentication. As
> we have everything on BSD/OS right now my main concern is moving the user
> passwd files over.
>
> How interchangeable are the passwd files between FBSD and BSD/OS? Ideally
> it would be nice to be able to copy the /etc/shells and /etc/groups files
> and have them the same as the BSD/OS machine then if possible copy over
> the master.passwd file from the BSD/OS box to the FreeBSD box then run
> pwd_mkdb(8) on the FreeBSD machine.
>
> That just sounds too simple though. Are they similiar enough to acutally
> do that?
>
> Thanks for any info.
> Keith
>
>
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-isp" in the body of the message
>



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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?021101c00967$f995cf00$68c311cc>