Bug 189967 - cp -Z doesn't set the SE Linux context if a file exists
cp -Z doesn't set the SE Linux context if a file exists
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: coreutils (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-04-26 06:47 EDT by Russell Coker
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version: 5.94-4
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-04-26 06:59:36 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


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

  None (edit)
Description Russell Coker 2006-04-26 06:47:02 EDT
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 06:47:02 EDT
Created attachment 128246 [details]
patch to fix this bug
Comment 2 Tim Waugh 2006-04-26 06:59:36 EDT
Thanks.  Applied in 5.94-4.
Comment 3 Tim Waugh 2006-10-04 09:33:45 EDT
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.