Don't mount the ns subsystem.
[util-vserver.git] / scripts / vserver.functions
index 63d1bad..b014abf 100644 (file)
@@ -147,6 +147,8 @@ function _generateIONiceCommand
     local ionice_class=2
     local ionice_priority=0
 
+    test -n "$_IONICE" || return 0
+
     test -r "$vdir/ionice/class" && read ionice_class <"$vdir"/ionice/class
     test -r "$vdir/ionice/priority" && read ionice_priority <"$vdir"/ionice/priority
 
@@ -916,6 +918,10 @@ function _mountVserverInternal
     # magic regarding the mtab file; when etc/mtab can not be touched,
     # add the '-n' flag to mount
     test -w etc -o -w etc/mtab || xflag=-n
+    if test -h etc/mtab; then
+       local l=$($_READLINK etc/mtab)
+       test "${l##/proc/}" = "$l" || xflag=-n
+    fi
     "$@" $_SECURE_MOUNT -a $xflag --chroot --fstab "$fstab" --rootfs no
     popd >/dev/null
 }
@@ -966,10 +972,10 @@ function mountVserver
         _namespaceCleanup "$cfgdir"
 
     real_vdir=$(getPhysicalDir "$vdir")
-    ! $_VSERVER_INFO - FEATURE PIVOT_ROOT || \
-       extra_opt=,shared
     isAvoidNamespace "$cfgdir" || \
-       $_SECURE_MOUNT --rbind -n -o dev$extra_opt "$vdir" "$real_vdir"
+       $_SECURE_MOUNT --rbind -n -o dev "$vdir" "$real_vdir"
+    ! $_VSERVER_INFO - FEATURE PIVOT_ROOT || \
+       $_SECURE_MOUNT -n -o shared,rec "$real_vdir" "$real_vdir"
 }
 
 function _umountVserverInternal
@@ -1376,7 +1382,8 @@ function _namespaceCleanup
     while read -r dev path opts; do
        test -n "$path" || continue
        for i in "$root" /dev /proc; do
-           test "${path#$i}" != "$path" && continue 2
+           path_dir="${path}/"
+           test "${path_dir#${i}/}" != "${path_dir}" && continue 2
        done
        for i in "${list[@]}" /; do
            test "$path" = "$i" && continue 2
@@ -1436,6 +1443,10 @@ function _generateCgroupOptions
     findFile file "$__CONFDIR/.defaults/cgroup/subsys" ""
     if test -n "$file"; then
        read CGROUP_SUBSYS < "$file"
+    elif $_GREP -q '^ns[[:space:]]' /proc/cgroups; then
+       # Hack for the ns subsystem, with which we are incompatible
+       CGROUP_SUBSYS=$($_SED '/^#/d;/^ns[[:space:]]/d;s/[[:space:]].*//' /proc/cgroups | \
+                       (s=""; while read x; do test -n "$s" && s="$s,"; s="$s$x"; done; echo "$s"))
     fi
     findFile file "$__CONFDIR/.defaults/cgroup/inherit" ""
     if test -n "$file"; then
@@ -1485,7 +1496,10 @@ function _handleCgroup
 
            shopt -s nullglob
            for i in "$dir"/*; do
-               cat "$i" > "$CGROUP_MNT/$name/${i##*/}"
+               f="${i##*/}"
+               test "$f" != mnt -a "$f" != subsys -a \
+                   "$f" != inherit -a "$f" != name || continue
+               cat "$i" > "$CGROUP_MNT/$name/$f"
            done
        fi
        echo "$$" > "$CGROUP_MNT/$name/tasks"