Bug 607 - "test -r" does not work properly with pipe files
Summary: "test -r" does not work properly with pipe files
Status: RESOLVED INVALID
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.13.x
Hardware: PC Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-11 10:33 UTC by Oriol
Modified: 2009-09-16 08:57 UTC (History)
1 user (show)

See Also:
Host: VirtualBox
Target:
Build:


Attachments
Busybox "test" command playground (21.59 KB, image/png)
2009-09-12 16:29 UTC, Oriol
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oriol 2009-09-11 10:33:54 UTC
When executing "test -r" or "test -w" with a pipe file with or without read/write permission the returned value is always the same. However, it works with standard files (haven't tried with sockets).
Comment 1 Denys Vlasenko 2009-09-12 13:54:57 UTC
Can you give an example, what exactly do you see, and what do you expect to see?

mkfifo abc
chmod ... abc
busybox test -r abc; echo $?
/path/to/coreutils/test -r abc; echo $?
bash -c 'test -r abc; echo $?'
Comment 2 Oriol 2009-09-12 16:29:39 UTC
Created attachment 649 [details]
Busybox "test" command playground

In the screenshot there are some examples about the tests I performed in my VirtualBox host with busybox 1.13.4.

In the top part of the image, there is a directory listing with the actual contents, and next the tests performed with the command "test" and the unexpected results. 

However, it's possible I didn't understood totally the directory permission policies shown, since the following command didn't produce any error:

(notice that di01.info has -r--r--r-- root root permission)

# echo TEST2 > di01.info ; cat di01.info
TEST2
Comment 3 Denys Vlasenko 2009-09-12 20:06:57 UTC
You see it because you run as root.

I see the same with both busybox and with bash:

# mkfifo busybox_TST
# chmod a=r busybox_TST
# bash -c 'test -r busybox_TST; echo $?'
0
# bash -c 'test -w busybox_TST; echo $?'
0
# bash -c './busybox test -r busybox_TST; echo $?'
0
# bash -c './busybox test -w busybox_TST; echo $?'
0

But under non-root, test -w returns "false":

# bash -c 'setuidgid 1:1 ./busybox test -r busybox_TST; echo $?'
0
# bash -c 'setuidgid 1:1 ./busybox test -w busybox_TST; echo $?'
1
# setuidgid 1:1 bash -c 'test -r busybox_TST; echo $?'
0
# setuidgid 1:1 bash -c 'test -w busybox_TST; echo $?'
1

Again, we are bash-compatible here. Looks like it is not a bug.
Comment 4 Oriol 2009-09-16 08:57:24 UTC
True, "test" works fine if is not executed as "root". I'll change the status to "invalid".