X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Fvcontext.c;h=0d979cfa2ebd19a69f10472f6dc607a7487f5a2f;hb=245184e3863bc621fd6a318fa51da348c1ef86d9;hp=bc42b475a65fc513f1e1a840012e40083dba2a6a;hpb=a4f37dc057de58a91433035a366bf956c6201d69;p=util-vserver.git diff --git a/util-vserver/src/vcontext.c b/util-vserver/src/vcontext.c index bc42b47..0d979cf 100644 --- a/util-vserver/src/vcontext.c +++ b/util-vserver/src/vcontext.c @@ -24,8 +24,6 @@ #include "lib/internal.h" #include "lib_internal/jail.h" -#include "linuxcaps.h" - #include #include #include @@ -48,7 +46,7 @@ #define CMD_XID 0x4000 #define CMD_CREATE 0x4001 #define CMD_MIGRATE 0x4003 -#define CMD_FAKEINIT 0x4002 +#define CMD_INITPID 0x4002 #define CMD_DISCONNECT 0x4004 #define CMD_UID 0x4005 #define CMD_CHROOT 0x4006 @@ -58,6 +56,7 @@ #define CMD_MIGRATESELF 0x400a #define CMD_ENDSETUP 0x400b #define CMD_SILENTEXIST 0x400c +#define CMD_NAMESPACE 0x400d struct option const @@ -69,15 +68,19 @@ CMDLINE_OPTIONS[] = { { "create", no_argument, 0, CMD_CREATE }, { "migrate", no_argument, 0, CMD_MIGRATE }, { "migrate-self", no_argument, 0, CMD_MIGRATESELF }, - { "fakeinit", no_argument, 0, CMD_FAKEINIT }, + { "initpid", no_argument, 0, CMD_INITPID }, { "endsetup", no_argument, 0, CMD_ENDSETUP }, { "disconnect", no_argument, 0, CMD_DISCONNECT }, { "silent", no_argument, 0, CMD_SILENT }, { "silentexist", no_argument, 0, CMD_SILENTEXIST }, { "uid", required_argument, 0, CMD_UID }, { "chroot", no_argument, 0, CMD_CHROOT }, + { "namespace", no_argument, 0, CMD_NAMESPACE }, { "syncsock", required_argument, 0, CMD_SYNCSOCK }, { "syncmsg", required_argument, 0, CMD_SYNCMSG }, +#if 1 + { "fakeinit", no_argument, 0, CMD_INITPID }, // compatibility +#endif { 0,0,0,0 }, }; @@ -87,8 +90,9 @@ struct Arguments { bool do_migrateself; bool do_disconnect; bool do_endsetup; - bool is_fakeinit; + bool is_initpid; bool is_silentexist; + bool set_namespace; int verbosity; bool do_chroot; uid_t uid; @@ -112,8 +116,9 @@ showHelp(int fd, char const *cmd, int res) "\n" " can be:\n" " --chroot ... chroot into current directory\n" + " --namespace ... execute namespace management operations\n" " --uid ... change uid\n" - " --fakeinit ... set current process as general process reaper\n" + " --initpid ... set current process as general process reaper\n" " for ctx (possible for --migrate only)\n" " --endsetup ... clear the setup flag; usefully for migrate only\n" " --disconnect ... start program in background\n" @@ -184,7 +189,7 @@ setFlags(struct Arguments const *args, xid_t xid) { struct vc_ctx_flags flags = { 0,0 }; - if (args->is_fakeinit) + if (args->is_initpid) flags.mask |= VC_VXF_STATE_INIT; if (args->do_endsetup) @@ -244,8 +249,13 @@ doit(struct Arguments const *args, char *argv[]) else xid = args->xid; - if (args->do_chroot) + if (args->do_chroot) { Echroot("."); + if (args->set_namespace) { + if (args->do_migrateself) Evc_set_namespace(); + else if (args->do_migrate) Evc_enter_namespace(xid); + } + } setFlags(args, xid); @@ -284,8 +294,9 @@ int main (int argc, char *argv[]) .do_migrateself = false, .do_disconnect = false, .do_endsetup = false, - .is_fakeinit = false, + .is_initpid = false, .is_silentexist = false, + .set_namespace = false, .verbosity = 1, .uid = -1, .xid = VC_DYNAMIC_XID, @@ -303,8 +314,9 @@ int main (int argc, char *argv[]) case CMD_MIGRATE : args.do_migrate = true; break; case CMD_DISCONNECT : args.do_disconnect = true; break; case CMD_ENDSETUP : args.do_endsetup = true; break; - case CMD_FAKEINIT : args.is_fakeinit = true; break; + case CMD_INITPID : args.is_initpid = true; break; case CMD_CHROOT : args.do_chroot = true; break; + case CMD_NAMESPACE : args.set_namespace = true; break; case CMD_SILENTEXIST : args.is_silentexist = true; break; case CMD_SYNCSOCK : args.sync_sock = optarg; break; case CMD_SYNCMSG : args.sync_msg = optarg; break; @@ -334,8 +346,8 @@ int main (int argc, char *argv[]) WRITE_MSG(2, "Neither '--create' nor '--migrate specified; try '--help' for more information\n"); else if (args.do_create && args.do_migrate) WRITE_MSG(2, "Can not specify '--create' and '--migrate' at the same time; try '--help' for more information\n"); - else if (!args.do_migrate && args.is_fakeinit) - WRITE_MSG(2, "'--fakeinit' is possible in combination with '--migrate' only\n"); + else if (!args.do_migrate && args.is_initpid) + WRITE_MSG(2, "'--initpid' is possible in combination with '--migrate' only\n"); else if (!args.do_create && args.xid==VC_DYNAMIC_XID) WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "Can not migrate to an unknown context\n"); else if (optind>=argc)