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 ***