Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bfs coloring all files as if they had a capability, on non-Linux systems #146

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ static const struct bfs_stat *cpath_stat(const struct cpath *cpath) {
/** Check if a path has non-trivial capabilities. */
static bool cpath_has_capabilities(const struct cpath *cpath) {
if (cpath->valid == cpath->len) {
return bfs_check_capabilities(cpath->ftwbuf);
return bfs_check_capabilities(cpath->ftwbuf) > 0;
} else {
// TODO: implement capability checks for arbitrary paths
return false;
Expand Down
4 changes: 4 additions & 0 deletions tests/bfs/color_ca.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.
./link
./capable
./normal
10 changes: 10 additions & 0 deletions tests/bfs/color_ca.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test "$UNAME" = "Linux" || skip
invoke_bfs . -quit -capable || skip

cd "$TEST"

"$XTOUCH" normal capable
bfs_sudo setcap all+ep capable || skip
ln -s capable link

LS_COLORS="ca=30;41:" bfs_diff . -color
27 changes: 27 additions & 0 deletions tests/bfs/color_ca_incapable.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
$'rainbow/\e[1m'
$'rainbow/\e[1m/'$'\e[0m'
rainbow
rainbow/exec.sh
rainbow/socket
rainbow/broken
rainbow/chardev_link
rainbow/link.txt
rainbow/sticky_ow
rainbow/sgid
rainbow/pipe
rainbow/ow
rainbow/sugid
rainbow/suid
rainbow/sticky
rainbow/file.dat
rainbow/file.txt
rainbow/lower.gz
rainbow/lower.tar
rainbow/lower.tar.gz
rainbow/lu.tar.GZ
rainbow/mh1
rainbow/mh2
rainbow/ul.TAR.gz
rainbow/upper.GZ
rainbow/upper.TAR
rainbow/upper.TAR.GZ
1 change: 1 addition & 0 deletions tests/bfs/color_ca_incapable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LS_COLORS="ca=30;41:" bfs_diff rainbow -color
Loading