]> git.pld-linux.org Git - packages/apparmor-parser.git/blob - apparmor-parser-bzr.patch
- release 5
[packages/apparmor-parser.git] / apparmor-parser-bzr.patch
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
4 @@ -83,15 +83,6 @@
5  SUBDOMAINFS_MOUNTPOINT=$(grep subdomainfs /etc/fstab  | \
6         sed -e 's|^[[:space:]]*[^[:space:]]\+[[:space:]]\+\(/[^[:space:]]*\)[[:space:]]\+subdomainfs.*$|\1|' 2> /dev/null)
7  
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}"
12 -else
13 -       APPARMOR_TMPDIR="/tmp"
14 -fi
15 -
16 -
17  # keep exit status from parser during profile load.  0 is good, 1 is bad
18  STATUS=0
19  
20 @@ -221,7 +212,6 @@
21  
22  profiles_names_list() {
23         # run the parser on all of the apparmor profiles
24 -       TMPFILE=$1
25         if [ ! -f "$PARSER" ]; then
26                 aa_log_failure_msg "- AppArmor parser not found"
27                 exit 1
28 @@ -234,9 +224,9 @@
29  
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" )
34                         if [ $? -eq 0 ]; then
35 -                               echo "$LIST_ADD" >>$TMPFILE
36 +                               echo "$LIST_ADD"
37                         fi
38                 fi
39         done
40 @@ -408,18 +398,16 @@
41         fi
42  
43         retval=0
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
50 +       # the children
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"
54                 rc=$?
55                 if [ ${rc} -ne 0 ] ; then 
56                         retval=${rc}
57                 fi
58         done
59 -       rm "$MODULE_PLIST"
60         return ${retval}
61  }
62  
63 @@ -461,17 +449,33 @@
64  
65         configure_owlsm
66         parse_profiles reload
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 '
80 +BEGIN {
81 +  while (getline < "'${SFS_MOUNTPOINT}'/profiles" ) {
82 +    str = sub(/ \((enforce|complain)\)$/, "", $0);
83 +    if (match($0, /^libvirt-[0-9a-f\-]+$/) == 0)
84 +      arr[$str] = $str
85 +  }
86 +}
87 +
88 +{ if (length(arr[$0]) > 0) { delete arr[$0] } }
89 +
90 +END {
91 +  for (key in arr)
92 +    if (length(arr[key]) > 0) {
93 +      printf("%s\n", arr[key])
94 +    }
95 +}
96 +' | LC_COLLATE=C sort -r | while IFS= read profile ; do
97                 echo -n "$profile" > "$SFS_MOUNTPOINT/.remove"
98         done
99 -       rm "$MODULE_PLIST"
100 -       rm "$PNAMES_LIST"
101         return 0
102  }
103  
104
This page took 0.054518 seconds and 3 git commands to generate.