[BusyBox 0006144]: cp clobbers symlink with actual file (mismatch with coreutils)

bugs at busybox.net bugs at busybox.net
Tue Nov 11 19:22:05 UTC 2008


The following issue has been SUBMITTED. 
====================================================================== 
http://busybox.net/bugs/view.php?id=6144 
====================================================================== 
Reported By:                pgbovine
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   6144
Category:                   Standards Compliance
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             11-11-2008 11:22 PST
Last Modified:              11-11-2008 11:22 PST
====================================================================== 
Summary:                    cp clobbers symlink with actual file (mismatch with
coreutils)
Description: 
If A is a symlink to file B, then calling 'busybox cp A A' will actually
copy the contents of B into A and make it into a regular file, whereas
coreutils cp will simply exit with an error.  I've reproduced this in the
latest svn head as of today.

Setup:

$ echo 'hello' > B
$ ln -s B A
$ ls -l A B
lrwxrwxrwx 1 pgbovine users 1 2008-11-11 11:31 A -> B
-rw-r--r-- 1 pgbovine users 6 2008-11-11 11:30 B


Coreutils behavior:

$ cp A A
cp: `A' and `A' are the same file
$ echo $?
1

($? is to get exit code, which is 1 here, signaling error)

$ ls -l A B
lrwxrwxrwx 1 pgbovine users 1 2008-11-11 11:32 A -> B
-rw-r--r-- 1 pgbovine users 6 2008-11-11 11:32 B

(no change in A or B)


Busybox behavior:

$ ./busybox cp A A
$ echo $?
0
pgbovine at hexapod ~/busybox
$ ls -l A B
-rw-r--r-- 1 pgbovine users 6 2008-11-11 11:33 A
-rw-r--r-- 1 pgbovine users 6 2008-11-11 11:33 B
$ stat A B
  File: `A'
  Size: 6               Blocks: 8          IO Block: 4096   regular file
Device: 802h/2050d      Inode: 1279976     Links: 1
Access: (0644/-rw-r--r--)  Uid: (  501/pgbovine)   Gid: (  100/   users)
Access: 2008-11-11 11:33:24.000000000 -0800
Modify: 2008-11-11 11:33:24.000000000 -0800
Change: 2008-11-11 11:33:24.000000000 -0800
  File: `B'
  Size: 6               Blocks: 8          IO Block: 4096   regular file
Device: 802h/2050d      Inode: 1279975     Links: 1
Access: (0644/-rw-r--r--)  Uid: (  501/pgbovine)   Gid: (  100/   users)
Access: 2008-11-11 11:33:24.000000000 -0800
Modify: 2008-11-11 11:33:16.000000000 -0800
Change: 2008-11-11 11:33:16.000000000 -0800

(exit code is 0, signifying success, and now A is a REGULAR FILE with the
same contents as B)
====================================================================== 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
11-11-08 11:22  pgbovine       New Issue                                    
11-11-08 11:22  pgbovine       Status                   new => assigned     
11-11-08 11:22  pgbovine       Assigned To               => BusyBox         
======================================================================




More information about the busybox-cvs mailing list