From c931a9b75459bd115c76533913cf5654e80f1a94 Mon Sep 17 00:00:00 2001 From: "jrayhawk+piny.be@omgwallhack.org" Date: Thu, 30 Dec 2010 01:11:50 -0800 Subject: Fix up syntax on cgis --- pinyweb/cgi-bin/piny-newuser.cgi | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'pinyweb/cgi-bin/piny-newuser.cgi') diff --git a/pinyweb/cgi-bin/piny-newuser.cgi b/pinyweb/cgi-bin/piny-newuser.cgi index ad46296..002d2be 100644 --- a/pinyweb/cgi-bin/piny-newuser.cgi +++ b/pinyweb/cgi-bin/piny-newuser.cgi @@ -12,20 +12,17 @@ $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, '-' ); + 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]); - 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; + print( IN $q->param('p') . "\n" ); + close( IN ); + while( ) { + print; }; } else { print 'Missing parameters.'; -- cgit v1.2.3