Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_tlsv12/sys/src/cmd/auth/newns.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <auth.h>
4
 
5
void
6
usage(void)
7
{
8
	fprint(2, "usage: newns [-ad] [-n namespace] [cmd [args...]]\n");
9
	exits("usage");
10
}
11
 
12
static int
13
rooted(char *s)
14
{
15
	if(s[0] == '/')
16
		return 1;
17
	if(s[0] == '.' && s[1] == '/')
18
		return 1;
19
	if(s[0] == '.' && s[1] == '.' && s[2] == '/')
20
		return 1;
21
	return 0;
22
}
23
 
24
void
25
main(int argc, char **argv)
26
{
27
	extern int newnsdebug;
28
	char *defargv[] = { "/bin/rc", "-i", nil };
29
	char *nsfile, err[ERRMAX];
30
	int add;
31
 
32
	rfork(RFNAMEG);
33
	add = 0;
34
	nsfile = "/lib/namespace";
35
	ARGBEGIN{
36
	case 'a':
37
		add = 1;
38
		break;
39
	case 'd':
40
		newnsdebug = 1;
41
		break;
42
	case 'n':
43
		nsfile = ARGF();
44
		break;
45
	default:
46
		usage();
47
		break;
48
	}ARGEND
49
	if(argc == 0)
50
		argv = defargv;
51
	if (add)
52
		addns(getuser(), nsfile);
53
	else
54
		newns(getuser(), nsfile);
55
	exec(argv[0], argv);
56
	if(!rooted(argv[0])){
57
		rerrstr(err, sizeof err);
58
		exec(smprint("/bin/%s", argv[0]), argv);
59
		errstr(err, sizeof err);
60
	}
61
	sysfatal("exec: %s: %r", argv[0]);
62
}