Bug 736841

Summary: SELinux is preventing /bin/bash from 'write' accesses on the file /etc/resolv.conf.
Product: [Fedora] Fedora Reporter: Mircea Sava <msava>
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:98a614dd71d7b97498ce013fc7515514e1fbabd8a468f74d0106c1b8d425e31e
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-09-09 07:57:59 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 Mircea Sava 2011-09-08 20:20:44 UTC
SELinux is preventing /bin/bash from 'write' accesses on the file /etc/resolv.conf.

*****  Plugin restorecon (99.5 confidence) suggests  *************************

If you want to fix the label. 
/etc/resolv.conf default label should be net_conf_t.
Then you can run restorecon.
Do
# /sbin/restorecon -v /etc/resolv.conf

*****  Plugin catchall (1.49 confidence) suggests  ***************************

If you believe that bash should be allowed write access on the resolv.conf 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 dhclient-script /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                unconfined_u:system_r:dhcpc_t:s0-s0:c0.c1023
Target Context                unconfined_u:object_r:etc_runtime_t:s0
Target Objects                /etc/resolv.conf [ file ]
Source                        dhclient-script
Source Path                   /bin/bash
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           bash-4.2.10-4.fc15
Target RPM Packages           
Policy RPM                    selinux-policy-3.9.16-38.fc15
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 2.6.40.4-5.fc15.i686
                              #1 SMP Tue Aug 30 14:54:41 UTC 2011 i686 i686
Alert Count                   2
First Seen                    Thu 08 Sep 2011 10:21:16 PM EEST
Last Seen                     Thu 08 Sep 2011 10:21:16 PM EEST
Local ID                      29ec74d0-d379-4474-a234-bbeb52024302

Raw Audit Messages
type=AVC msg=audit(1315509676.219:92): avc:  denied  { write } for  pid=3007 comm="dhclient-script" name="resolv.conf" dev=dm-1 ino=13956 scontext=unconfined_u:system_r:dhcpc_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:etc_runtime_t:s0 tclass=file


type=SYSCALL msg=audit(1315509676.219:92): arch=i386 syscall=open success=no exit=EACCES a0=9c6b888 a1=8201 a2=0 a3=0 items=0 ppid=2928 pid=3007 auid=528 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=1 comm=dhclient-script exe=/bin/bash subj=unconfined_u:system_r:dhcpc_t:s0-s0:c0.c1023 key=(null)

Hash: dhclient-script,dhcpc_t,etc_runtime_t,file,write

audit2allow

#============= dhcpc_t ==============
allow dhcpc_t etc_runtime_t:file write;

audit2allow -R

#============= dhcpc_t ==============
allow dhcpc_t etc_runtime_t:file write;

Comment 1 Miroslav Grepl 2011-09-09 07:57:59 UTC
resolv.conf is mislabeled.

# /sbin/restorecon -v /etc/resolv.conf

will fix. 

Could you reopen the bug if this happens again.

Comment 2 Daniel Walsh 2011-09-09 12:19:42 UTC
Somewhere in your init scripts or a script launched out of dbus it is creating a resolv.conf with the wrong label.  Are you using a tool like ppp?