Red Hat Bugzilla – Bug 358701
/bin/cp can cause data loss on filesystems that are not SELinux aware
Last modified: 2007-11-30 17:12:20 EST
Description of problem:
On a filesystem such as NFS that doesn't know how to store SELinux metadata,
/bin/cp can create empty target files due to incorrect error handling.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Go to an NFS-mounted directory that has a non-empty file named 'file1'.
2. Run 'cp -av file1 file2'.
3. Run 'cp -av file1 file2' again.
file2 is empty
file2 has same contents as file1
Patch is attached that fixes this particular case. However, I would almost argue
that all errors generated by fsetfilecon() should be ignored (and not just
EOPNOTSUPP), simply because they're not fatal, and because truncating the user's
files to zero-length is a really bad outcome for a basic utility like /bin/cp.
Created attachment 243681 [details]
Patch to fix this problem
That is more workaround than patch. Anyway - I have a fix for that - so this bug
is duplicate of #219900 (patch will hopefully make it into F8 final)
*** This bug has been marked as a duplicate of 219900 ***