Problem with test -r

Vladimír Macek (Scripteo) macek at scripteo.cz
Sat Feb 11 19:35:40 UTC 2023


Additional info:

The test -r command started to work again after downgrading to alpine:3.13 
docker image with busybox 1.32:

bash-5.1$ head -1 /task/output/files/cnb_rate_eur_czk.csv  ; [ -r 
/task/output/files/cnb_rate_eur_czk.csv ] && echo READABLE1 ; [[ -r 
/task/output/files/cnb_rate_eur_czk.csv ]] && echo READABLE2
date,rate
READABLE1
READABLE2


Container build log:

Step 1/6 : FROM alpine:3.13
3.13: Pulling from library/alpine
72cfd02ff4d0: Pulling fs layer
72cfd02ff4d0: Verifying Checksum
72cfd02ff4d0: Download complete
72cfd02ff4d0: Pull complete
Digest: sha256:469b6e04ee185740477efa44ed5bdd64a07bbdd6c7e5f5d169e540889597b911
Status: Downloaded newer image for alpine:3.13
  ---> 6b5c5e00213a
Step 2/6 : LABEL maintainer="devs at project.com"
  ---> Running in 33d4d3325a4c
Removing intermediate container 33d4d3325a4c
  ---> cc52a45921d5
Step 3/6 : RUN apk add --no-cache     curl     bash tar     tzdata  && 
addgroup --gid 2000 project && adduser --uid 2001 --home / --no-create-home 
--ingroup project --gecos "project Setup-Teardown" --disabled-password 
setup  && adduser --uid 2002 --home /home/task --ingroup project --gecos 
"project Task" --disabled-password task
  ---> Running in 0aa074d40de9
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch 
https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
(1/12) Installing ncurses-terminfo-base (6.2_p20210109-r1)
(2/12) Installing ncurses-libs (6.2_p20210109-r1)
(3/12) Installing readline (8.1.0-r0)
(4/12) Installing bash (5.1.16-r0)
Executing bash-5.1.16-r0.post-install
(5/12) Installing ca-certificates (20220614-r0)
(6/12) Installing brotli-libs (1.0.9-r3)
(7/12) Installing nghttp2-libs (1.42.0-r1)
(8/12) Installing libcurl (7.79.1-r3)
(9/12) Installing curl (7.79.1-r3)
(10/12) Installing libacl (2.2.53-r0)
(11/12) Installing tar (1.34-r0)
(12/12) Installing tzdata (2022f-r1)
Executing busybox-1.32.1-r9.trigger


Thank you,

Vlada


On 11. 02. 23 20:14, Vladimír Macek (Scripteo) wrote:

> Hi,
>
> 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
>
> dd72078df6d2:/task/output/files$ id
> uid=2001(setup) gid=2000(project) groups=2000(project)
>
> dd72078df6d2:/task/output/files$ head -1 cnb_rate_eur_czk.csv
> date,rate
>
> dd72078df6d2:/task/output/files$ [ -r cnb_rate_eur_czk.csv ] && echo READABLE
> dd72078df6d2:/task/output/files$ [[ -r cnb_rate_eur_czk.csv ]] && echo READABLE
>
> dd72078df6d2:/task/output/files$ which [
> /usr/bin/[
> dd72078df6d2:/task/output/files$ which [[
> /usr/bin/[[
>
> dd72078df6d2:/task/output/files$ ls -la /usr/bin/[*
> lrwxrwxrwx    1 root     root            12 Jan  9 12:46 /usr/bin/[ ->
> /bin/busybox
> lrwxrwxrwx    1 root     root            12 Jan  9 12:46 /usr/bin/[[ ->
> /bin/busybox
>
> dd72078df6d2:/task/output/files$ /bin/busybox
> BusyBox v1.35.0 (2022-11-19 10:13:10 UTC) multi-call binary.
> BusyBox is copyrighted by many authors between 1998-2015.
> Licensed under GPLv2. See source distribution for detailed
> copyright notices.
> ...
>
> Here's how the container was built:
>
> Sending build context to Docker daemon   25.6kB
> Step 1/6 : FROM alpine:3
> 3: Pulling from library/alpine
> 8921db27df28: Pulling fs layer
> 8921db27df28: Download complete
> 8921db27df28: Pull complete
> Digest: sha256:f271e74b17ced29b915d351685fd4644785c6d1559dd1f2d4189a5e851ef753a
> Status: Downloaded newer image for alpine:3
>    ---> 042a816809aa
> Step 2/6 : LABEL maintainer="devs at project.com"
>    ---> Running in cbe6d0033ff3
> Removing intermediate container cbe6d0033ff3
>    ---> cfdded5747d9
> Step 3/6 : RUN apk add --no-cache   curl    bash tar     tzdata  &&
> addgroup --gid 2000 project && adduser --uid 2001 --home / --no-create-home
> --ingroup project --gecos "project Setup-Teardown" --disabled-password
> setup  && adduser --uid 2002 --home /home/task --ingroup project --gecos
> "project Task" --disabled-password task
>    ---> Running in 4b16dff318b9
> fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz
> fetch
> https://dl-cdn.alpinelinux.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz
> (1/12) Installing ncurses-terminfo-base (6.3_p20221119-r0)
> (2/12) Installing ncurses-libs (6.3_p20221119-r0)
> (3/12) Installing readline (8.2.0-r0)
> (4/12) Installing bash (5.2.15-r0)
> Executing bash-5.2.15-r0.post-install
> (5/12) Installing ca-certificates (20220614-r4)
> (6/12) Installing brotli-libs (1.0.9-r9)
> (7/12) Installing nghttp2-libs (1.51.0-r0)
> (8/12) Installing libcurl (7.87.0-r1)
> (9/12) Installing curl (7.87.0-r1)
> (10/12) Installing libacl (2.3.1-r1)
> (11/12) Installing tar (1.34-r1)
> (12/12) Installing tzdata (2022f-r1)
> Executing busybox-1.35.0-r29.trigger
> ...
>
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list