Bug 185090

Summary: "install" command terribly slow when no -P option used (selinux related bug)
Product: [Fedora] Fedora Reporter: Tomasz Ostrowski <tometzky+redhat>
Component: coreutilsAssignee: Tim Waugh <twaugh>
Status: CLOSED NOTABUG QA Contact:
Severity: low Docs Contact:
Priority: medium    
Version: 4CC: meyering
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-03-27 18:18:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tomasz Ostrowski 2006-03-10 15:43:49 UTC
Description of problem:
install command is terribly slow when no -P option is used.

Version-Release number of selected component (if applicable):
coreutils-5.2.1-48.1

How reproducible:
Always.

Steps to Reproduce:
1. touch /tmp/example1
2. time install /tmp/example1 /tmp/example2
  
Actual results:
real    0m0.672s
user    0m0.452s
sys     0m0.220s

Expected results:
real    0m0.010s
user    0m0.004s
sys     0m0.004s

Additional info:
This delay is caused by over 1300 cycles of opening, writing and closing of
"/selinux/context", seen by strace:
    open("/selinux/context", O_RDWR|O_LARGEFILE) = 5
    write(5, "system_u:object_r:default_t\0", 28) = 28
    close(5)                                = 0
Why does "install" do this is beyond my understanding.

Comment 1 Tim Waugh 2006-03-27 18:18:27 UTC
When SELinux is enabled, the two choices are:

1. set the context to be the default based on the target location
2. preserve the original file context

Option 1 is the default; -P switches to option 2.

If neither of these is performed, the resulting file context may well be incorrect.