Sunil Dhaka rearranged electrons thusly:
> allows access ( mailman login page does exactly this ) There is no interface
> on mailman which allows the user to change the password (even the prfessional
> version). Me thinks that Suresh's script needs to be used appropriately to
> build in this feature. And this should work even for normal users in addition
woops - that script I sent is to _add_ users ... run that yourself ...
for changing password ... again assuming a chrooted pop daemon which looks at
/home/popmail/etc/passwd
<<< changepass.pl attached >>>
you can easily call this from a html interface
--suresh
--
Suresh Ramasubramanian <--> mallet <at> efn <dot> org
EMail Sturmbannfuhrer, Lower Middle Class Unix Sysadmin
#!/usr/bin/perl
use CGI;
print "Content-type: text/html\n\n";
$cgi = new CGI;
unless (defined ($cgi->param('USERNAME')))
{
print "UserName is a MUST!!!";
exit 100;
}
unless (defined ($cgi->param('CURR_PASS')))
{
print "Current Password is a MUST!!!";
exit 101;
}
unless (defined ($cgi->param('NEW_PASS')))
{
print "New Password Cannot be Blank!!!";
exit 102;
}
unless (defined ($cgi->param('DOMAIN')))
{
print "Where do you belong ???";
exit 103;
}
my $DOMAIN = $cgi->param('DOMAIN');
my $username = $cgi->param('USERNAME');
my $currpass = $cgi->param('CURR_PASS');
my $password = $cgi->param('NEW_PASS');
my $tmpfile = "../passtemp/tmp.$$";
$passdir = "/home/popmail/$DOMAIN/etc/passwd";
open(ORGFILE,"$passdir") || die "Cannot Open File $passdir";
$return = flock(ORGFILE, 2);
if ($return != 0)
{
print "Could not Change Password. Please try again after some time\n";
close(ORGFILE);
exit 104;
}
if ( ! -d "../passtemp" )
{
mkdir("../passtemp", "0700");
}
open(TMPFILE,">$tmpfile") || HTMLDie("Error 105: Could not change password.
Contact Administrator.");
$found = 0;
while (<ORGFILE>)
{
$line = $_;
my ($SPLIT_USER, $SPLIT_PASS, $SPLIT_OTHER) = split (/:/,$line, 3);
if($SPLIT_USER eq $username)
{
$enterpass = crypt($currpass, substr($SPLIT_PASS,0,2));
if ($enterpass ne $SPLIT_PASS)
{
HTMLDie("Error 106: Username/Password Error");
}
$newpass = crypt($password, substr($username,0,1) .
substr($username, length($username) - 1,1));
print TMPFILE "$username:$newpass:$SPLIT_OTHER";
$found = 1;
}
else{
print TMPFILE "$line";
}
}
if ($found == 0) {
HTMLDie("Error 107: Sorry, I don't KNOW You.");
}
rename($tmpfile, $passdir);
flock(ORGFILE, 8);
close(ORGFILE);
close(TMPFILE);
#system("/bin/mv $tmpfile $passdir");
print "Your Password has been Changed\n";
exit;
sub HTMLDie()
{
my $message = shift(@_);
print $message;
flock(ORGFILE, 8);
exit 120;
}
----------------------------------------------
The mailing list archives are available at
http://lists.linux-india.org/cgi-bin/wilma/LIH