From: Enrico Scholz Date: Fri, 5 Mar 2004 03:23:39 +0000 (+0000) Subject: obsoleted by vnamespace X-Git-Tag: VERSION_0_10~489 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1db27120460f531708565bf6ee1ca2cbf388197e;p=util-vserver.git obsoleted by vnamespace git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1082 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/src/enter-namespace.c b/util-vserver/src/enter-namespace.c deleted file mode 100644 index d672a4b..0000000 --- a/util-vserver/src/enter-namespace.c +++ /dev/null @@ -1,78 +0,0 @@ -// $Id$ --*- c -*-- - -// Copyright (C) 2004 Enrico Scholz -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "util.h" -#include - -#include -#include -#include - -static void -showHelp(int fd, char const *cmd, int exit_code) -{ - VSERVER_DECLARE_CMD(cmd); - - WRITE_MSG(fd, "Usage: "); - WRITE_STR(fd, cmd); - WRITE_MSG(fd, - " \n" - "\n" - "Enters namespace of context and executes there.\n" - "\n" - "Report bugs to " PACKAGE_BUGREPORT "\n"); - - exit(exit_code); -} - -static void -showVersion() -{ - WRITE_MSG(1, - "enter-namespace " VERSION " -- enters namespaces and executes programs there\n" - "This program is part of " PACKAGE_STRING "\n" - "Copyright (C) 2003 Enrico Scholz\n" - VERSION_COPYRIGHT_DISCLAIMER); - exit(0); -} - -int main(int argc, char *argv[]) -{ - if (argc==1) showHelp(2, argv[0], 255); - if (!strcmp(argv[1], "--help")) showHelp(1, argv[0], 0); - if (!strcmp(argv[1], "--version")) showVersion(); - if (!strcmp(argv[1], "--")) { ++argv; --argc; } - - if (argc<2) { - WRITE_MSG(2, "No context and/or command specified; try '--help' for more information\n"); - exit(255); - } - - if (vc_enter_namespace(atoi(argv[1]))==-1) { - perror("enter-namespace: vc_enter_namespace()"); - exit(255); - } - - execvp(argv[2], argv+2); - perror("enter-namespace: execvp()"); - exit(255); -} diff --git a/util-vserver/src/new-namespace.c b/util-vserver/src/new-namespace.c deleted file mode 100644 index f966080..0000000 --- a/util-vserver/src/new-namespace.c +++ /dev/null @@ -1,105 +0,0 @@ -// $Id$ --*- c++ -*-- - -// Copyright (C) 2003 Enrico Scholz -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -// Executes a program in a new namespace -// Based on http://www.win.tue.nl/~aeb/linux/lk/lk-6.html - - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "util.h" -#include "sys_clone.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define ENSC_WRAPPERS_PREFIX "new-namespace: " -#define ENSC_WRAPPERS_WAIT 1 -#include - -#ifndef CLONE_NEWNS -# define CLONE_NEWNS 0x00020000 -#endif - -int wrapper_exit_code = 255; - -static void -showHelp(int fd, char const *cmd, int exit_code) -{ - VSERVER_DECLARE_CMD(cmd); - - WRITE_MSG(fd, "Usage: "); - WRITE_STR(fd, cmd); - WRITE_MSG(fd, - " [--help] [--version] \n" - "\n" - "Executes in a new namespace.\n" - "\n" - "Report bugs to " PACKAGE_BUGREPORT "\n"); - - exit(exit_code); -} - -static void -showVersion() -{ - WRITE_MSG(1, - "new-namespace " VERSION " -- executes programs in a new namespace\n" - "This program is part of " PACKAGE_STRING "\n" - "Copyright (C) 2003 Enrico Scholz\n" - VERSION_COPYRIGHT_DISCLAIMER); - exit(0); -} - -int main(int argc, char *argv[]) -{ - pid_t pid; - - if (argc==1) showHelp(2, argv[0], 255); - if (!strcmp(argv[1], "--help")) showHelp(1, argv[0], 0); - if (!strcmp(argv[1], "--version")) showVersion(); - if (!strcmp(argv[1], "--")) ++argv; - - -#ifdef NDEBUG - pid = sys_clone(CLONE_NEWNS|CLONE_VFORK|SIGCHLD, 0); -#else - pid = sys_clone(CLONE_NEWNS|SIGCHLD, 0); -#endif - switch (pid) { - case -1 : - perror("new-namespace: clone()"); - exit(wrapper_exit_code); - case 0 : - execvp(argv[1], argv+1); - perror("new-namespace: execvp()"); - exit(wrapper_exit_code); - default : - exitLikeProcess(pid); - } -}