1 === modified file 'parser/rc.apparmor.functions'
2 --- parser/rc.apparmor.functions 2011-08-13 12:15:58 +0000
3 +++ parser/rc.apparmor.functions 2011-08-26 22:55:43 +0000
5 SUBDOMAINFS_MOUNTPOINT=$(grep subdomainfs /etc/fstab | \
6 sed -e 's|^[[:space:]]*[^[:space:]]\+[[:space:]]\+\(/[^[:space:]]*\)[[:space:]]\+subdomainfs.*$|\1|' 2> /dev/null)
8 -if [ -d "/var/lib/${MODULE}" ] ; then
9 - APPARMOR_TMPDIR="/var/lib/${MODULE}"
10 -elif [ -d "/var/lib/${OLD_MODULE}" ] ; then
11 - APPARMOR_TMPDIR="/var/lib/${OLD_MODULE}"
13 - APPARMOR_TMPDIR="/tmp"
17 # keep exit status from parser during profile load. 0 is good, 1 is bad
22 profiles_names_list() {
23 # run the parser on all of the apparmor profiles
25 if [ ! -f "$PARSER" ]; then
26 aa_log_failure_msg "- AppArmor parser not found"
30 for profile in $PROFILE_DIR/*; do
31 if skip_profile "${profile}" && [ -f "${profile}" ] ; then
32 - LIST_ADD=$($PARSER $ABSTRACTIONS -N "$profile" | grep -v '\^')
33 + LIST_ADD=$($PARSER $ABSTRACTIONS -N "$profile" )
35 - echo "$LIST_ADD" >>$TMPFILE
44 - #the list of profiles isn't stable once we start adding or removing
45 - #them so store to tmp first (in reverse order so hat profiles are removed first)
46 - MODULE_PLIST=$(mktemp ${APPARMOR_TMPDIR}/tmp.XXXXXXXX)
47 - sed -e "s/ (\(enforce\|complain\))$//" "$SFS_MOUNTPOINT/profiles" | sort -r > "$MODULE_PLIST"
48 - cat "$MODULE_PLIST" | while read profile ; do
49 + # We filter child profiles as removing the parent will remove
51 + sed -e "s/ (\(enforce\|complain\))$//" "$SFS_MOUNTPOINT/profiles" | \
52 + LC_COLLATE=C sort | grep -v // | while read profile ; do
53 echo -n "$profile" > "$SFS_MOUNTPOINT/.remove"
55 if [ ${rc} -ne 0 ] ; then
67 - PNAMES_LIST=$(mktemp ${APPARMOR_TMPDIR}/tmp.XXXXXXXX)
68 - profiles_names_list ${PNAMES_LIST}
69 - MODULE_PLIST=$(mktemp ${APPARMOR_TMPDIR}/tmp.XXXXXXXX)
70 # Clean out running profiles not associated with the current profile
71 # set, excluding the libvirt dynamically generated profiles.
72 - sed -e "s/ (\(enforce\|complain\))$//" "$SFS_MOUNTPOINT/profiles" | egrep -v '^libvirt-[0-9a-f\-]+$' | sort >"$MODULE_PLIST"
73 - sort "$PNAMES_LIST" | comm -2 -3 "$MODULE_PLIST" - | while IFS= read profile ; do
74 + # Note that we reverse sort the list of profiles to remove to
75 + # ensure that child profiles (e.g. hats) are removed before the
76 + # parent. We *do* need to remove the child profile and not rely
77 + # on removing the parent profile when the profile has had its
78 + # child profile names changed.
79 + profiles_names_list | awk '
81 + while (getline < "'${SFS_MOUNTPOINT}'/profiles" ) {
82 + str = sub(/ \((enforce|complain)\)$/, "", $0);
83 + if (match($0, /^libvirt-[0-9a-f\-]+$/) == 0)
88 +{ if (length(arr[$0]) > 0) { delete arr[$0] } }
92 + if (length(arr[key]) > 0) {
93 + printf("%s\n", arr[key])
96 +' | LC_COLLATE=C sort -r | while IFS= read profile ; do
97 echo -n "$profile" > "$SFS_MOUNTPOINT/.remove"