Only call remount on kernels newer than 2.6.26 without BME where it's needed, as...
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Wed, 16 Feb 2011 12:49:03 +0000 (12:49 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Wed, 16 Feb 2011 12:49:03 +0000 (12:49 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2935 94cd875c-1c1d-0410-91d2-eb244daf1a30

lib/Makefile-files
lib/getkernel.c [new file with mode: 0644]
lib/issupported.c
lib/issupportedstring.c
lib/vserver.h
src/secure-mount.c

index 075c82c..e607f53 100644 (file)
@@ -203,6 +203,7 @@ lib_SRCS =                          lib/syscall.c \
                                lib/val2text-v2t-uint32.c \
                                lib/val2text-v2t-uint64.c \
                                lib/parselimit.c \
+                               lib/getkernel.c \
                                $(lib_legacy_SRCS) \
                                $(lib_compat_SRCS) \
                                $(lib_management_SRCS) \
diff --git a/lib/getkernel.c b/lib/getkernel.c
new file mode 100644 (file)
index 0000000..b9a36c8
--- /dev/null
@@ -0,0 +1,58 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2011 Daniel Hokka Zakrisson <daniel@hozac.com>
+//  
+// 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 <sys/utsname.h>
+#include <ctype.h>
+
+int
+vc_get_kernel()
+{
+  static int linux_ver = -1;
+  if (linux_ver == -1) {
+    struct utsname uts;
+    char *p;
+    int part, n;
+    if (uname(&uts) == -1)
+      return -1;
+    part = 0;
+    n = 0;
+    linux_ver = 0;
+    for (p = uts.release; *p && part < 3; p++) {
+      if (*p == '.') {
+       if (part < 3) {
+         linux_ver |= n << (8 * (2 - part));
+         n = 0;
+         part++;
+       }
+      }
+      else if (isdigit(*p)) {
+       n *= 10;
+       n += *p - '0';
+      }
+      else
+       break;
+    }
+    if (n > 0 && part < 3)
+      linux_ver |= n << (8 * (2 - part));
+  }
+  return linux_ver;
+}
index e1176de..6859094 100644 (file)
@@ -28,6 +28,7 @@ vc_isSupported(vcFeatureSet feature)
 {
   int          ver = vc_get_version();
   vc_vci_t     conf = vc_get_vci();
+  int          linux_ver = vc_get_kernel();
   if (ver==-1) return false;
   if (conf==(vc_vci_t)-1) conf = 0;
 
@@ -53,6 +54,7 @@ vc_isSupported(vcFeatureSet feature)
     case vcFEATURE_PIDSPACE    :  return false;
     case vcFEATURE_MEMCG       :  return ver >= 0x00020306 && conf & VC_VCI_MEMCG;
     case vcFEATURE_DYNAMIC     :  return ver <  0x00020300 || !(conf & VC_VCI_NO_DYNAMIC);
+    case vcFEATURE_BME         :  return linux_ver < 0x0002061a;
     default                    :  assert(false); 
   }
 
index 746f5f3..03fb46c 100644 (file)
@@ -36,7 +36,7 @@ static struct {
   DECL(VHI),     DECL(VSHELPER0), DECL(VSHELPER), DECL(VWAIT),
   DECL(VNET),    DECL(VSTAT),     DECL(PPTAG),    DECL(PIDSPACE),
   DECL(SPACES),  DECL(PERSISTENT),DECL(PIVOT_ROOT),DECL(MEMCG),
-  DECL(DYNAMIC), 
+  DECL(DYNAMIC), DECL(BME),
 };
 
 bool
index f8da611..1d553f4 100644 (file)
@@ -392,6 +392,8 @@ extern "C" {
      */
   vc_vci_t     vc_get_vci();
 
+  int          vc_get_kernel();
+
     /** \brief   Moves current process into a context
      *  \ingroup syscalls
      *
@@ -991,6 +993,7 @@ extern "C" {
                 vcFEATURE_VNET,   vcFEATURE_VSTAT,   vcFEATURE_PPTAG,
                 vcFEATURE_PIDSPACE, vcFEATURE_SPACES, vcFEATURE_PERSISTENT,
                 vcFEATURE_PIVOT_ROOT, vcFEATURE_MEMCG, vcFEATURE_DYNAMIC,
+                vcFEATURE_BME,
                 }
     vcFeatureSet;
 
index baf2c4a..ae0650f 100644 (file)
@@ -470,7 +470,8 @@ mountSingle(struct MountInfo const *mnt, struct Options *opt)
       opt->cur_dir_fd = Eopen(".", O_RDONLY|O_DIRECTORY, 0);
       Efcntl(opt->cur_dir_fd, F_SETFD, FD_CLOEXEC);
     }
-    if ((mnt->flag & MS_BIND) &&
+    if (!vc_isSupported(vcFEATURE_BME) &&
+       (mnt->flag & MS_BIND) &&
        (mnt->mask & ~(MS_BIND|MS_REC))) {
       /* This is needed to put us in the new mountpoint */
       if (!secureChdir(mnt->dst, opt))