exec-remount remounts proc and sys, to get the right namespaces associated with them.
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Sun, 13 Jul 2008 17:34:35 +0000 (17:34 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Sun, 13 Jul 2008 17:34:35 +0000 (17:34 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2735 94cd875c-1c1d-0410-91d2-eb244daf1a30

scripts/vserver.start
src/Makefile-files
src/exec-remount.c [new file with mode: 0644]

index ff5300b..25b4767 100644 (file)
@@ -142,6 +142,7 @@ if $_VSERVER_INFO - FEATURE migrate; then
     ${OPTION_STRACE:+$_STRACE -fF -o /tmp/vserver-start.$$} \
     ${USE_VNAMESPACE:+$_VNAMESPACE --set -- } \
     $_VSPACE     --set "${OPTS_VSPACE[@]}" -- \
+    $_EXEC_REMOUNT -- \
     $_VLIMIT     --dir "$VSERVER_DIR"/rlimits --missingok -- \
     $_VSCHED     --xid self --force "${OPTS_VSCHED[@]}" -- \
     $_VSYSCTL    --xid self --dir "$VSERVER_DIR"/sysctl --missingok -- \
index faacdff..3ffda07 100644 (file)
@@ -85,7 +85,8 @@ DIETPROGS +=          src/chcontext-compat \
                        src/vtag \
                        src/vspace \
                        src/vmemctrl \
-                       src/tunctl
+                       src/tunctl \
+                       src/exec-remount
 
 if ENSC_CAN_CRYPTO_WITH_DIETLIBC
 DIETPROGS +=           src/vhashify
@@ -126,6 +127,7 @@ pkglib_PROGRAMS +=  src/capchroot \
                        src/vsysctl \
                        src/h2ext \
                        src/tunctl \
+                       src/exec-remount \
                        $(src_pkglib_C99_X_PROGS) \
                        $(src_pkglib_CXX_X_PROGS)
 
@@ -368,6 +370,10 @@ src_tunctl_SOURCES         = src/tunctl.c
 src_tunctl_LDADD               = $(VSERVER_LDADDS) $(LIBINTERNAL)
 src_tunctl_LDFLAGS             = $(VSERVER_LDFLGS)
 
+src_exec_remount_SOURCES       = src/exec-remount.c
+src_exec_remount_LDADD         = $(VSERVER_LDADDS)
+src_exec_remount_LDFLAGS       = $(VSERVER_LDFLGS)
+
 EXTRA_PROGRAMS +=              $(src_sbin_CXX_PROGS) $(src_pkglib_CXX_PROGS)
 
 TESTS_ENVIRONMENT +=           srctestsuitedir=$(top_builddir)/src/testsuite
diff --git a/src/exec-remount.c b/src/exec-remount.c
new file mode 100644 (file)
index 0000000..05157c7
--- /dev/null
@@ -0,0 +1,61 @@
+// $Id$    --*- c -*--
+
+// Copyright (C) 2008 Daniel Hokka Zakrisson
+//  
+// 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 <config.h>
+#endif
+
+#include "util.h"
+
+#include <vserver.h>
+
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mount.h>
+#include <errno.h>
+
+#define ENSC_WRAPPERS_PREFIX   "exec-remount: "
+#define ENSC_WRAPPERS_MOUNT    1
+#define ENSC_WRAPPERS_UNISTD   1
+#include <wrappers.h>
+
+#define CMD_HELP               0x1000
+#define CMD_VERSION            0x1001
+
+int            wrapper_exit_code  =  255;
+
+int main(int argc, char *argv[])
+{
+       int i = 1;
+       if (vc_isSupported(vcFEATURE_PIDSPACE)) {
+               /* FIXME: Get options from etc/mtab
+                *        Get list of filesystems from argv
+                */
+               if (umount("proc") == 0)
+                       Emount("proc", "proc", "proc", 0, NULL);
+               if (umount("sys") == 0)
+                       Emount("sysfs", "sys", "sysfs", 0, NULL);
+       }
+       if (strcmp(argv[i], "--") == 0)
+               i++;
+       EexecvpD(argv[i], argv+i);
+       /* NOTREACHED */
+       return 1;
+}