[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cobalt-developers] migration utility lose users passwords
- Subject: Re: [cobalt-developers] migration utility lose users passwords
- From: Jeff Bilicki <jeff@xxxxxxxxxxx>
- Date: Thu Oct 12 18:42:48 2000
- List-id: Mailing list for developers on Cobalt Networks products <cobalt-developers.list.cobalt.com>
> Ok, I try to comparing cmu.xml file and the shadow file in the old machine,
> and are identical (match), but after the cmuImport, the password don't
> functioning and the new file /etc/shadow have a different password. I try to
> change it, but without successful. What password is the new password? Why
> happens this things? I don't want to change over 500 users password, because
> this is a big work, and my customer are unhappy if they lose their pwd...
If you still have the cmu.xml file on the system
you can run the following script to re-add all of
the usrPasswd values into /etc/shadow.
Jeff-
#!/usr/bin/perl -I/usr/lib/cmu
# $Id: redoPasswd,v 1.1.2.1 2000/10/13 01:12:03 jeffb Exp $
# Written by: Jeff Bilicki
# Goes back through cmu.xml and pulls out the passwords
# and adds them to /etc/shadow
# ./redoPasswd /location/of/xml/cmu.xml
die "You must run this script as root\n" if ($< != 0);
use CMU::Migrate;
my $cmuFile = $ARGV[0];
unless(-f $cmuFile) {
print "Cannot find file $cmuFile\n";
die "usage: $0 [FILE]\n";
}
my $mobj = CMU::Migrate->new();
$mobj->imptState($cmuFile);
for my $site ( @{ $mobj->{children} }) {
next unless($site->{type} eq "vsite");
warn "Processing site ", $site->{name}, "\n";
for my $child ( @{ $site->{children} }) {
next unless($child->{type} eq "user");
setpwent;
next unless((getpwnam($child->{name}))[0]);
warn "Processing user", $child->{name},
" with password ", $child->{usrPasswd}, "\n";
my $ret = addPasswd($child->{name},$child->{usrPasswd});
unless($ret) {
warn "Error processing user ", $child->{name}, "\n";
}
}
}
exit;
sub addPasswd
{
my $userName = shift || return 0;
my $passwd = shift || return 0;
require FileHandle;
my $Ptmp = "/etc/locks/ptmp";
my $pwFile = "/etc/shadow";
my $fhShadow = new FileHandle("< $pwFile");
die "$0: Open failed: $pwFile: $!\n" if (!defined($fhShadow));
my $fhPtmp = new FileHandle("> $Ptmp");
die "$0: Open failed: $Ptmp: $!\n" if (!defined($fhPtmp));
while (my $line = <$fhShadow>) {
if ($line =~ /^$userName:\S+/ ) {
my $end = "11198:0:99999:7:::\n";
print $fhPtmp $userName.":".$passwd.":".$end;
} else {
print $fhPtmp $line;
}
}
$fhPtmp->close();
$fhShadow->close();
my $ret = rename($Ptmp, $pwFile);
return $ret;
}