#!/usr/bin/perl

BEGIN { push(@INC,"/usr/local/cpanel"); }
use strict;
use Cpanel::PwCache qw(pwcheckos pwclearcache getpwnam getpwuid);
use Cpanel::CheckPass;
use Cpanel::Form;
pwcheckos();

while(my @PW=getpwent()) {
	if (Cpanel::CheckPass::checkpassword($PW[0],$PW[1])) {
		print "$PW[0] has their password set to their username:\n";
		my $randpass = Cpanel::Form::getranddata(10,0);

		open(CHPASS,"|/scripts/chpass");
		print CHPASS "$PW[0] ${randpass}\n";
		close(CHPASS);
		print "\ttheir new password is: ${randpass}\n";
	}
}
endpwent();
