xref: /plan9/sys/src/cmd/upas/send/authorize.c (revision 7dd7cddf99dd7472612f1413b4da293630e6b1bc)
1 #include "common.h"
2 #include "send.h"
3 
4 /*
5  *  Run a command to authorize or refuse entry.  Return status 0 means
6  *  authorize, -1 means refuse.
7  */
8 void
authorize(dest * dp)9 authorize(dest *dp)
10 {
11 	process *pp;
12 	String *errstr;
13 
14 	dp->authorized = 1;
15 	pp = proc_start(s_to_c(dp->repl1), (stream *)0, (stream *)0, outstream(), 1, 0);
16 	if (pp == 0){
17 		dp->status = d_noforward;
18 		return;
19 	}
20 	errstr = s_new();
21 	while(s_read_line(pp->std[2]->fp, errstr))
22 		;
23 	if ((dp->pstat = proc_wait(pp)) != 0) {
24 		dp->repl2 = errstr;
25 		dp->status = d_noforward;
26 	} else
27 		s_free(errstr);
28 	proc_free(pp);
29 }
30