]> git.proxmox.com Git - lxc.git/blob - debian/patches/extra/0004-tests-lxc-test-apparmor-mount-show-a-log-on-error.patch
bump version to 3.0.1+pve1-1
[lxc.git] / debian / patches / extra / 0004-tests-lxc-test-apparmor-mount-show-a-log-on-error.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Mon, 23 Jul 2018 17:23:08 +0200
4 Subject: [PATCH] tests: lxc-test-apparmor-mount: show a log on error
5
6 Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
7 (cherry picked from commit d6523915861f2289505a11140874001099dfdfdc)
8 ---
9 src/tests/lxc-test-apparmor-mount | 24 ++++++++++++++++++++----
10 1 file changed, 20 insertions(+), 4 deletions(-)
11
12 diff --git a/src/tests/lxc-test-apparmor-mount b/src/tests/lxc-test-apparmor-mount
13 index ddcee8a7..144467c8 100755
14 --- a/src/tests/lxc-test-apparmor-mount
15 +++ b/src/tests/lxc-test-apparmor-mount
16 @@ -45,6 +45,7 @@ DONE=0
17 KNOWN_RELEASES="precise trusty xenial yakkety zesty"
18 MOUNTSR=/sys/kernel/security/apparmor/features/mount
19 dnam=`mktemp -d`
20 +logfile=`mktemp`
21 cname=`basename $dnam`
22 cleanup() {
23 run_cmd lxc-destroy -f -n $cname || true
24 @@ -56,12 +57,21 @@ cleanup() {
25 rm -Rf $HDIR /run/user/$(id -u $TUSER)
26 deluser $TUSER
27 if [ $DONE -eq 0 ]; then
28 + echo 'Failed container log:' >&2
29 + cat "$logfile" >&2
30 + echo 'End log' >&2
31 + rm -f "$logfile"
32 echo "FAIL"
33 exit 1
34 fi
35 + rm -f "$logfile"
36 echo "PASS"
37 }
38
39 +clear_log() {
40 + truncate -s0 "$logfile"
41 +}
42 +
43 trap cleanup exit
44
45 # Only run on a normally configured ubuntu lxc system
46 @@ -74,6 +84,8 @@ if [ "$(id -u)" != "0" ]; then
47 exit 1
48 fi
49
50 +chmod 0666 "$logfile"
51 +
52 # This would be much simpler if we could run it as
53 # root. However, in order to not have the bind mount
54 # of an empty directory over the securitfs 'mount' directory
55 @@ -160,7 +172,7 @@ fi
56 run_cmd lxc-create -t download -n $cname -- -d ubuntu -r $release -a $ARCH
57
58 echo "test default confined container"
59 -run_cmd lxc-start -n $cname -d
60 +run_cmd lxc-start -n $cname -d -lDEBUG -o "$logfile"
61 run_cmd lxc-wait -n $cname -s RUNNING
62 pid=`run_cmd lxc-info -p -H -n $cname`
63 profile=`cat /proc/$pid/attr/current`
64 @@ -169,10 +181,11 @@ if [ "x$profile" != "x${default_profile}" ]; then
65 exit 1
66 fi
67 run_cmd lxc-stop -n $cname -k
68 +clear_log
69
70 echo "test regular unconfined container"
71 echo "lxc.apparmor.profile = unconfined" >> $HDIR/.local/share/lxc/$cname/config
72 -run_cmd lxc-start -n $cname -d
73 +run_cmd lxc-start -n $cname -d -lDEBUG -o "$logfile"
74 run_cmd lxc-wait -n $cname -s RUNNING
75 pid=`run_cmd lxc-info -p -H -n $cname`
76 profile=`cat /proc/$pid/attr/current`
77 @@ -181,6 +194,7 @@ if [ "x$profile" != "xunconfined" ]; then
78 exit 1
79 fi
80 run_cmd lxc-stop -n $cname -k
81 +clear_log
82
83 echo "masking $MOUNTSR"
84 mount --bind $dnam $MOUNTSR
85 @@ -198,7 +212,7 @@ fi
86
87 echo "test regular unconfined container"
88 echo "lxc.apparmor.profile = unconfined" >> $HDIR/.local/share/lxc/$cname/config
89 -run_cmd lxc-start -n $cname -d
90 +run_cmd lxc-start -n $cname -d -lDEBUG -o "$logfile"
91 run_cmd lxc-wait -n $cname -s RUNNING
92 pid=`run_cmd lxc-info -p -H -n $cname`
93 if [ "$pid" = "-1" ]; then
94 @@ -211,11 +225,12 @@ if [ "x$profile" != "xunconfined" ]; then
95 exit 1
96 fi
97 run_cmd lxc-stop -n $cname -k
98 +clear_log
99
100 echo "testing override"
101 sed -i '/apparmor.profile/d' $HDIR/.local/share/lxc/$cname/config
102 echo "lxc.apparmor.allow_incomplete = 1" >> $HDIR/.local/share/lxc/$cname/config
103 -run_cmd lxc-start -n $cname -d
104 +run_cmd lxc-start -n $cname -d -lDEBUG -o "$logfile"
105 run_cmd lxc-wait -n $cname -s RUNNING
106 pid=`run_cmd lxc-info -p -H -n $cname`
107 if [ "$pid" = "-1" ]; then
108 @@ -228,5 +243,6 @@ if [ "x$profile" != "x${default_profile}" ]; then
109 exit 1
110 fi
111 run_cmd lxc-stop -n $cname -k
112 +clear_log
113
114 DONE=1
115 --
116 2.11.0
117