Bug 1139873 - vdsm-tool sebool-config call fails with AttributeError during vdsmd start
Summary: vdsm-tool sebool-config call fails with AttributeError during vdsmd start
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: vdsm
Version: 3.5.0
Hardware: x86_64
OS: Linux
urgent
high
Target Milestone: ---
: 3.5.0
Assignee: Mooli Tayer
QA Contact: Nikolai Sednev
URL:
Whiteboard: infra
: 1142739 (view as bug list)
Depends On: 1148800
Blocks: 1175555 1175723
TreeView+ depends on / blocked
 
Reported: 2014-09-09 21:14 UTC by Marian Krcmarik
Modified: 2016-02-10 19:13 UTC (History)
24 users (show)

Fixed In Version: vdsm-4.16.8.1-4.el6ev
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1175555 (view as bug list)
Environment:
Last Closed: 2015-02-16 13:37:36 UTC
oVirt Team: Infra
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
policycoreutils seobject.patch (431 bytes, patch)
2014-10-01 09:35 UTC, Miroslav Grepl
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 33771 0 master MERGED spec: bump policycoreutils-python version to 2.0.83-19.47. 2020-09-16 14:42:20 UTC
oVirt gerrit 33986 0 ovirt-3.5 MERGED spec: bump policycoreutils-python version to 2.0.83-19.47 2020-09-16 14:42:18 UTC
oVirt gerrit 36148 0 master MERGED spec: bump policycoreutils-python >= 2.0.83-19.47.el6_6.1 2020-09-16 14:42:18 UTC
oVirt gerrit 36168 0 ovirt-3.5 MERGED spec: bump policycoreutils-python >= 2.0.83-19.47.el6_6.1 2020-09-16 14:42:18 UTC

Description Marian Krcmarik 2014-09-09 21:14:13 UTC
Description of problem:
VM is not lanuched when using libvirt since selinux prevents libvirtd to connect to /var/run/sanlock/sanlock.sock, See the AVC:
type=AVC msg=audit(1410296138.576:290): avc:  denied  { connectto } for  pid=6707 comm="libvirtd" path="/var/run/sanlock/sanlock.sock" scontext=system_u:system_r:svirt_t:s0:c190,c297 tcontext=system_u:system_r:sanlock_t:s0-s0:c0.c1023 tclass=unix_stream_socket

ls -Z /var/run/sanlock/sanlock.sock
srw-rw----. sanlock sanlock system_u:object_r:sanlock_var_run_t:s0 /var/run/sanlock/sanlock.sock

Version-Release number of selected component (if applicable):
selinux-policy-3.7.19-254
libvirt-0.10.2-29.el6_5.12.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Start a VM managed by libvirt


Actual results:
Acces denied

Expected results:
Access allowed

Additional info:

Comment 2 Milos Malik 2014-09-10 05:56:30 UTC
Did you enable the virt_use_sanlock boolean ?

Comment 3 Marian Krcmarik 2014-09-10 08:55:52 UTC
(In reply to Milos Malik from comment #2)
> Did you enable the virt_use_sanlock boolean ?

Hm I did not, It helps, but something should turn it on, in RHEVM environment. 
I am moving to vdsm then.

I guess vdsm should turn the seboolean virt_use_sanlock to on.
vdsm-4.16.3-2.el6.x86_64

Comment 4 Marian Krcmarik 2014-09-10 09:14:55 UTC
Actually all of the seboleans from vdsm/tool/seboolsetup.py are off:

"virt_use_fusefs",
"virt_use_nfs",
"virt_use_samba",
"virt_use_sanlock",
"sanlock_use_fusefs",
"sanlock_use_nfs",
"sanlock_use_samba",

Comment 5 Miroslav Grepl 2014-09-10 14:02:01 UTC
#============= svirt_t ==============

#!!!! This avc can be allowed using the boolean 'virt_use_sanlock'
allow svirt_t sanlock_t:unix_stream_socket connectto;

Comment 6 Francesco Romani 2014-09-19 16:18:49 UTC
These selinux booleans are already configured by VDSM.

However, the selinux configuration is run only after vdsm is installed or before it was removed. For example, quoting vdsm.spec:

%post
%{_bindir}/vdsm-tool configure --module sanlock --force >/dev/null
%{_bindir}/vdsm-tool sebool-config || :
# set the vdsm "secret" password for libvirt
%{_bindir}/vdsm-tool set-saslpasswd

Comment 7 Marian Krcmarik 2014-09-19 16:21:15 UTC
(In reply to Francesco Romani from comment #6)
> These selinux booleans are already configured by VDSM.
> 
> However, the selinux configuration is run only after vdsm is installed or
> before it was removed. For example, quoting vdsm.spec:
> 
> %post
> %{_bindir}/vdsm-tool configure --module sanlock --force >/dev/null
> %{_bindir}/vdsm-tool sebool-config || :
> # set the vdsm "secret" password for libvirt
> %{_bindir}/vdsm-tool set-saslpasswd

and my observation is that they are not set when vdsm is installed on RHEL6 hosts that's why I created a bug.

Comment 8 Yaniv Bronhaim 2014-09-21 08:02:52 UTC
can you run manually "vdsm-tool sebool-config" and tell if it creates the missing policies?

mooli, can you reproduce it and check if we call the sebool-config as we used to during the rpm installation or we added some kind of regression in that area?

Comment 9 Omer Frenkel 2014-09-22 08:18:51 UTC
*** Bug 1142739 has been marked as a duplicate of this bug. ***

Comment 10 Marian Krcmarik 2014-09-22 10:55:56 UTC
(In reply to Yaniv Bronhaim from comment #8)
> can you run manually "vdsm-tool sebool-config" and tell if it creates the
> missing policies?
# vdsm-tool sebool-config
Traceback (most recent call last):
  File "/usr/bin/vdsm-tool", line 209, in main
    return tool_command[cmd]["command"](*args)
  File "/usr/lib64/python2.6/site-packages/vdsm/tool/seboolsetup.py", line 66, in sebool_config
    setup_booleans(True)
  File "/usr/lib64/python2.6/site-packages/vdsm/tool/seboolsetup.py", line 53, in setup_booleans
    sebool_obj.finish()
  File "/usr/lib64/python2.6/site-packages/seobject.py", line 320, in finish
    self.commit()
  File "/usr/lib64/python2.6/site-packages/seobject.py", line 309, in commit
    semanage_set_reload(self.sh, self.load)
AttributeError: booleanRecords instance has no attribute 'load'

Comment 12 Yaniv Bronhaim 2014-09-28 06:59:45 UTC
Looks like the bug is in your policycoreutils-python package. can you check what version do you use (run "rpm -q policycoreutils-python")

in my rhel 6.5 setup I use policycoreutils-python-2.0.83-19.39.el6.x86_64 which works fine

Comment 13 Marian Krcmarik 2014-09-28 18:13:39 UTC
(In reply to Yaniv Bronhaim from comment #12)
> Looks like the bug is in your policycoreutils-python package. can you check
> what version do you use (run "rpm -q policycoreutils-python")
> 
> in my rhel 6.5 setup I use policycoreutils-python-2.0.83-19.39.el6.x86_64
> which works fine

policycoreutils-python-2.0.83-19.47.el6.x86_64

Comment 14 Mooli Tayer 2014-09-29 14:53:35 UTC
I tested on policycoreutils-python-2.0.83-19.39.el6.x86_64 and everything seems fine.

I could not locate policycoreutils-python-2.0.83-19.47 on brew/on the internet.

What repo is it coming from("yum list policycoreutils-python")?

are there steps to reproduce this on a fresh host? 

I would very much like access to that machine.

Please ping me (mtayer) on #vdsm

PS the code of seobject.py that I get looks very different from that throwing the exception above (semanage_set_reload is a function defined in semanage.py and not seobject.py) this looks strange to me for a different release(39 vs 47) only?
but I'm not sure what to make of it.

I will try to catch the packager also.

Comment 16 Mooli Tayer 2014-09-30 13:03:58 UTC
Tested on the rhel 6.6 machine where this occurred.

AFAIU, as yaniv suggested, there is a problem with policycoreutils-python.

The following succeeds with:
policycoreutils-python-2.2.5-4.fc20.x86_64 (fe20 current) and
policycoreutils-python-2.0.83-19.39.el6.x86_64 (el6.4 current).

But fails with:
policycoreutils-python-2.0.83-19.47.el6.x86_64(el6.6 current?)

$ python
...
>>> import seobject
>>> seobject.booleanRecords().modify('virt_use_samba','on')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/seobject.py", line 2102, in modify
    self.commit()
  File "/usr/lib64/python2.6/site-packages/seobject.py", line 309, in commit
    semanage_set_reload(self.sh, self.load) 
AttributeError: booleanRecords instance has no attribute 'load'

Comment 17 Miroslav Grepl 2014-10-01 09:35:49 UTC
Created attachment 943008 [details]
policycoreutils seobject.patch

Could you try to apply the following patch. Basically we implemented a new optioni in RHEL6.6 which causes now this issue.

Comment 18 Miroslav Grepl 2014-10-01 09:36:48 UTC
It should work with

https://brewweb.devel.redhat.com/buildinfo?buildID=369418

policycoreutils builds without a new option.

Comment 19 Mooli Tayer 2014-10-01 13:34:30 UTC
Marian I've do not access to the machine.

can you please try to downgrade to policycoreutils-2.0.83-19.43.el6

If not ping me and we can apply the one line patch to the machine.

Comment 20 Marian Krcmarik 2014-10-01 14:28:06 UTC
# rpm -qa | grep policycore
policycoreutils-2.0.83-19.43.el6.x86_64
policycoreutils-python-2.0.83-19.43.el6.x86_64

# vdsm-tool sebool-config
Traceback (most recent call last):
  File "/usr/bin/vdsm-tool", line 209, in main
    return tool_command[cmd]["command"](*args)
  File "/usr/lib64/python2.6/site-packages/vdsm/tool/seboolsetup.py", line 66, in sebool_config
    setup_booleans(True)
  File "/usr/lib64/python2.6/site-packages/vdsm/tool/seboolsetup.py", line 53, in setup_booleans
    sebool_obj.finish()
  File "/usr/lib64/python2.6/site-packages/seobject.py", line 320, in finish
    self.commit()
  File "/usr/lib64/python2.6/site-packages/seobject.py", line 309, in commit
    semanage_set_reload(self.sh, self.load)
AttributeError: booleanRecords instance has no attribute 'load'

But applying the one liner helps and it seems to work as expected.

Comment 21 Michal Skrivanek 2014-10-02 12:14:24 UTC
do we want to add a specific dependency on a new selinux package?

Comment 22 Mooli Tayer 2014-10-02 15:05:57 UTC
If case the bugfix in policycoreutils-python will reach 6.6 GA,
won't the erroneous minor releases  be untagged?

(the bug effect everyone and not just us.)

Dan?

Comment 23 Mooli Tayer 2014-10-02 15:50:11 UTC
Aside from handling the dependency issue,
I think error handling needs improvement. 

We ignore it so we won't fail due to disabled selinux.

In cases where the failure is from a different unknown reason,
we get a broken installation - as seen here and ovirt-host-deploy succeeds.
(though we do get log error.)

Patch suggested.

Comment 24 Dan Kenigsberg 2014-10-02 20:36:34 UTC
(In reply to Mooli Tayer from comment #22)
> If case the bugfix in policycoreutils-python will reach 6.6 GA,
> won't the erroneous minor releases  be untagged?
> 
> (the bug effect everyone and not just us.)
> 
> Dan?

The fix is expected to be on 0day errata, and reach everybody. HOWEVER, QE are notorious of having partially-updated machines. Adding an explicit requirement in spec is just another way to ensure that you won't need to debug the same bug again.

Swallowing only the expected error (in case selinux is disabled) is a good idea.

Comment 25 Mooli Tayer 2014-10-03 13:27:49 UTC
INO The version bump patch (33771) should make 3.5.0
The swallow errors patch (33737) should probably not.

Comment 27 Dan Kenigsberg 2014-10-15 16:34:10 UTC
We require only publically-available packages. At least we try. Sometime, we require an upstream version of (say) libvirt which has not Fedora/el6 build yet. But that's reasonable only for important new features, not to avoid a bug in a dependent package.

Comment 28 Oved Ourfali 2014-10-22 11:53:11 UTC
(In reply to Dan Kenigsberg from comment #27)
> We require only publically-available packages. At least we try. Sometime, we
> require an upstream version of (say) libvirt which has not Fedora/el6 build
> yet. But that's reasonable only for important new features, not to avoid a
> bug in a dependent package.

So can we fix that in 3.5.0? Will there be a suitable public package at that time frame?

Comment 31 Nikolai Sednev 2014-11-20 16:38:14 UTC
Hi,
Please provide more detailed steps for reproduction of a bug, I'm not quite getting the meaning VM managed by libvirt, please add some WEBUI based steps or command list for for reproduction.

Comment 32 Nikolai Sednev 2014-11-20 17:42:44 UTC
Works for me on these components:
libvirt-0.10.2-46.el6_6.2.x86_64
vdsm-4.16.7.4-1.el6ev.x86_64
ovirt-hosted-engine-ha-1.2.4-1.el6ev.noarch
ovirt-hosted-engine-setup-1.2.1-3.el6ev.noarch
sanlock-2.8-1.el6.x86_64
ovirt-host-deploy-1.3.0-1.el6ev.noarch
policycoreutils-python-2.0.83-19.47.el6_6.1.x86_64
rhevm-3.5.0-0.20.el6ev.noarch


Here is an example of vdsm-tool configure --force:

[root@blue-vdsc ~]# vdsm-tool configure --force

Checking configuration status...

libvirt is already configured for vdsm

Running configure...
Reconfiguration of libvirt is done.

Done configuring modules to VDSM.
You have new mail in /var/spool/mail/root

Comment 33 Nikolai Sednev 2014-11-25 16:51:25 UTC
Works for me:
policycoreutils-python-2.0.83-19.47.el6_6.1.x86_64
qemu-kvm-rhev-0.12.1.2-2.448.el6.x86_64
ovirt-hosted-engine-setup-1.2.1-4.el6ev.noarch
sanlock-2.8-1.el6.x86_64
ovirt-host-deploy-1.3.0-1.el6ev.noarch
ovirt-hosted-engine-ha-1.2.4-1.el6ev.noarch
libvirt-0.10.2-46.el6_6.2.x86_64
vdsm-4.16.7.5-1.el6ev.x86_64
rhevm-3.5.0-0.21.el6ev.noarch


[root@brown-vdsd ~]# vdsm-tool configure --force

Checking configuration status...

libvirt is already configured for vdsm

Running configure...
Reconfiguration of libvirt is done.

Done configuring modules to VDSM.
You have new mail in /var/spool/mail/root
[root@brown-vdsd ~]#

Comment 34 Yaniv Bronhaim 2014-12-14 12:17:41 UTC
Looks that the requirement is currently wrong. still getting this exception in master and 3.5 branch

http://gerrit.ovirt.org/#/c/36148/ should be the right requirement.

Comment 35 Michal Skrivanek 2014-12-15 08:48:58 UTC
(In reply to Yaniv Bronhaim from comment #34)
> Looks that the requirement is currently wrong. still getting this exception
> in master and 3.5 branch
> 
> http://gerrit.ovirt.org/#/c/36148/ should be the right requirement.

how do you get any exception? 6.6 is shipping the right version for a month already

Comment 36 Mooli Tayer 2014-12-15 09:57:18 UTC
> (In reply to Yaniv Bronhaim from comment #34)
> > Looks that the requirement is currently wrong. still getting this exception
> > in master and 3.5 branch
> > 
> > http://gerrit.ovirt.org/#/c/36148/ should be the right requirement.
> 
> how do you get any exception? 6.6 is shipping the right version for a month
> already

(In reply to Michal Skrivanek from comment #35)
It is indeed:
http://mirror.centos.org/centos-6/6.6/updates/x86_64/Packages/policycoreutils-python-2.0.83-19.47.el6_6.1.x86_64.rpm

I've looked in that machine and I believe the rpm repo used is out of date.

The version bump patch will fail under such circumstances.

Please review.

Comment 38 Nikolai Sednev 2014-12-28 16:39:49 UTC
Works for me:
# vdsm-tool configure --force

Checking configuration status...

libvirt is already configured for vdsm

Running configure...
Reconfiguration of libvirt is done.

Done configuring modules to VDSM.

vdsm-4.16.8.1-4.el7ev.x86_64
qemu-kvm-rhev-1.5.3-60.el7_0.11.x86_64
mom-0.4.1-4.el7ev.noarch
libvirt-client-1.2.8-10.el7.x86_64
policycoreutils-python-2.2.5-15.el7.x86_64
sanlock-3.2.2-2.el7.x86_64


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