test: expose recent gnulib canonicalize bug
[coreutils/ericb.git] / tests / misc / selinux
blob810996c8793b0c2a1cc09fb42bcf9e400f48530b
1 #!/bin/sh
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
22 require_root_
23 require_selinux_
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_
29 mkfifo_or_skip_ p
32 # special context that works both with and without mcstransd
33 ctx=root:object_r:tmp_t:s0
35 chcon $ctx f d p ||
36 skip_ '"chcon '$ctx' ..." failed'
38 # inspect that context with both ls -Z and stat.
39 for i in d f p; do
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
42 done
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
49 for i in d f p; do
50 c=`stat --printf %C s1/$i`; test x$c = x$ctx || fail=1
51 done
53 # Now, move each to a new directory and ensure that context is preserved.
54 mv d f p s2 || fail=1
55 for i in d f p; do
56 c=`stat --printf %C s2/$i`; test x$c = x$ctx || fail=1
57 done
59 Exit $fail