CoCalc Public Fileswww / cgi-bin / openwebmail / misc / test / authtest.plOpen with one click!
Author: William A. Stein
1
#!/usr/bin/perl
2
#
3
# this is used for debuging aut_*pl modules under auth/
4
# change the module name to the one you want to test
5
#
6
7
# add the path of your openwebmail cgi-bin here if it is not listed
8
push (@INC,
9
'/usr/local/www/cgi-bin/openwebmail',
10
'/var/www/cgi-bin/openwebmail'
11
);
12
13
use strict; no strict 'vars';
14
use vars qw (%config);
15
%config=( passwd_minlen => 1 );
16
17
my ($authfile, $user, $passwd, $newpasswd)=@ARGV;
18
if ($user eq "") {
19
print "authtest.pl [authfile] [username] [oldpassword] [newpassword]\n".
20
"eg1: authtest auth_unix.pl username pwd\n".
21
"eg2: authtest auth_unix.pl username pwd1 pwd2\n";
22
exit 1;
23
}
24
25
require "auth/auth.pl";
26
ow::auth::load($authfile);
27
28
my ($ret, $errmsg)=ow::auth::check_userpassword(\%config, $user, $passwd);
29
print "user=$user, pwd=$passwd, check pwd ret=$ret, err=$errmsg\n";
30
31
if ($newpasswd ne '') {
32
($ret, $errmsg)=ow::auth::change_userpassword(\%config, $user, $passwd, $newpasswd);
33
print "user=$user, pwd=$passwd, newpwd=$newpasswd, change pwd ret=$ret, err=$errmsg\n";
34
}
35