Bug 3175 - 'cp' does not play well with device files with ENABLE_FEATURE_NON_POSIX_CP is selected.
Summary: 'cp' does not play well with device files with ENABLE_FEATURE_NON_POSIX_CP is...
Status: RESOLVED WONTFIX
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.18.x
Hardware: PC Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-31 19:44 UTC by Caglar Akyuz
Modified: 2011-02-02 00:04 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Caglar Akyuz 2011-01-31 19:44:05 UTC
Issuing following command replaces my device file:

$cp /dev/zero /dev/fb0

Here /dev/fb0 is a device file and I want to clear framebuffer memory, however cp tries to open device file with O_WRONLY|O_CREAT|O_EXCL and fails to open device file. Then it unlinks device file and creates a new file on my file-system. I don't know if this is intentional or not but, IMHO, this behavior is not expected.
Comment 1 Denys Vlasenko 2011-02-02 00:04:50 UTC
That's not surprising, since you use "copy file(s)" command to perform something quite different from copying of files.


Help text for this option says:

config FEATURE_NON_POSIX_CP
        bool "Non-POSIX, but safer, copying to special nodes"
        default y
        help
          With this option, "cp file symlink" will delete symlink
          and create a regular file. This does not conform to POSIX,
          but prevents a symlink attack.
          Similarly, "cp file device" will not send file's data
          to the device. (To do that, use "cat file >device")


Thus, either disable FEATURE_NON_POSIX_CP and recompile your busybox, or use

cat /dev/zero >/dev/fb0

instead of cp.