Bug 826528

Summary: Selinux denies cobbler to write tftp config
Product: Red Hat Enterprise Linux 6 Reporter: Pablo Iranzo Gómez <pablo.iranzo>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3CC: dwalsh, mmalik
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-10-15 15:03:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pablo Iranzo Gómez 2012-05-30 12:32:15 UTC
Description of problem:
SELinux denies cobbler writting tftp

Version-Release number of selected component (if applicable):
[root@Merak ~]# rpm -q cobbler
cobbler-2.2.2-1.el6.noarch
[root@Merak ~]# rpm -q selinux-policy
selinux-policy-3.7.19-145.el6.noarch
[root@Merak ~]# rpm -qa|grep -i target
selinux-policy-targeted-3.7.19-145.el6.noarch

How reproducible:
Execute cobbler sync

Steps to Reproduce:
1. cobbler sync
2.
3.
  
Actual results:
AUDIT.LOG:
type=AVC msg=audit(1338380856.563:62132): avc:  denied  { write } for  pid=3098 comm="cobblerd" name="tftp" dev=dm-0 ino=10881600 scontext=system_u:system_r:cobblerd_t:s0 tcontext=system_u:object_r:etc_t:s0 tclass=file
type=SYSCALL msg=audit(1338380856.563:62132): arch=c000003e syscall=2 success=no exit=-13 a0=7fd2280f2d30 a1=242 a2=1b6 a3=0 items=0 ppid=1 pid=3098 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="cobblerd" exe="/usr/bin/python" subj=system_u:system_r:cobblerd_t:s0 key=(null)

COBBLER ON CONSOLE:
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
Exception occured: <type 'exceptions.IOError'>
Exception value: [Errno 13] Permission denied: '/etc/xinetd.d/tftp'
Exception Info:
  File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 89, in run
    rc = self._run(self)
   File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 184, in runner
    return self.remote.api.sync(self.options.get("verbose",False),logger=self.logger)
   File "/usr/lib/python2.6/site-packages/cobbler/api.py", line 701, in sync
    return sync.run()
   File "/usr/lib/python2.6/site-packages/cobbler/action_sync.py", line 142, in run
    self.tftpd.write_tftpd_files()
   File "/usr/lib/python2.6/site-packages/cobbler/modules/manage_in_tftpd.py", line 131, in write_tftpd_files
    self.templar.render(template_data, metadata, self.settings_file, None)
   File "/usr/lib/python2.6/site-packages/cobbler/templar.py", line 167, in render
    fd = open(out_path, "w+")

!!! TASK FAILED !!!

Expected results:
cobbler should be able to generate that configuration file and output something similar to:
Iniciando dhcpd: [  OK  ]

received on stderr: 
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***


Additional info:

Comment 2 Miroslav Grepl 2012-05-30 13:37:14 UTC
This is a problem with the latest cobbler. We should need

/etc/xinetd\.d/tftp --  gen_context(system_u:object_r:tftpd_etc_t,s0

in the policy. But we can say to create this file with this label only on Fedora16+.

We have another transition for /etc in the cobbler policy on RHEL6.3. So we would get duplicate transitions.

I think we could add labeling and cobbler sync could run restorecon when /etc/xinetd\.d/tftp is created. I hope the cobbler sync runs as unconfined in this phase.

Comment 4 RHEL Program Management 2012-07-10 08:19:14 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 5 RHEL Program Management 2012-07-11 01:56:29 UTC
This request was erroneously removed from consideration in Red Hat Enterprise Linux 6.4, which is currently under development.  This request will be evaluated for inclusion in Red Hat Enterprise Linux 6.4.

Comment 6 Miroslav Grepl 2012-10-15 15:03:38 UTC

*** This bug has been marked as a duplicate of bug 816309 ***