cp overwrites symlinks

Denys Vlasenko vda.linux at googlemail.com
Thu Jan 31 10:36:40 UTC 2013


On Thu, Jan 31, 2013 at 10:10 AM,  <wbeinhart at gmx-topmail.de> wrote:
> Hi all,
>
> I just found that cp behaves differently compared to native cp if the dst file is a symlink.
> In that case the symlink is replaced by by the src file.
> Is this intended behaviour?

"""
Non-POSIX, but safer, copying to special nodes (FEATURE_NON_POSIX_CP)
[Y/n/?] (NEW) ?

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")
"""

If you don't want this, set FEATURE_NON_POSIX_CP to "no"

-- 
vda


More information about the busybox mailing list