Bug 2125878

Summary: SELinux is preventing sh from 'read' accesses on the file openboxes-run.sh.
Product: [Fedora] Fedora Reporter: Aleksandar Kostadinov <akostadi>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 36CC: dwalsh, grepl.miroslav, lvrabec, mmalik, omosnacek, pkoncity, vmojzis, zpytela
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: abrt_hash:4b755e4742cc2538da566e085baef93b9f116fd3339f138fc6bb67346e948e63;
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-09-12 19:51:36 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 Aleksandar Kostadinov 2022-09-11 13:13:41 UTC
Description of problem:
Issue happened while running docker-compose I believe
SELinux is preventing sh from 'read' accesses on the file openboxes-run.sh.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that sh should be allowed read access on the openboxes-run.sh file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'sh' --raw | audit2allow -M my-sh
# semodule -X 300 -i my-sh.pp

Additional Information:
Source Context                system_u:system_r:container_t:s0:c53,c753
Target Context                unconfined_u:object_r:user_home_t:s0
Target Objects                openboxes-run.sh [ file ]
Source                        sh
Source Path                   sh
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
SELinux Policy RPM            selinux-policy-targeted-36.14-1.fc36.noarch
Local Policy RPM              selinux-policy-targeted-36.14-1.fc36.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 5.19.8-200.fc36.x86_64 #1 SMP
                              PREEMPT_DYNAMIC Thu Sep 8 19:02:21 UTC 2022 x86_64
                              x86_64
Alert Count                   1
First Seen                    2022-09-11 16:11:31 EEST
Last Seen                     2022-09-11 16:11:31 EEST
Local ID                      71c0de21-aec7-4c6c-a02e-0fb31908ecaa

Raw Audit Messages
type=AVC msg=audit(1662901891.916:701): avc:  denied  { read } for  pid=22558 comm="sh" name="openboxes-run.sh" dev="dm-3" ino=24818132 scontext=system_u:system_r:container_t:s0:c53,c753 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0


Hash: sh,container_t,user_home_t,file,read

Version-Release number of selected component:
selinux-policy-targeted-36.14-1.fc36.noarch

Additional info:
component:      selinux-policy
reporter:       libreport-2.17.2
hashmarkername: setroubleshoot
kernel:         5.19.8-200.fc36.x86_64
type:           libreport

Comment 1 Aleksandar Kostadinov 2022-09-11 15:42:53 UTC
I believe there is some selinux relabeling needed when running docker-compose according to https://github.com/openboxes/openboxes-docker

Comment 2 Zdenek Pytela 2022-09-12 08:33:43 UTC
Alexander,

Can you put down some details or reproducer? Container should not be allowed to access data outside.

Comment 3 Daniel Walsh 2022-09-12 19:51:36 UTC
This is not a bug.  It is expected the directory must be labeled for SELinux access.

chcon -t container_file_t -r on the volume being mounted into the container.

Comment 4 Daniel Walsh 2022-09-12 19:52:09 UTC
If the directory is not private to the container then you might need to disable SELinux for the run of the container.

Comment 5 Aleksandar Kostadinov 2022-10-30 18:16:09 UTC
chcon -R worked, thank you!

Just for anybody that reads, the `-r` above is a typo and should be `-R`.