2 # Test SELinux-related options.
4 # Copyright (C) 2007-2012 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/init.sh"; path_prepend_ ..
/src
20 print_ver_ chcon
cp ls mv stat
24 skip_if_mcstransd_is_running_
26 # Create a regular file, dir, fifo.
27 touch f || framework_failure_
28 mkdir d s1 s2 || framework_failure_
32 # special context that works both with and without mcstransd
33 ctx
=root
:object_r
:tmp_t
:s0
36 skip_
'"chcon '$ctx' ..." failed'
38 # inspect that context with both ls -Z and stat.
40 c
=`ls -dogZ $i|cut -d' ' -f3`; test x
$c = x
$ctx || fail
=1
41 c
=`stat --printf %C $i`; test x
$c = x
$ctx || fail
=1
44 # ensure that ls -l output includes the ".".
45 c
=`ls -l f|cut -c11`; test "$c" = . || fail
=1
47 # Copy each to a new directory and ensure that context is preserved.
48 cp -r --preserve=all d f p s1 || fail
=1
50 c
=`stat --printf %C s1/$i`; test x
$c = x
$ctx || fail
=1
53 # Now, move each to a new directory and ensure that context is preserved.
56 c
=`stat --printf %C s2/$i`; test x
$c = x
$ctx || fail
=1