Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1100375

Summary: cp -Z does not copy a file when SELinux context is supplied
Product: Red Hat Enterprise Linux 7 Reporter: Milos Malik <mmalik>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED DUPLICATE QA Contact: qe-baseos-daemons
Severity: high Docs Contact:
Priority: high    
Version: 7.0   
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-05-23 04:54:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Milos Malik 2014-05-22 16:53:51 UTC
Description of problem:
 * cp does not work as described in its man page - the destination file is not created at all !

       -Z, --context[=CTX]
              set  SELinux  security  context  of  destination file to default
              type, or to CTX if specified

Version-Release number of selected component (if applicable):
coreutils-debuginfo-8.22-11.el7.x86_64
coreutils-8.22-11.el7.x86_64

How reproducible:
always

Steps to Reproduce:
# rm -f empty-file another-empty-file
# touch empty-file
# ls -Z *empty-file 
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 empty-file
# cp -Z unconfined_u:object_r:etc_t:s0 empty-file another-empty-file
cp: target ‘another-empty-file’ is not a directory
# echo $?
1
# ls -Z *empty-file 
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 empty-file
# 

Actual results:
 * the file is not copied

Expected results:
 * the file is copied

Comment 1 Ondrej Vasik 2014-05-23 04:54:47 UTC
This is not a bug - and duplicate of #1084471... this is documented behaviour change - in RHEL6, -Z <something> was used for setting context. In RHEL 7, long option --context has to be used for setting context, and -Z just restores the context of the file. Closing duplicate, as I plan to improve the docs with http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=30acfcab as #1084471 bugfix.

*** This bug has been marked as a duplicate of bug 1084471 ***