Bug 358701 - /bin/cp can cause data loss on filesystems that are not SELinux aware
Summary: /bin/cp can cause data loss on filesystems that are not SELinux aware
Keywords:
Status: CLOSED DUPLICATE of bug 219900
Alias: None
Product: Fedora
Classification: Fedora
Component: coreutils
Version: rawhide
Hardware: All
OS: Linux
low
urgent
Target Milestone: ---
Assignee: Ondrej Vasik
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-10-30 17:48 UTC by Elliot Lee
Modified: 2007-11-30 22:12 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-10-30 18:05:59 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Patch to fix this problem (457 bytes, text/x-patch)
2007-10-30 17:48 UTC, Elliot Lee
no flags Details

Description Elliot Lee 2007-10-30 17:48:11 UTC
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):
coreutils-6.9-6.fc8

How reproducible:
100%

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.
  
Actual results:
file2 is empty

Expected results:
file2 has same contents as file1

Additional info:

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.

Comment 1 Elliot Lee 2007-10-30 17:48:12 UTC
Created attachment 243681 [details]
Patch to fix this problem

Comment 2 Ondrej Vasik 2007-10-30 18:05:59 UTC
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 ***


Note You need to log in before you can comment on or make changes to this bug.