summaryrefslogtreecommitdiff
path: root/pinyweb
diff options
context:
space:
mode:
authorJulian Blake Kongslie <jblake@omgwallhack.org>2010-12-27 14:09:02 -0800
committerJulian Blake Kongslie <jblake@omgwallhack.org>2010-12-27 14:09:02 -0800
commitef695be134b8046c8b05cfe6c47f8856b7108c77 (patch)
tree6ba59f558d11f3bcfb8b82da104abae149ee9200 /pinyweb
parentfadbff800f910475df98af9aac683935ea7175e8 (diff)
parent3e9915449ee56f3b3c8106cb8b36ceb117d2d242 (diff)
downloadpiny-code-ef695be134b8046c8b05cfe6c47f8856b7108c77.tar.gz
piny-code-ef695be134b8046c8b05cfe6c47f8856b7108c77.zip
Merge branch 'master' of ssh://piny/srv/git/piny-code
Diffstat (limited to 'pinyweb')
-rw-r--r--pinyweb/cgi-bin/piny-newuser.cgi27
1 files changed, 25 insertions, 2 deletions
diff --git a/pinyweb/cgi-bin/piny-newuser.cgi b/pinyweb/cgi-bin/piny-newuser.cgi
index d10c6ba..ad46296 100644
--- a/pinyweb/cgi-bin/piny-newuser.cgi
+++ b/pinyweb/cgi-bin/piny-newuser.cgi
@@ -1,9 +1,32 @@
#!/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\n\n" );
+
+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.';
+};