Red Hat Bugzilla – Bug 189967
cp -Z doesn't set the SE Linux context if a file exists
Last modified: 2007-11-30 17:11:31 EST
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
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.
Created attachment 128246 [details]
patch to fix this bug
Thanks. Applied in 5.94-4.
This got broken again in rawhide. Fixed in 5.97-12.