Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <bio.h>
4
#include <auth.h>
5
 
6
/*
7
 * called by listen as rexexec rexexec net dir ...
8
 */
9
void
10
main(int argc, char **argv)
11
{
12
	char buf[8192];
13
	int n, nn;
14
	AuthInfo *ai;
15
 
16
	ARGBEGIN{
17
	}ARGEND;
18
 
19
	ai = auth_proxy(0, auth_getkey, "proto=p9any role=server");
20
	if(ai == nil)
21
		sysfatal("auth_proxy: %r");
22
	if(strcmp(ai->cuid, "none") == 0)
23
		sysfatal("rexexec by none disallowed");
24
	if(auth_chuid(ai, nil) < 0)
25
		sysfatal("auth_chuid: %r");
26
 
27
	n = 0;
28
	do {
29
		nn = read(0, buf+n, 1);
30
		if(nn <= 0)
31
			sysfatal("can't read command");
32
		n += nn;
33
		if(n == sizeof buf)
34
			buf[n-1] = '\0';
35
	} while (buf[n-1] != '\0');
36
 
37
	putenv("service", "rx");
38
	execl("/bin/rc", "rc", "-lc", buf, nil);
39
	sysfatal("can't exec rc");
40
}