File: auth-pop.pl

package info (click to toggle)
websieve 0.62-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 276 kB
  • ctags: 92
  • sloc: perl: 3,532; makefile: 53
file content (76 lines) | stat: -rw-r--r-- 1,668 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/perl
#
# auth-pop.pl: Password changing with the Qualcomm poppassd server
# ftp.qualcomm.com:/quest/unix/servers/password
# contributed BY Gary Mills
# History:
# 4 Jun 01 Created
# 5 Jun 01 Fixed a response handling bug
 
use IO::Socket::INET;

$useauth=1;

sub auth_disconnect {
    return 0;
}

sub auth_getuserserver {
       return '';
}


sub auth_changepass {
	
#  Lets Check the Password

    my $pass1 = param("pass1");
    my $pass2 = param("pass2");
    if (!$pass1 && !$pass2) {return;}
    if ($pass1 eq "" || $pass2 eq "") {return;}

    if ($pass1 ne $pass2) {
	print "<b>Error:</b> Passwords Did Not Match...Not Changed...\n",p;
	exit;
    }
    else {
	my $sock = IO::Socket::INET->new(
					 Proto    => "tcp",
					 PeerAddr => "localhost",
					 PeerPort => "poppassd(106)",
					 );
	unless ($sock) {
	    print "\n",p,"Error: Unable to connect to poppassd\n",p;
	    exit;
	}
	my $resp = <$sock>;
	if (substr($resp, 0, 12)  eq "200 poppassd") {
	    print $sock "user $uid\r\n";
	    $resp = <$sock>;
	    if (substr ($resp, 0, 3) eq "200") {
		print $sock "pass $pass\r\n";
		$resp = <$sock>;
		if (substr ($resp, 0, 3) eq "200") {
		    print $sock "newpass $pass1\r\n";
		    $resp = <$sock>;
		    if (substr ($resp, 0, 3) eq "200") {
			$resp = '999';
		    }
		}
	    }
	}

    }
    $resp="000 unexpected EOF" unless $resp;
    unless ($resp eq '999') {
        print "\n",p,"Error from poppassd: $resp\n",p;
	exit;
    }
	  
#  Success!
    print "<b>Password Modified...</b>\n";
    print "<b>Warning:</b> You must login with your new password by clicking <a href=" . $program_url . "?op=logout>HERE</a>\n",p;
    exit;

}
1;