2 # Ensure "ls --color" properly colorizes file with capability.
4 # Copyright (C) 2008-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
23 grep '^#define HAVE_CAP 1' $CONFIG_HEADER > /dev
/null \
24 || skip_
"configured without libcap support"
26 (setcap
--help) 2>&1 |
grep 'usage: setcap' > /dev
/null \
27 || skip_
"setcap utility not found"
29 # Don't let a different umask perturb the results.
32 # We create 2 files of the same name as
33 # before coreutils 8.1 only the name rather than
34 # the full path was used to read the capabilities
35 # thus giving false positives and negatives.
38 touch cap_pos dir
/cap_pos dir
/cap_neg
39 for file in cap_pos dir
/cap_neg
; do
40 setcap
'cap_net_bind_service=ep' $file ||
41 skip_
"setcap doesn't work"
45 # Note we explicitly disable "executable" coloring
46 # so that capability coloring is not dependent on it,
47 # as was the case before coreutils 8.1
49 LS_COLORS
="di=:${ex}ca=$code" \
50 ls --color=always cap_pos dir
> out || fail
=1
53 \e[0m\e[${code}mcap_pos\e[0m
56 \e[${code}mcap_neg\e[0m
58 " > out_ok || framework_failure_
60 compare out out_ok || fail
=1