Problem with test -r
Dominique Martinet
asmadeus at codewreck.org
Mon Feb 13 11:14:34 UTC 2023
David Laight wrote on Mon, Feb 13, 2023 at 09:00:47AM +0000:
> From: Vladimír Macek
> > I'd like to report what seems to be a bug in the busybox's test command. I
> > use the official alpine:3 docker container.
> >
> > The test -r does not return true even when the file is indeed readable
> > (testing by head command). Yes, the file has an unusual set of permissions,
> > but that does not restrict it from reading. Here's the output of the
> > interactive container shell session:
> >
> > dd72078df6d2:/task/output/files$ ls -lad . .. cnb_rate_eur_czk.csv
> > drwxrwx--- 2 setup project 4096 Feb 11 18:33 .
> > drwxr-x--- 5 setup project 4096 Feb 11 18:33 ..
> > -rw-r--r-- 1 task project 20512 Feb 11 18:33 cnb_rate_eur_czk.csv
>
> By the look of it the problem is that 'test -r' requires
> directory search access - so why not just say that.
It has x on directory (both as user and group), so what's the problem?
I also cannot reproduce with the same busybox version he reports using
anyway, and busybox' test has not changed from 1.32 to 1.35 so I'd say
"strace or it didn't happen".
Could be a weird side effect of what I assume to be a volume mount for
/task, how the directory was made was not specified.
b4adb3ccf49f:/task/output/files$ id
uid=2001(setup) gid=2000(project) groups=2000(project),2000(project)
b4adb3ccf49f:/task/output/files$ ls -lad . .. cnb_rate_eur_czk.csv
drwxr-xr-x 1 root root 40 Feb 13 11:08 .
drwxrwx--- 1 setup project 10 Feb 13 11:07 ..
-rw-r--r-- 1 task project 4 Feb 13 11:01 cnb_rate_eur_czk.csv
b4adb3ccf49f:/task/output/files$ busybox | head -n 1
BusyBox v1.35.0 (2022-11-19 10:13:10 UTC) multi-call binary.
b4adb3ccf49f:/task/output/files$ [ -r cnb_rate_eur_czk.csv ] && echo READABLE
READABLE
b4adb3ccf49f:/task/output/files$ [[ -r cnb_rate_eur_czk.csv ]] && echo READABLE
READABLE
b4adb3ccf49f:/task/output/files$ /usr/bin/[ -r cnb_rate_eur_czk.csv ] && echo READABLE
READABLE
b4adb3ccf49f:/task/output/files$ cat /etc/alpine-release
3.17.2
--
Dominique
More information about the busybox
mailing list