diff options
author | jrayhawk+piny.be@omgwallhack.org <jrayhawk@dev.piny.svcs.cs.pdx.edu> | 2010-12-27 04:56:11 -0800 |
---|---|---|
committer | jrayhawk+piny.be@omgwallhack.org <jrayhawk@dev.piny.svcs.cs.pdx.edu> | 2010-12-27 04:56:11 -0800 |
commit | 340b56a463797d6a2acb597de210d6c82fac8c08 (patch) | |
tree | 95685815d01bc9fea60f8f3463bdbfb65eddf3c0 /pinyweb | |
parent | db75ce911c66b38a70b16f50feeb5a3304e53343 (diff) | |
download | piny-code-340b56a463797d6a2acb597de210d6c82fac8c08.tar.gz piny-code-340b56a463797d6a2acb597de210d6c82fac8c08.zip |
Add a tentative newuser cgi.
Diffstat (limited to 'pinyweb')
-rw-r--r-- | pinyweb/cgi-bin/piny-newuser.cgi | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/pinyweb/cgi-bin/piny-newuser.cgi b/pinyweb/cgi-bin/piny-newuser.cgi index d10c6ba..64b6b0a 100644 --- a/pinyweb/cgi-bin/piny-newuser.cgi +++ b/pinyweb/cgi-bin/piny-newuser.cgi @@ -1,9 +1,34 @@ #!/usr/bin/perl +$| = 1; use warnings; use CGI; -print 'Content-type: text/plain +use IPC::Open2; -hello' +$q = CGI->new; + +print( "Content-type: text/plain + +" + +if( $q->param('n') && $q->param('a') && $q->param('p') ) { + # 03:57:44 omg/jrayhawk: system() lets me specify arguments as an array, and open() lets me work with stdout, but i would like something that does both + # 03:59:50 omg/jrayhawk: hahaha they recommend i open(, '-|') and then exec() in the child + # 03:59:55 omg/jrayhawk: fuck you, perl + $pid = open2( OUT, IN, '-' ); + # make things flushier + select((select(IN), $| = 1)[0]); + select((select(OUT), $| = 1)[0]); + if( $pid ) { + print( IN $q->param('p') . "\n" ); + while( <OUT> ) { + print; + }; + } else { + exec( '/usr/bin/sudo', '/usr/sbin/newuser', '--batch', $q->param('a'), $q->param('n') ) || print 'could not execute newuser' && die; + }; +} else { + print 'Missing parameters.'; +}; |