Bug 805742 - SELINUX_ERR when using config tools to install packages
Summary: SELINUX_ERR when using config tools to install packages
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: selinux-policy
Version: 6.2
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Miroslav Grepl
QA Contact: Michal Trunecka
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-03-22 01:07 UTC by Gordon Messmer
Modified: 2014-09-30 23:33 UTC (History)
7 users (show)

Fixed In Version: selinux-policy-3.7.19-146.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-20 12:32:26 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2012:0780 0 normal SHIPPED_LIVE selinux-policy bug fix and enhancement update 2012-06-19 20:34:59 UTC

Description Gordon Messmer 2012-03-22 01:07:06 UTC
Description of problem:
When bcfg2 is used to install RPM packages (using the yum python modules), errors are logged if the package scripts add users or groups:

type=SELINUX_ERR msg=audit(1332377695.924:15802): security_compute_sid:  invalid context unconfined_u:unconfined_r:useradd_t:s0-s0:c0.c1023 for scontext=unconfined_u:unconfined_r:rpm_script_t:s0-s0:c0.c1023 tcontext=system_u:object_r:useradd_exec_t:s0 tclass=process
type=SYSCALL msg=audit(1332377695.924:15802): arch=c000003e syscall=59 success=yes exit=0 a0=282ac10 a1=282acd0 a2=2827600 a3=80 items=0 ppid=12664 pid=12669 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=2 comm="useradd" exe="/usr/sbin/useradd" subj=unconfined_u:unconfined_r:useradd_t:s0-s0:c0.c1023 key=(null)
type=ADD_USER msg=audit(1332377695.982:15803): user pid=12669 uid=0 auid=0 ses=2 subj=unconfined_u:unconfined_r:useradd_t:s0-s0:c0.c1023 msg='op=adding user id=25 exe="/usr/sbin/useradd" hostname=? addr=? terminal=? res=success'

# ls -lZ /usr/sbin/bcfg2 
-rwxr-xr-x. root root system_u:object_r:bin_t:s0       /usr/sbin/bcfg2


Version-Release number of selected component (if applicable):
selinux-policy-3.7.19-126.el6_2.10

How reproducible:
Always

Steps to Reproduce:
1. use bcfg2 to configure new system, including package additions
2. tail -f /var/log/audit/audit.log
  
Actual results:
SELinux logs an error, users are not added.

Expected results:
New user accounts should be added according to rpm preinstall scripts

Comment 2 Milos Malik 2012-03-22 05:37:59 UTC
I'm not familiar with bcfg2* packages. Could you help me a little? I'm able to start bcfg2-server and it runs without errors. How do you invoke bcfg2 to install a package?

Comment 3 Milos Malik 2012-03-22 05:41:51 UTC
It seems that bcfg2-server does not have its own SELinux domain. It runs as initrc_t.

# rpm -qa selinux-policy\*
selinux-policy-targeted-3.7.19-142.el6.noarch
selinux-policy-minimum-3.7.19-142.el6.noarch
selinux-policy-3.7.19-142.el6.noarch
selinux-policy-doc-3.7.19-142.el6.noarch
selinux-policy-mls-3.7.19-142.el6.noarch
# sestatus 
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted
# ps -efZ | grep bcfg
unconfined_u:system_r:initrc_t:s0 root    7002     1  0 05:14 ?        00:00:00 /usr/bin/python /usr/sbin/bcfg2-server -D /var/run/bcfg2-server.pid
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 root 7190 6459  0 05:38 pts/0 00:00:00 grep bcfg
#

Comment 4 Miroslav Grepl 2012-03-22 07:56:05 UTC
The problem is bcfg2 was run directly from unconfined_t. 

How is bcfg2 used in your case?

Comment 5 Jonathan Billings 2012-03-22 13:23:43 UTC
Hi, I've also been hit by this bug so I can provide a bit more information.  Bcfg2 is a configuration management service, and the bcfg2 client is what's actually triggering this issue.  It's actually kind of complex to set up an example, but there's documentation here: http://docs.bcfg2.org/appendix/guides/centos.html#appendix-guides-centos

The issue isn't with bcfg2-server, but with the bcfg2 package, which uses the yum python libraries to install packages.  Most often, bcfg2 is run on the command line or as a cron job.  Both instances trigger this problem.  See the bcfg2 bug report here: http://trac.mcs.anl.gov/projects/bcfg2/ticket/1095

The issue is that when bcfg2 is invoked, it is capable of installing packages, but any packages that have preinstall scripts that attempt to create users or groups fail.  Changing the SELinux type on the bcfg2 executable to rpm_exec_t allows it to transition from the unconfined role to one which is allowed to run useradd and groupadd.

The temporary solution is to add that attribute to bcfg2, but it would be nice if /usr/sbin/bcfg2 could have the rpm_exec_t type in the RHEL6 selinux policy.

Comment 6 Daniel Walsh 2012-03-22 14:45:36 UTC
chcon -t rpm_exec_t /usr/sbin/bcfg2

Comment 7 Jonathan Billings 2012-03-22 14:52:26 UTC
Daniel Walsh:

Yes, that's the temporary solution I proposed in the bcfg2 ticket above.  Actually, I'm currently running: 

semanage fcontext -a -t rpm_exec_t /usr/sbin/bcfg2
and
restorecon /usr/sbin/bcfg2

for now, until the selinux policy is updated on RHEL6.

Comment 8 Daniel Walsh 2012-03-22 15:09:07 UTC
Great.

Comment 9 Miroslav Grepl 2012-03-26 08:57:29 UTC
I added it to Fedora, backporting to RHEL6.3.

Comment 10 Milos Malik 2012-03-27 08:14:18 UTC
Could you also create a new SELinux domain for bcfg2-server ? I noticed that it runs as initrc_t.

Comment 11 Jonathan Billings 2012-03-27 12:18:29 UTC
(In reply to comment #10)
> Could you also create a new SELinux domain for bcfg2-server ? I noticed that it
> runs as initrc_t.

This issue has nothing to do with the bcfg2-server process.

Comment 12 Daniel Walsh 2012-03-27 18:49:17 UTC
Milos is this server just running to install packages?

Comment 13 Jonathan Billings 2012-03-27 18:54:08 UTC
(In reply to comment #12)
> Milos is this server just running to install packages?

The bcfg2-server process started from the init script doesn't install packages.  The client (/usr/sbin/bcfg2) installs packages.  This is configuration management software, the server just directs the clients what packages are to be installed, based on the definitions in the configuration.

Comment 14 Daniel Walsh 2012-03-27 19:05:36 UTC
Ok lets open a separate bugzilla for this.

Comment 15 Miroslav Grepl 2012-04-17 11:40:23 UTC
The /usr/sbin/bcfg2 label has been fixed.

Comment 18 errata-xmlrpc 2012-06-20 12:32:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0780.html


Note You need to log in before you can comment on or make changes to this bug.