summaryrefslogtreecommitdiff
path: root/pinyweb/cgi-bin/auth/newpass.cgi
blob: 4f4a636109ec6327d150b6c7b052ebdb618b9144 (plain)
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
#!/usr/bin/perl
$| = 1;

use warnings;

use CGI;

use IPC::Open2;

$q = CGI->new;

print( "Content-type: text/plain\n\n");

open(STDERR, ">&STDOUT");

if( defined( $q->param('p') ) ) {

my @saltchars =
  ( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
  , 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
  , '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
  , '.', '/'
  );

my $salt = "\$6\$";

foreach my $n ( 1 .. 16 ) {
  $salt .= $saltchars[int ( rand ( scalar @saltchars ) )];
};

$salt .= "\$";

my $crypt = crypt( scalar( $q->param('p') ), $salt );

  unless ( system( '/usr/sbin/piny-suid', $ENV{'REMOTE_USER'}, 'newpasshash', $crypt ) == 0 ) {
    die( 'newpass was unsuccessful.' );
  };
  print 'newpass was successful.' ;
} else {
  print 'Missing parameters.';
};