Browse code

Check for apparmor file before reading it

I ran a single integration test and got an error that the file
/sys/module/apparmor/parameters/enabled doesn't exist. I don't have
apparmor installed. So, just check the file first to avoid a confusing
error.

Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>

Christy Perez authored on 2015/06/10 04:01:58
Showing 2 changed files
... ...
@@ -28,7 +28,7 @@ fi
28 28
 
29 29
 if [ -z "$DOCKER_TEST_HOST" ]; then
30 30
 	# Start apparmor if it is enabled
31
-	if [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then
31
+	if [ -e "/sys/module/apparmor/parameters/enabled" ] && [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then
32 32
 		# reset container variable so apparmor profile is applied to process
33 33
 		# see https://github.com/docker/libcontainer/blob/master/apparmor/apparmor.go#L16
34 34
 		export container=""
... ...
@@ -12,7 +12,7 @@ done
12 12
 
13 13
 if [ -z "$DOCKER_TEST_HOST" ]; then
14 14
 	# Stop apparmor if it is enabled
15
-	if [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then
15
+	if [ -e "/sys/module/apparmor/parameters/enabled" ] && [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then
16 16
 		(
17 17
 			set -x
18 18
 			/etc/init.d/apparmor stop