summaryrefslogtreecommitdiff
path: root/pinyweb/cgi-bin/newuser.cgi
blob: 90c2d597ea0d6b3c00e3fdd502c294a67fa1d5c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl
$| = 1;

open(STDERR, ">&STDOUT");

use warnings;

use CGI;

use IPC::Open2;

$q = CGI->new;

print( "Content-type: text/plain\n\n" );

if( $q->param('n') && $q->param('a') && $q->param('p') ) {
  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]);
  print( IN $q->param('p') . "\n" );
  close( IN );
  while( <OUT> ) {
    print;
  };
} else {
  print 'Missing parameters.';
};