On Wed, Jun 2, 2010 at 11:56 AM, Richard Purdie <[email protected]> wrote:
> Hi,
>
> I have an issue having recently upgraded busybox.

To which version do you upgrade?

> 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?

This would be the bug, but I can't reproduce it. Test script:



echo Hi there >b.tmp

exec 9>&0 <b.tmp
while read a b
do
       echo "$a $b"
done
exec 0>&9 9>&-

if test "$sourced"; then
    echo Returning from sourced file
    return
fi
sourced=1
echo Sourcing
. "$0"
echo Sourcing done

ls -l /proc/$$/fd



Running it:

# ./busybox ash b
Hi there
Sourcing
Hi there
Returning from sourced file
Sourcing done
total 0
lrwx------ 1 root root 64 2010-06-02 17:49 0 -> /dev/pts/0
lrwx------ 1 root root 64 2010-06-02 17:49 1 -> /dev/pts/0
lr-x------ 1 root root 64 2010-06-02 17:49 10 ->
/root/srcdevel/bbox/fix/busybox.t7/b
lrwx------ 1 root root 64 2010-06-02 17:49 2 -> /dev/pts/0


-- 
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to