From 52dfff5433ea99e7427e781a1db43b68cbfe9243 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Sun, 13 Jul 2008 17:34:35 +0000 Subject: [PATCH] exec-remount remounts proc and sys, to get the right namespaces associated with them. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2735 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- scripts/vserver.start | 1 + src/Makefile-files | 8 ++++++- src/exec-remount.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 src/exec-remount.c diff --git a/scripts/vserver.start b/scripts/vserver.start index ff5300b..25b4767 100644 --- a/scripts/vserver.start +++ b/scripts/vserver.start @@ -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 -- \ diff --git a/src/Makefile-files b/src/Makefile-files index faacdff..3ffda07 100644 --- a/src/Makefile-files +++ b/src/Makefile-files @@ -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 index 0000000..05157c7 --- /dev/null +++ b/src/exec-remount.c @@ -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 +#endif + +#include "util.h" + +#include + +#include +#include +#include +#include +#include +#include + +#define ENSC_WRAPPERS_PREFIX "exec-remount: " +#define ENSC_WRAPPERS_MOUNT 1 +#define ENSC_WRAPPERS_UNISTD 1 +#include + +#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; +} -- 1.8.1.5