Skip to content

Commit e831a39

Browse files
authored
Merge pull request #146 from jody-frankowski/fix/capa-color-non-linux
Fix bfs coloring all files as if they had a capability, on non-Linux systems
2 parents 515cda3 + 7152645 commit e831a39

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

src/color.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ static const struct bfs_stat *cpath_stat(const struct cpath *cpath) {
939939
/** Check if a path has non-trivial capabilities. */
940940
static bool cpath_has_capabilities(const struct cpath *cpath) {
941941
if (cpath->valid == cpath->len) {
942-
return bfs_check_capabilities(cpath->ftwbuf);
942+
return bfs_check_capabilities(cpath->ftwbuf) > 0;
943943
} else {
944944
// TODO: implement capability checks for arbitrary paths
945945
return false;

tests/bfs/color_ca.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.
2+
./link
3+
./capable
4+
./normal

tests/bfs/color_ca.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
test "$UNAME" = "Linux" || skip
2+
invoke_bfs . -quit -capable || skip
3+
4+
cd "$TEST"
5+
6+
"$XTOUCH" normal capable
7+
bfs_sudo setcap all+ep capable || skip
8+
ln -s capable link
9+
10+
LS_COLORS="ca=30;41:" bfs_diff . -color

tests/bfs/color_ca_incapable.out

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$'rainbow/\e[1m'
2+
$'rainbow/\e[1m/'$'\e[0m'
3+
rainbow
4+
rainbow/exec.sh
5+
rainbow/socket
6+
rainbow/broken
7+
rainbow/chardev_link
8+
rainbow/link.txt
9+
rainbow/sticky_ow
10+
rainbow/sgid
11+
rainbow/pipe
12+
rainbow/ow
13+
rainbow/sugid
14+
rainbow/suid
15+
rainbow/sticky
16+
rainbow/file.dat
17+
rainbow/file.txt
18+
rainbow/lower.gz
19+
rainbow/lower.tar
20+
rainbow/lower.tar.gz
21+
rainbow/lu.tar.GZ
22+
rainbow/mh1
23+
rainbow/mh2
24+
rainbow/ul.TAR.gz
25+
rainbow/upper.GZ
26+
rainbow/upper.TAR
27+
rainbow/upper.TAR.GZ

tests/bfs/color_ca_incapable.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LS_COLORS="ca=30;41:" bfs_diff rainbow -color

0 commit comments

Comments
 (0)