From a48cfba9520a8ad9bf1308dcbac3fc6ee23894ba Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 7 Feb 2015 15:32:22 -0600 Subject: Merge unshare and nsenter (promoting and cleaning up nsenter). Needs more testing, don't have a test environment set up for this yet... --- toys/pending/nsenter.c | 104 ------------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 toys/pending/nsenter.c (limited to 'toys/pending') diff --git a/toys/pending/nsenter.c b/toys/pending/nsenter.c deleted file mode 100644 index 33db873e..00000000 --- a/toys/pending/nsenter.c +++ /dev/null @@ -1,104 +0,0 @@ -/* nsenter.c - Enter existing namespaces - * - * Copyright 2014 andy Lutomirski - -USE_NSENTER(NEWTOY(nsenter, "<1F(no-fork)t#(target)i:(ipc);m:(mount);n:(net);p:(pid);u:(uts);U:(user);", TOYFLAG_USR|TOYFLAG_BIN)) - -config NSENTER - bool "nsenter" - default n - help - usage: nsenter [-t pid] [-F] [-i] [-m] [-n] [-p] [-u] [-U] COMMAND... - - Run COMMAND in a different set of namespaces. - - -T PID to take namespaces from - -F don't fork, even if -p is set - - The namespaces to switch are: - - -i SysV IPC (message queues, semaphores, shared memory) - -m Mount/unmount tree - -n Network address, sockets, routing, iptables - -p Process IDs and init (will fork unless -F is used) - -u Host and domain names - -U UIDs, GIDs, capabilities - - Each of those options takes an optional argument giving the path of - the namespace file (usually in /proc). This optional argument is - mandatory unless -t is used. -*/ - -#define FOR_nsenter -#define _GNU_SOURCE -#include "toys.h" -#include -#include -#include - -#define NUM_NSTYPES 6 - -struct nstype { - int type; - const char *name; -}; - -struct nstype nstypes[NUM_NSTYPES] = { - {CLONE_NEWUSER, "user"}, /* must be first to allow non-root operation */ - {CLONE_NEWUTS, "uts"}, - {CLONE_NEWPID, "pid"}, - {CLONE_NEWNET, "net"}, - {CLONE_NEWNS, "mnt"}, - {CLONE_NEWIPC, "ipc"}, -}; - -GLOBALS( - char *nsnames[6]; - long targetpid; -) - -static void enter_by_name(int idx) -{ - int fd, rc; - char buf[64]; - char *filename = TT.nsnames[idx]; - - if (!(toys.optflags & (1<