1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 12_vnamespace_cleanup.dpatch by Micah Anderson <Micah Anderson <micah@debian.org>>
4 ## All lines beginning with `## DP:' are a description of the patch.
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
15 + <boolean id="global-namespace-cleanup" name="namespace-cleanup">
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
25 Path of the vserver run reverse directory. This directory contains
30 + <boolean id="global-nonamespace-cleanup" name="nonamespace-cleanup">
32 +Overrides the global <optionref ref="global-namespace-cleanup">namespace-cleanup</optionref> flag and disables
33 +namespace cleanup for the current vserver.
37 + <boolean name="namespace-cleanup">
39 +Enable namespace cleanup for the current vserver.
43 <hash name="schedule">
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
50 -e "$cfgdir"/nonamespace
53 +function isNamespaceCleanup
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
65 ## Usage: getAllVservers <var> [<KIND>*]
66 function getAllVservers
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
73 test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
75 - test -z "$NAMESPACE_CLEANUP" || isAvoidNamespace "$cfgdir" || \
76 - $_VNAMESPACE --cleanup
78 _mountVserverInternal "$cfgdir"/fstab
79 _mountVserverInternal "$cfgdir"/fstab.local
80 _mountVserverInternal "$cfgdir"/fstab.remote $_CHBIND "${CHBIND_OPTS[@]}"
82 + isNamespaceCleanup "$cfgdir" || \
85 isAvoidNamespace "$cfgdir" || \
86 $_SECURE_MOUNT --rbind -n "$vdir" "/"
88 @@ -1099,3 +1099,29 @@
89 _saveSingleDiskLimit "$vdir" "$dlimit"
93 +function _namespaceCleanup
95 + local root=$(readlink -f "$vdir")
98 + while [ "$tmp" ]; do
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
108 + for i in $list /; do
109 + [ "$path" = "$i" ] && continue 2
111 + list_umount="$path $list_umount"
112 + done < /proc/mounts
113 + for i in $list_umount; do