Bug 715557 - cp -Z , security context of file is NOT changed
Summary: cp -Z , security context of file is NOT changed
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: coreutils
Version: 6.1
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Ondrej Vasik
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-06-23 10:29 UTC by Petr Sklenar
Modified: 2018-12-04 11:47 UTC (History)
5 users (show)

Fixed In Version: coreutils-8.4-14.el6
Doc Type: Bug Fix
Doc Text:
When using the "-Z/--context" option in the cp utility, the SELinux context of a file was not changed if the file destination already existed. The utility has been modified and the context is changed as expected. However, this option is not portable to other systems.
Clone Of:
Environment:
Last Closed: 2011-12-06 17:12:41 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1693 0 normal SHIPPED_LIVE coreutils bug fix update 2011-12-06 00:49:52 UTC

Description Petr Sklenar 2011-06-23 10:29:49 UTC
Description of problem:
cp -Z , security context of file is NOT changed

Version-Release number of selected component (if applicable):
coreutils-8.4-13.el6.ppc64
it could see the same on rhel5u7

How reproducible:
deterministic

Steps to Reproduce:
# ORIG_CONTEXT=root:object_r:file_t
# NEW_CONTEXT=root:object_r:tmp_t

# rm -f file-a file-b
# touch file-a
# ls -Z file-a 
-rw-r--r--. root root unconfined_u:object_r:tmp_t:s0   file-a
# cp -Z $ORIG_CONTEXT file-a file-b
# ls -Z file-b
-rw-r--r--. root root root:object_r:file_t             file-b
# cp -Z $NEW_CONTEXT file-a file-b
cp: overwrite `file-b'? y
# ls -Z file-b
-rw-r--r--. root root root:object_r:file_t             file-b
  
Actual results:
context of file-b is NOT changed

Expected results:
context is file-b is changed

Additional info:
man page says
-Z, --context=CONTEXT
              set security context of copy to CONTEXT

Comment 2 Kamil Dudka 2011-06-30 10:23:52 UTC
I am observing the same behavior on F-14 coreutils.  The problem is that cp -Z uses setfscreatecon(), which affects only newly created files.  As a workaround you can use cp --remove-destination -Z ...

Comment 3 RHEL Program Management 2011-07-05 23:56:52 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.

Comment 8 Eliska Slobodova 2011-09-19 14:22:10 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
When using the "-Z/--context" option in the cp utility, the SELinux context of a file was not changed if the file destination already existed. The utility has been modified and the context is changed as expected. However, this option is not portable to other systems.

Comment 9 errata-xmlrpc 2011-12-06 17:12:41 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1693.html


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