Mercurial > hg > toybox
comparison toys/other/unshare.c @ 653:2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 25 Aug 2012 14:25:22 -0500 |
parents | toys/unshare.c@99cb6ad605ee |
children | 6df4ccc0acbe |
comparison
equal
deleted
inserted
replaced
652:2d7c56913fda | 653:2986aa63a021 |
---|---|
1 /* vi: set sw=4 ts=4: | |
2 * | |
3 * unshare.c - run command in new context | |
4 * | |
5 * Copyright 2011 Rob Landley <rob@landley.net> | |
6 * | |
7 * Not in SUSv4. | |
8 | |
9 USE_UNSHARE(NEWTOY(unshare, "<1^nium", TOYFLAG_USR|TOYFLAG_BIN)) | |
10 | |
11 config UNSHARE | |
12 bool "unshare" | |
13 default y | |
14 depends on TOYBOX_CONTAINER | |
15 help | |
16 usage: unshare [-muin] COMMAND... | |
17 | |
18 Create new namespace(s) for this process and its children, so some | |
19 attribute is not shared with the parent process. This is part of | |
20 Linux Containers. Each process can have its own: | |
21 | |
22 -m Mount/unmount tree | |
23 -u Host and domain names | |
24 -i SysV IPC (message queues, semaphores, shared memory) | |
25 -n Network address, sockets, routing, iptables | |
26 */ | |
27 | |
28 #include "toys.h" | |
29 #include <linux/sched.h> | |
30 extern int unshare (int __flags); | |
31 | |
32 void unshare_main(void) | |
33 { | |
34 unsigned flags[]={CLONE_NEWNS, CLONE_NEWUTS, CLONE_NEWIPC, CLONE_NEWNET,0}; | |
35 unsigned f=0; | |
36 int i; | |
37 | |
38 for (i=0; flags[i]; i++) | |
39 if (toys.optflags & (1<<i)) | |
40 f |= flags[i]; | |
41 | |
42 if(unshare(f)) perror_exit("failed"); | |
43 | |
44 xexec(toys.optargs); | |
45 } |