#!/usr/bin/perl
# $Id: redoPasswd,v 1.2 2002/02/11 21:53:44 jeffb Exp $
# Goes back through the cmu.xml and pulls out the encypted passwords
# and adds them to /etc/shadow
# ./redoPasswd /location/of/xml/cmu.xml

use strict;

die "You must run this script as root\n" if ($< != 0);

use lib "/usr/cmu/perl";
use TreeXml;
require RaQUtil;

my $cmuFile = $ARGV[0];
unless(-f $cmuFile) {
	print "Cannot find file $cmuFile\n";
	die "usage:	$0 [FILE]\n";
}

my $tree = TreeXml::readXml($cmuFile, 0); 
if(! defined $tree->{user}) {
	die "No users defined in $cmuFile\n";
} else {
	RaQUtil::setShadowPass($tree->{user});
	chmod 0400, '/etc/shadow';
}

exit 0;
