summaryrefslogtreecommitdiff
path: root/pinyweb/cgi-bin/newuser.cgi
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@omgwallhack.org>2011-04-24 13:00:05 -0700
committerJoe Rayhawk <jrayhawk@omgwallhack.org>2011-04-24 13:00:05 -0700
commitffab3ec34b9fd949a9877d0a19182b58911424da (patch)
tree102fb78c332d7c43d5c3671e4de59bcba25134ca /pinyweb/cgi-bin/newuser.cgi
parent4ac0fd01b73a0b718db3a756866fee121a1615f1 (diff)
parent2a27be477f89b42abb23793c5118b40120b793aa (diff)
downloadpiny-code-ffab3ec34b9fd949a9877d0a19182b58911424da.tar.gz
piny-code-ffab3ec34b9fd949a9877d0a19182b58911424da.zip
Merge branch 'master' of piny.be:/srv/git/piny-code
Conflicts: libpiny/lib/Piny/Repo.pm
Diffstat (limited to 'pinyweb/cgi-bin/newuser.cgi')
-rwxr-xr-xpinyweb/cgi-bin/newuser.cgi56
1 files changed, 43 insertions, 13 deletions
diff --git a/pinyweb/cgi-bin/newuser.cgi b/pinyweb/cgi-bin/newuser.cgi
index 90c2d59..4f1263b 100755
--- a/pinyweb/cgi-bin/newuser.cgi
+++ b/pinyweb/cgi-bin/newuser.cgi
@@ -9,23 +9,53 @@ use CGI;
use IPC::Open2;
+use Piny::Auth;
+
$q = CGI->new;
print( "Content-type: text/plain\n\n" );
-if( $q->param('n') && $q->param('a') && $q->param('p') ) {
- unless( open2( OUT, IN, '/usr/bin/sudo', '/usr/sbin/newuser', '--batch', $q->param('a'), $q->param('n') ) ) {
- print 'could not execute newrepo';
- die;
- };
- # make things flushier
- select((select(IN), $| = 1)[0]);
- select((select(OUT), $| = 1)[0]);
- print( IN $q->param('p') . "\n" );
- close( IN );
- while( <OUT> ) {
- print;
+if( $q->param("n") && $q->param("a") && $q->param("p") ) {
+
+ my $auth = Piny::Auth->new( );
+
+ my $code = $auth->hash( { "n" => $q->param( "n" ), "a" => $q->param( "a" ), "p" => $q->param( "p" ) } );
+
+ if ( $q->param("h") && $q->param("h") eq $code ) {
+ unless( open2( OUT, IN, "/usr/bin/sudo", "/usr/sbin/newuser", "--batch", $q->param("a"), $q->param("n") ) ) {
+ print "could not execute newrepo";
+ die;
+ };
+ # make things flushier
+ select((select(IN), $| = 1)[0]);
+ select((select(OUT), $| = 1)[0]);
+ print( IN $q->param("p") . "\n" );
+ close( IN );
+ while( <OUT> ) {
+ print;
+ };
+ } else { # No hash, they need one sent to their address
+ print( "Dispatching email to " . $q->param("a") . "...\n" );
+ unless( open( MAIL, "|/usr/lib/sendmail -t" ) ) {
+ print "could not execute sendmail";
+ die;
+ };
+ print( MAIL "To: " . $q->param("a") . "\n" );
+ print( MAIL "Subject: Verifying account " . $q->param("n") . "\n" );
+ print( MAIL "Content-Type: text/plain; charset=us-ascii\n\n" );
+ print( MAIL "http" );
+ if( $ENV{"HTTPS"} eq "on" ) {
+ print( MAIL "s" );
+ };
+ print( MAIL "://" . $ENV{"SERVER_NAME"} . $ENV{"SCRIPT_NAME"} . "?" );
+ print( MAIL "h=" . $code );
+ print( MAIL "&n=" . $q->param("n") );
+ print( MAIL "&a=" . $q->param("a") );
+ print( MAIL "&p=" . $q->param("p") );
+ print( MAIL "\n");
+ close( MAIL );
+ print( "Done!" );
};
} else {
- print 'Missing parameters.';
+ print( "Missing parameters." );
};