ls: use '.' (not +) as SELinux-only alt. access flag in ls -l output
[coreutils/bo.git] / tests / misc / selinux
blob8211c80f7179c3d675744903e3c0b73695f19af5
1 #!/bin/sh
2 # Test SELinux-related options.
4 if test "$VERBOSE" = yes; then
5 set -x
6 chcon --version
7 cp --version
8 ls --version
9 mv --version
10 stat --version
13 . $srcdir/test-lib.sh
14 require_root_
15 require_selinux_
16 skip_if_mcstransd_is_running_
18 # Create a regular file, dir, fifo.
19 touch f || framework_failure
20 mkdir d s1 s2 || framework_failure
21 mkfifo p || framework_failure
23 fail=0
25 # special context that works both with and without mcstransd
26 ctx=root:object_r:tmp_t:s0
28 chcon $ctx f d p ||
29 skip_test_ '"chcon '$ctx' ..." failed'
31 # inspect that context with both ls -Z and stat.
32 for i in d f p; do
33 c=`ls -dogZ $i|cut -d' ' -f3`; test x$c = x$ctx || fail=1
34 c=`stat --printf %C $i`; test x$c = x$ctx || fail=1
35 done
37 # ensure that ls -l output includes the ".".
38 c=`ls -l f|cut -c11`; test "$c" = . || fail=1
40 # Copy each to a new directory and ensure that context is preserved.
41 cp -r --preserve=all d f p s1 || fail=1
42 for i in d f p; do
43 c=`stat --printf %C s1/$i`; test x$c = x$ctx || fail=1
44 done
46 # Now, move each to a new directory and ensure that context is preserved.
47 mv d f p s2 || fail=1
48 for i in d f p; do
49 c=`stat --printf %C s2/$i`; test x$c = x$ctx || fail=1
50 done
52 Exit $fail