diff options
author | Kai Kang <kai.kang@windriver.com> | 2017-09-05 16:54:42 +0800 |
---|---|---|
committer | Mark Hatle <mark.hatle@windriver.com> | 2017-09-08 13:20:27 -0500 |
commit | beaaa37217546c99a3960e4855d8b914f4377b97 (patch) | |
tree | a8969332f3befe0659120f3148615fc29d8cbb65 | |
parent | 2aadc0d5fbd91606493463a12307579f660b6918 (diff) | |
download | meta-selinux-beaaa37217546c99a3960e4855d8b914f4377b97.tar.gz |
attr: fix ptest failures when selinux enabled
When selinux is enabled, a file has a default attribute
"security.selinux" and the output of getfattr shows:
# file: here
security.selinux="system_u:object_r:lib_t:s0"
That always causes more output of command getfattr than expected.
Filter out selinux related attribute info, and if the file has only
selinux attribute info, remove its whole output.
Signed-off-by: Kai Kang <kai.kang@windriver.com>
-rw-r--r-- | recipes-support/attr/attr/fix-ptest-failures-when-selinux-enabled.patch | 41 | ||||
-rw-r--r-- | recipes-support/attr/attr_%.bbappend | 5 |
2 files changed, 46 insertions, 0 deletions
diff --git a/recipes-support/attr/attr/fix-ptest-failures-when-selinux-enabled.patch b/recipes-support/attr/attr/fix-ptest-failures-when-selinux-enabled.patch new file mode 100644 index 0000000..e1eefa7 --- /dev/null +++ b/recipes-support/attr/attr/fix-ptest-failures-when-selinux-enabled.patch | |||
@@ -0,0 +1,41 @@ | |||
1 | Upstream-Status: Pending | ||
2 | |||
3 | When enable selinux, file has a default attribute: | ||
4 | |||
5 | # file: here | ||
6 | security.selinux="system_u:object_r:lib_t:s0" | ||
7 | |||
8 | That cause there is always more output than expected. | ||
9 | |||
10 | Filter out selinux related attribute info to make ptest pass. | ||
11 | |||
12 | Signed-off-by: Kai Kang <kai.kang@windriver.com> | ||
13 | --- | ||
14 | diff --git a/test/run b/test/run | ||
15 | index cf15252..945741e 100755 | ||
16 | --- a/test/run | ||
17 | +++ b/test/run | ||
18 | @@ -132,6 +132,23 @@ sub process_test($$$$) { | ||
19 | print "[$prog_line] \$ ", join(' ', | ||
20 | map { s/\s/\\$&/g; $_ } @$p), " -- "; | ||
21 | my $result = exec_test($prog, $in); | ||
22 | + | ||
23 | + # filter selinux related attributes info | ||
24 | + my @strip1; | ||
25 | + my @strip2; | ||
26 | + foreach (@$result) { | ||
27 | + unless (/security.selinux=.*\n/) { | ||
28 | + push @strip1, $_; | ||
29 | + } | ||
30 | + } | ||
31 | + for (my $i = 0; $i <= $#strip1; $i++) { | ||
32 | + if ($strip1[$i] =~ /^# file:.*/ && $strip1[$i+1] =~ /^\n$/) { | ||
33 | + $i++; | ||
34 | + } else { | ||
35 | + push @strip2, $strip1[$i]; | ||
36 | + } | ||
37 | + } | ||
38 | + $result = \@strip2; | ||
39 | my @good = (); | ||
40 | my $nmax = (@$out > @$result) ? @$out : @$result; | ||
41 | for (my $n=0; $n < $nmax; $n++) { | ||
diff --git a/recipes-support/attr/attr_%.bbappend b/recipes-support/attr/attr_%.bbappend new file mode 100644 index 0000000..6be8191 --- /dev/null +++ b/recipes-support/attr/attr_%.bbappend | |||
@@ -0,0 +1,5 @@ | |||
1 | inherit selinux | ||
2 | |||
3 | FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" | ||
4 | |||
5 | SRC_URI += "${@target_selinux(d, 'file://fix-ptest-failures-when-selinux-enabled.patch')}" | ||