summaryrefslogtreecommitdiff
path: root/pinyweb/cgi-bin
diff options
context:
space:
mode:
authorjrayhawk+piny.be@omgwallhack.org <jrayhawk@dev.piny.svcs.cs.pdx.edu>2010-12-30 01:11:50 -0800
committerjrayhawk+piny.be@omgwallhack.org <jrayhawk@dev.piny.svcs.cs.pdx.edu>2010-12-30 01:11:50 -0800
commitc931a9b75459bd115c76533913cf5654e80f1a94 (patch)
tree7e2f8e0389f060121c5a2d80d46e90c4e7181b21 /pinyweb/cgi-bin
parent52e32341bcab3ca814086f5c0f80feb25079cfc9 (diff)
downloadpiny-code-c931a9b75459bd115c76533913cf5654e80f1a94.tar.gz
piny-code-c931a9b75459bd115c76533913cf5654e80f1a94.zip
Fix up syntax on cgis
Diffstat (limited to 'pinyweb/cgi-bin')
-rw-r--r--pinyweb/cgi-bin/piny-newuser.cgi19
-rwxr-xr-xpinyweb/cgi-bin/piny/newrepo.cgi29
2 files changed, 37 insertions, 11 deletions
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( <OUT> ) {
- 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( <OUT> ) {
+ print;
};
} else {
print 'Missing parameters.';
diff --git a/pinyweb/cgi-bin/piny/newrepo.cgi b/pinyweb/cgi-bin/piny/newrepo.cgi
new file mode 100755
index 0000000..450fa82
--- /dev/null
+++ b/pinyweb/cgi-bin/piny/newrepo.cgi
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+$| = 1;
+
+use warnings;
+
+use CGI;
+
+use IPC::Open2;
+
+$q = CGI->new;
+
+print( "Content-type: text/plain\n\n");
+
+if( $q->param('n') && $q->param('d') ) {
+ unless( open2( OUT, IN, '/usr/sbin/piny-suid', $ENV{'REMOTE_USER'}, 'newrepo', $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('d') . "\n" );
+ close( IN );
+ while( <OUT> ) {
+ print;
+ };
+} else {
+ print 'Missing parameters.';
+};