[BusyBox] possible bug report: /bin/cp behavior

Mark mark at solinus.com
Fri Jan 7 18:54:00 UTC 2005


I originally saw this posted around September of 2002, but saw nothing since,
so I figured I'd bring it up again:

/bin/cp, when operated on special files (pipes, sockets, char devices, block
devices), actually create the devices, and not copy from them, as should
happen:

server running busybox:
-----------------------
mark at mflinux:~                                                                  > sudo cp /dev/null foobar
                                                                                mark at mflinux:~                                                                  > ls -al foobar
crw-r--r--    1 root     root       1,   3 Jan  7 05:48 foobar

server running slackware, no busybox:
-------------------------------------
root at sunset:/tmp# cp /dev/null foobar
root at sunset:/tmp# ls -al foobar
-rw-r--r--  1 root root 0 2005-01-07 09:59 foobar

I belive this bug also blends into why /dev/null can't be copied into a file,
to zero it out.  In this instance (/bin/cp /dev/null foobar, which should
create a 0 length foobar file), if foobar doesn't exist, and you are not uid
0, you get this:

mark at mflinux:~
> cp /dev/null foobar
cp: unable to create `foobar': Operation not permitted

mark at mflinux:~
> cp -f /dev/null foobar
cp: unable to create `foobar': Operation not permitted

if foobar DOES exist, you get this:

mark at mflinux:~
> cp /dev/null foobar
cp: unable to remove `foobar': Success

mark at mflinux:~
> cp -f /dev/null foobar
cp: unable to create `foobar': Operation not permitted
(here, foobar is unlinked, but can not be created as a device without uid 0)

Basically, cp behaves incorrectly when the source file is a special device.
I'm not sure if this is a design decision or not, since I saw it reported
before, but I figured I'd bring it up.

-- 
Mark Maurer       
mark at solinus.com  



More information about the busybox mailing list