From 340b56a463797d6a2acb597de210d6c82fac8c08 Mon Sep 17 00:00:00 2001 From: "jrayhawk+piny.be@omgwallhack.org" Date: Mon, 27 Dec 2010 04:56:11 -0800 Subject: Add a tentative newuser cgi. --- pinyweb/cgi-bin/piny-newuser.cgi | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'pinyweb') 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( ) { + 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.'; +}; -- cgit v1.2.3 From 3e9915449ee56f3b3c8106cb8b36ceb117d2d242 Mon Sep 17 00:00:00 2001 From: "jrayhawk+piny.be@omgwallhack.org" Date: Mon, 27 Dec 2010 05:00:47 -0800 Subject: Cleaning up syntax in piny-newuser.cgi --- pinyweb/cgi-bin/piny-newuser.cgi | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'pinyweb') diff --git a/pinyweb/cgi-bin/piny-newuser.cgi b/pinyweb/cgi-bin/piny-newuser.cgi index 64b6b0a..ad46296 100644 --- a/pinyweb/cgi-bin/piny-newuser.cgi +++ b/pinyweb/cgi-bin/piny-newuser.cgi @@ -9,9 +9,7 @@ use IPC::Open2; $q = CGI->new; -print( "Content-type: text/plain - -" +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 -- cgit v1.2.3