Problem with ash redirection changing behaviour

Richard Purdie rpurdie at rpsys.net
Wed Jun 2 09:56:43 UTC 2010


Hi,

I have an issue having recently upgraded busybox. The change that is
causing me problems is:

http://git.busybox.net/busybox/commit/?id=6a0ad2506116f4ddc3f9f617a90ba04a57eeef88

which is sanity checking file descriptors before allowing redirection.

A script that triggers the problem is:

"""
exec 9>&0 </etc/fstab
while read fs mnt type opts dump pass junk
do
	echo $fs
done
exec 0>&9 9>&-
"""

The idea being to save stdin, read from a file and then restore stdin
without forking. This used to work but now when run as ". script" from
ash this results in:

line 1: 0: Bad file descriptor

which is in turn due to is_hidden_fd() returning 1 since stdin was being
read as the source for commands.

I can see what its getting at as stdin was where the main shell was
accepting data from. bash doesn't error with this.

Is this error the expected result or a bug in busybox?

I can see some argument for saving copies of fd's when using
pushfile()/popfile() but I thought I'd ask the question.

Cheers,

Richard






More information about the busybox mailing list