File: //proc/self/root/scripts.20110531.215904.25158/realrawchpass
#!/usr/bin/perl
# cpanel4 - scripts Copyright(c) 1997-2002 cPanel, Inc..
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cpanel license. Unauthorized copying is prohibited
BEGIN {
$ENV{'LANG'} = 'C';
unshift @INC, "/scripts";
}
my($user) = $ARGV[0];
my($pass) = $ARGV[1];
if ($ARGV[0] eq "") {
chomp($up = <STDIN>);
@UP = split(/ /, $up);
$user = $UP[0];
$pass = $UP[1];
}
if ($user eq "") { print "user is blank\n"; exit; }
if ($pass eq "") { print "pass is blank\n"; exit; }
if (-e "/etc/master.passwd") {
system("/usr/bin/chpass","-p","$pass","$user");
print "Password for $user has been changed\n";
exit;
}
$cpass = $pass;
$mytime = int(time / (60*60*24));
open(SHADOW,"/etc/shadow");
flock(SHADOW,LOCK_EX);
@SHADOW=<SHADOW>;
flock(SHADOW,LOCK_UN);
close(SHADOW);
open(SHADOW,">/etc/shadow");
flock(SHADOW,LOCK_EX);
foreach $line (@SHADOW) {
if ($line =~ /^$user:/) {
$line =~ s/\n//g;
print "Changing password for $user\n";
#operator:*:10325:-1:-1:-1:-1:-1:-1
(undef,undef,undef,$g1,$g2,$g3,$g4,$g5,$g6) = split(/:/, $line);
$line = join(':',$user,$cpass,$mytime,$g1,$g2,$g3,$g4,$g5,$g6);
$line = $line . "\n";
}
print SHADOW $line;
}
flock(SHADOW,LOCK_UN);
close(SHADOW);
print "Password for $user has been changed\n";