From 8a4e3cedb5ec2975228faad597909037d3225950 Mon Sep 17 00:00:00 2001 From: Joe Rayhawk Date: Fri, 27 Jan 2012 18:11:52 -0800 Subject: Initial shot at web-friendly (sadly PAM unfriendly...) password modification. --- pinyweb/cgi-bin/auth/newpass.cgi | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 pinyweb/cgi-bin/auth/newpass.cgi (limited to 'pinyweb/cgi-bin') diff --git a/pinyweb/cgi-bin/auth/newpass.cgi b/pinyweb/cgi-bin/auth/newpass.cgi new file mode 100755 index 0000000..1031820 --- /dev/null +++ b/pinyweb/cgi-bin/auth/newpass.cgi @@ -0,0 +1,41 @@ +#!/usr/bin/perl +$| = 1; + +open(STDERR, ">&STDOUT"); + +use warnings; + +use CGI; + +use IPC::Open2; + +$q = CGI->new; + +print( "Content-type: text/plain\n\n"); + +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( $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.'; +}; -- cgit v1.2.3