Bug 723443

Summary: SELinux is preventing /bin/bash from 'read' accesses on the fichier /root/.bash_history.
Product: [Fedora] Fedora Reporter: Sylvain Arth <sylvain>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: dominick.grift, dwalsh, mgrepl
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard: setroubleshoot_trace_hash:d7b7a1710fd64832013113f3aa1d960e7390603cf07cda2933da8e6efd4a0bbd
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-20 11:58:06 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Sylvain Arth 2011-07-20 07:26:46 UTC
SELinux is preventing /bin/bash from 'read' accesses on the fichier /root/.bash_history.

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

If you believe that bash should be allowed read access on the .bash_history 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:
# grep bash /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                root:staff_r:staff_t:s0
Target Context                system_u:object_r:admin_home_t:s0
Target Objects                /root/.bash_history [ file ]
Source                        bash
Source Path                   /bin/bash
Port                          <Inconnu>
Host                          (removed)
Source RPM Packages           bash-4.2.10-4.fc15
Target RPM Packages           
Policy RPM                    selinux-policy-3.9.16-34.fc15
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Permissive
Host Name                     (removed)
Platform                      Linux (removed) 2.6.38.8-32.fc15.i686 #1
                              SMP Mon Jun 13 20:01:50 UTC 2011 i686 i686
Alert Count                   1
First Seen                    mer. 20 juil. 2011 09:15:36 CEST
Last Seen                     mer. 20 juil. 2011 09:15:36 CEST
Local ID                      f201ec49-89e5-4659-8adf-f866c608f977

Raw Audit Messages
type=AVC msg=audit(1311146136.945:189): avc:  denied  { read } for  pid=3261 comm="bash" name=".bash_history" dev=dm-0 ino=1573146 scontext=root:staff_r:staff_t:s0 tcontext=system_u:object_r:admin_home_t:s0 tclass=file


type=AVC msg=audit(1311146136.945:189): avc:  denied  { open } for  pid=3261 comm="bash" name=".bash_history" dev=dm-0 ino=1573146 scontext=root:staff_r:staff_t:s0 tcontext=system_u:object_r:admin_home_t:s0 tclass=file


type=SYSCALL msg=audit(1311146136.945:189): arch=i386 syscall=open success=yes exit=ESRCH a0=81da7a8 a1=8000 a2=0 a3=3e8 items=0 ppid=3251 pid=3261 auid=500 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts1 ses=1 comm=bash exe=/bin/bash subj=root:staff_r:staff_t:s0 key=(null)

Hash: bash,staff_t,admin_home_t,file,read

audit2allow

#============= staff_t ==============
allow staff_t admin_home_t:file { read open };

audit2allow -R

#============= staff_t ==============
allow staff_t admin_home_t:file { read open };

Comment 1 Miroslav Grepl 2011-07-20 11:58:06 UTC
You are not able switch to root user as staff SELinux user in enforcing mode. 

You can setup sudo for example

mgrepl ALL=(ALL) TYPE=unconfined_t ROLE=unconfined_r /bin/sh

which will cause if you run

# sudo sh

as staff_u:staff_r:staff_t

You will end up as unconfined_t.

Or

mgrepl ALL=(ALL) ROLE=sysadm_r TYPE=sysadm_t ALL
mgrepl ALL=(ALL) TYPE=unconfined_t ROLE=unconfined_r /bin/sh