Browse code

Make stop/disable of apparmor work on all SLE systems

The existing code to disable apparmor on SUSE systems only worked for
recent openSUSE / SLE releases. On SLE12 (at least), aa-enabled and
aa-teardown are not available, so instead use systemd's interface for
stop/disable. However on newer releases, systemctl stop apparmor is a
no-op:

https://www.suse.com/releasenotes/x86_64/SUSE-SLES/15/#fate-325343
https://gitlab.com/apparmor/apparmor/merge_requests/81
https://build.opensuse.org/package/view_file/openSUSE:Leap:15.2/apparmor/apparmor.service?expand=1

So we still need to call aa-teardown if it's available.

Change-Id: I8d99c8d743cc1935324e2e4fcb67efaa5241199e

Adam Spiers authored on 2019/08/07 22:34:56
Showing 1 changed files
... ...
@@ -230,12 +230,24 @@ function fixup_suse {
230 230
         return
231 231
     fi
232 232
 
233
-    # Disable apparmor profiles in openSUSE distros
234
-    # to avoid issues with haproxy and dnsmasq
235
-    if [ -x /usr/sbin/aa-enabled ] && sudo /usr/sbin/aa-enabled -q; then
236
-        sudo systemctl disable apparmor
233
+    # Deactivate and disable apparmor profiles in openSUSE and SLE
234
+    # distros to avoid issues with haproxy and dnsmasq.  In newer
235
+    # releases, systemctl stop apparmor is actually a no-op, so we
236
+    # have to use aa-teardown to make sure we've deactivated the
237
+    # profiles:
238
+    #
239
+    # https://www.suse.com/releasenotes/x86_64/SUSE-SLES/15/#fate-325343
240
+    # https://gitlab.com/apparmor/apparmor/merge_requests/81
241
+    # https://build.opensuse.org/package/view_file/openSUSE:Leap:15.2/apparmor/apparmor.service?expand=1
242
+    if sudo systemctl is-active -q apparmor; then
243
+        sudo systemctl stop apparmor
244
+    fi
245
+    if [ -x /usr/sbin/aa-teardown ]; then
237 246
         sudo /usr/sbin/aa-teardown
238 247
     fi
248
+    if sudo systemctl is-enabled -q apparmor; then
249
+        sudo systemctl disable apparmor
250
+    fi
239 251
 
240 252
     # Since pip10, pip will refuse to uninstall files from packages
241 253
     # that were created with distutils (rather than more modern