Bug 189967 - cp -Z doesn't set the SE Linux context if a file exists
Summary: cp -Z doesn't set the SE Linux context if a file exists
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: coreutils
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-04-26 10:47 UTC by Russell Coker
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version: 5.94-4
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-04-26 10:59:36 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
patch to fix this bug (765 bytes, patch)
2006-04-26 10:47 UTC, Russell Coker
no flags Details | Diff

Description Russell Coker 2006-04-26 10:47:02 UTC
Description of problem:

The command "cp -Z root:object_r:tmp_t file-a file-b" does not set the context 
of file-b if it already exists.  If the file does not exist then it operates 
correctly.

This is because the "-Z" option of cp sets the default context for new files 
that are created.  If a file exists then cp does not unlink and recreate it, 
but instead just truncates it.

One potential solution would be to unlink and recreate the file.  My solution 
has been to apply the create context when truncating the file (patch 
attached).  If you don't like my patch then let me know what you would like 
and I'll re-write it.

Comment 1 Russell Coker 2006-04-26 10:47:02 UTC
Created attachment 128246 [details]
patch to fix this bug

Comment 2 Tim Waugh 2006-04-26 10:59:36 UTC
Thanks.  Applied in 5.94-4.

Comment 3 Tim Waugh 2006-10-04 13:33:45 UTC
This got broken again in rawhide.  Fixed in 5.97-12.


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