]> git.pld-linux.org Git - packages/util-vserver.git/blob - util-vserver-0.30.210-namespace-cleanup.patch
- waldi's namespace cleanup patch
[packages/util-vserver.git] / util-vserver-0.30.210-namespace-cleanup.patch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 12_vnamespace_cleanup.dpatch by Micah Anderson <Micah Anderson <micah@debian.org>>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: No description.
6
7 @DPATCH@
8 diff -urNad trunk~/doc/configuration.xml trunk/doc/configuration.xml
9 --- trunk~/doc/configuration.xml        2006-03-20 08:16:46.000000000 -0500
10 +++ trunk/doc/configuration.xml 2006-04-05 23:18:43.000000000 -0400
11 @@ -37,6 +37,14 @@
12        </description>
13      </boolean>
14  
15 +    <boolean id="global-namespace-cleanup" name="namespace-cleanup">
16 +      <description>
17 +Enable namespace cleanup globally. It can be overridden for a single vserver
18 +by setting the <optionref ref="global-nonamespace-cleanup">nonamespace-cleanup</optionref> flag
19 +there.
20 +      </description>
21 +    </boolean>
22 +
23      <link name="run.rev">
24        <description>
25  Path of the vserver run reverse directory. This directory contains
26 @@ -344,6 +352,19 @@
27        </description>
28      </boolean>
29  
30 +    <boolean id="global-nonamespace-cleanup" name="nonamespace-cleanup">
31 +      <description>
32 +Overrides the global <optionref ref="global-namespace-cleanup">namespace-cleanup</optionref> flag and disables
33 +namespace cleanup for the current vserver.
34 +      </description>
35 +    </boolean>
36 +
37 +    <boolean name="namespace-cleanup">
38 +      <description>
39 +Enable namespace cleanup for the current vserver.
40 +      </description>
41 +    </boolean>
42 +
43      <hash name="schedule">
44        <description>
45  [experimental; name is subject of possible change] Contains the
46 diff -urNad trunk~/scripts/functions trunk/scripts/functions
47 --- trunk~/scripts/functions    2006-03-20 08:16:45.000000000 -0500
48 +++ trunk/scripts/functions     2006-04-05 23:18:43.000000000 -0400
49 @@ -480,6 +480,18 @@
50           -e "$cfgdir"/nonamespace
51  }
52  
53 +function isNamespaceCleanup
54 +{
55 +    local cfgdir
56 +
57 +    $_VSERVER_INFO - FEATURE namespace   || return 0
58 +    cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || return 0
59 +    test -e "$cfgdir"/nonamespace-cleanup && return 0
60 +    test -e "$__CONFDIR"/.defaults/namespace-cleanup -o \
61 +         -e "$cfgdir"/namespace-cleanup && return 1
62 +    return 0
63 +}
64 +
65  ## Usage: getAllVservers <var> [<KIND>*]
66  function getAllVservers
67  {
68 diff -urNad trunk~/scripts/vserver.functions trunk/scripts/vserver.functions
69 --- trunk~/scripts/vserver.functions    2006-03-20 08:16:45.000000000 -0500
70 +++ trunk/scripts/vserver.functions     2006-04-05 23:19:01.000000000 -0400
71 @@ -743,13 +743,13 @@
72  
73      test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
74  
75 -    test -z "$NAMESPACE_CLEANUP" || isAvoidNamespace "$cfgdir" || \
76 -       $_VNAMESPACE --cleanup
77 -
78      _mountVserverInternal "$cfgdir"/fstab
79      _mountVserverInternal "$cfgdir"/fstab.local
80      _mountVserverInternal "$cfgdir"/fstab.remote $_CHBIND "${CHBIND_OPTS[@]}"
81  
82 +    isNamespaceCleanup "$cfgdir" || \
83 +        _namespaceCleanup
84 +
85      isAvoidNamespace "$cfgdir" || \
86         $_SECURE_MOUNT --rbind -n "$vdir" "/"
87  }
88 @@ -1099,3 +1099,29 @@
89         _saveSingleDiskLimit "$vdir" "$dlimit"
90      done
91  }
92 +
93 +function _namespaceCleanup
94 +{
95 +    local root=$(readlink -f "$vdir")
96 +    local tmp="$root"
97 +    local list=""
98 +    while [ "$tmp" ]; do
99 +       list="$list $tmp"
100 +       tmp="${tmp%/*}"
101 +    done
102 +    local list_umount=""
103 +    while read dev path opts; do
104 +        [ "$path" ] || continue
105 +        for i in $root /dev /proc; do
106 +            [ "${path#$i}" != "$path" ] && continue 2
107 +        done
108 +        for i in $list /; do
109 +            [ "$path" = "$i" ] && continue 2
110 +        done
111 +        list_umount="$path $list_umount"
112 +    done < /proc/mounts
113 +    for i in $list_umount; do
114 +        umount $i
115 +    done
116 +}
117 +
This page took 0.04722 seconds and 4 git commands to generate.