Federico Simoncelli has uploaded a new change for review.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
vdsm-tool: add the sebool configuration module
This patch moves the sebool configuration from a shell scriptlet in the rpm package to the vdsm-tool command.
Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Signed-off-by: Federico Simoncelli fsimonce@redhat.com --- M vdsm-tool/Makefile.am A vdsm-tool/seboolsetup.py M vdsm.spec.in 3 files changed, 69 insertions(+), 36 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/9362/1
diff --git a/vdsm-tool/Makefile.am b/vdsm-tool/Makefile.am index 997e339..348940e 100644 --- a/vdsm-tool/Makefile.am +++ b/vdsm-tool/Makefile.am @@ -29,5 +29,6 @@ __init__.py \ load_needed_modules.py \ passwd.py \ + seboolsetup.py \ validate_ovirt_certs.py \ $(NULL) diff --git a/vdsm-tool/seboolsetup.py b/vdsm-tool/seboolsetup.py new file mode 100644 index 0000000..dee1e58 --- /dev/null +++ b/vdsm-tool/seboolsetup.py @@ -0,0 +1,63 @@ +# +# Copyright 2012 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# + +import seobject +from vdsm.tool import expose + +SEBOOL_ENABLED = "on" +SEBOOL_DISABLED = "off" + +VDSM_SEBOOL_LIST = [ + "virt_use_fusefs", + "virt_use_nfs", + "virt_use_samba", + "sanlock_use_fusefs", + "sanlock_use_nfs", + "sanlock_use_samba", + "virt_use_sanlock", +] + + +def setup_booleans(status): + sebool_obj = seobject.booleanRecords() + sebool_status = sebool_obj.get_all() + + sebool_obj.start() + + for sebool_variable in VDSM_SEBOOL_LIST: + if status and not all(sebool_status[sebool_variable]): + sebool_obj.modify(sebool_variable, SEBOOL_ENABLED) + + if not status and any(sebool_status[sebool_variable]): + sebool_obj.modify(sebool_variable, SEBOOL_DISABLED) + + sebool_obj.finish() + + +@expose("sebool-enable") +def sebool_enable(): + """Enable the required selinux booleans""" + setup_booleans(True) + + +@expose("sebool-disable") +def sebool_disable(): + """Disable the required selinux booleans""" + setup_booleans(False) diff --git a/vdsm.spec.in b/vdsm.spec.in index 3fa3395..033ce1a 100644 --- a/vdsm.spec.in +++ b/vdsm.spec.in @@ -456,30 +456,8 @@ /usr/sbin/usermod -a -G %{qemu_group},%{snlk_group} %{vdsm_user} /usr/sbin/usermod -a -G %{qemu_group},%{vdsm_group} %{snlk_user}
-# vdsm makes extensive use of nfs-exported images -# The next lines will collect the default selinux behaviour for the booleans -virtNFS=$(/usr/sbin/semanage boolean -l | /bin/grep virt_use_nfs | cut -d ',' -f 2) -virtSANLOCK=$(/usr/sbin/semanage boolean -l | /bin/grep virt_use_sanlock | cut -d ',' -f 2) -snlkNFS=$(/usr/sbin/semanage boolean -l | /bin/grep sanlock_use_nfs | cut -d ',' -f 2) - -# Set the booleans and persist it across reboots -if [[ "${virtNFS}" == *off* || "${virtSANLOCK}" == *off* || \ - "${snlkNFS}" == *off* ]]; then - /usr/sbin/semanage boolean -m -S targeted -F /dev/stdin << _EOF -virt_use_nfs=1 -virt_use_sanlock=1 -sanlock_use_nfs=1 -_EOF -fi - -# Set the current state of SELinux booleans -if /usr/sbin/selinuxenabled; then - /usr/sbin/setsebool virt_use_nfs on - /usr/sbin/setsebool virt_use_sanlock on - /usr/sbin/setsebool sanlock_use_nfs on -fi - %post +%{_bindir}/vdsm-tool sebool-enable # set the vdsm "secret" password for libvirt %{_bindir}/vdsm-tool set-saslpasswd
@@ -521,17 +499,7 @@ /bin/sed -i '/# VDSM section begin/,/# VDSM section end/d' \ /etc/sysctl.conf
- /usr/sbin/semanage boolean -m -S targeted -F /dev/stdin << _EOF -virt_use_nfs=0 -virt_use_sanlock=0 -sanlock_use_nfs=0 -_EOF - - if /usr/sbin/selinuxenabled; then - /usr/sbin/setsebool virt_use_nfs off - /usr/sbin/setsebool virt_use_sanlock off - /usr/sbin/setsebool sanlock_use_nfs off - fi + %{_bindir}/vdsm-tool sebool-disable
/usr/sbin/saslpasswd2 -p -a libvirt -d vdsm@ovirt
@@ -794,9 +762,10 @@ %{python_sitearch}/%{vdsm_name}/betterPopen/__init__.py* %{python_sitearch}/%{vdsm_name}/betterPopen/createprocess.so %{python_sitearch}/%{vdsm_name}/tool/__init__.py* -%{python_sitearch}/%{vdsm_name}/tool/passwd.py* -%{python_sitearch}/%{vdsm_name}/tool/validate_ovirt_certs.py* %{python_sitearch}/%{vdsm_name}/tool/load_needed_modules.py* +%{python_sitearch}/%{vdsm_name}/tool/passwd.py* +%{python_sitearch}/%{vdsm_name}/tool/seboolsetup.py* +%{python_sitearch}/%{vdsm_name}/tool/validate_ovirt_certs.py*
%files tests %doc %{_datadir}/%{vdsm_name}/tests/README
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/106/ (2/2)
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/72/ (1/2)
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 1:
Build Successful
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/72/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/106/ : SUCCESS
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 1: I would prefer that you didn't submit this
(1 inline comment)
minor naming suggestion.
.................................................... File vdsm-tool/seboolsetup.py Line 51: sebool_obj.finish() Line 52: Line 53: Line 54: @expose("sebool-enable") Line 55: def sebool_enable(): this name assume that we would never need to disable any seboolean.
how about keeping it a bit more general, like "selinux-config" or "selinux-unconfig". Line 56: """Enable the required selinux booleans""" Line 57: setup_booleans(True) Line 58: Line 59:
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 2:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/123/ (1/2)
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 2:
Build Started http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/89/ (2/2)
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 2:
Build Successful
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/89/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/123/ : SUCCESS
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 2: Looks good to me, approved
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Douglas Schilling Landgraf has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 2: Looks good to me, but someone else must approve
Much better. I just noticed that you have included as well passwd.py and validate_ovirt_certs.py.in to spec file maybe next time would be better in a separate patch?
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Douglas Schilling Landgraf has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 2:
Ah, just noticed that you changed the order of files... sorry the confusion, thanks!
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 2: Fails
(1 inline comment)
seems that I'm missing something basic.
.................................................... File vdsm-tool/seboolsetup.py Line 39: sebool_obj = seobject.booleanRecords() Line 40: sebool_status = sebool_obj.get_all() Line 41: Line 42: sebool_obj.start() Line 43: to verify this patch, I've manually
setsebool virt_use_nfs off
and install vdsm. The boolean was not turned on; how come do I have both
sebool_status["virt_use_nfs"]
[1, 1, 1] $ getsebool virt_use_nfs virt_use_nfs --> off Line 44: for sebool_variable in VDSM_SEBOOL_LIST: Line 45: if status and not all(sebool_status[sebool_variable]): Line 46: sebool_obj.modify(sebool_variable, SEBOOL_ENABLED) Line 47:
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
Patch Set 2: Verified
on irc, Federico told me that I'm missing -P: we care only about persisted policy, and the currently effective one.
If the local admin has changed the effective policy, he probably knows what's good for him.
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Dan Kenigsberg has submitted this change and it was merged.
Change subject: vdsm-tool: add the sebool configuration module ......................................................................
vdsm-tool: add the sebool configuration module
This patch moves the sebool configuration from a shell scriptlet in the rpm package to the vdsm-tool command.
Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Signed-off-by: Federico Simoncelli fsimonce@redhat.com --- M vdsm-tool/Makefile.am A vdsm-tool/seboolsetup.py M vdsm.spec.in 3 files changed, 69 insertions(+), 36 deletions(-)
Approvals: Douglas Schilling Landgraf: Looks good to me, but someone else must approve Dan Kenigsberg: Verified; Looks good to me, approved
-- To view, visit http://gerrit.ovirt.org/9362 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: I01baf1c17f7cad2a0525b261be6b5ac648576252 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Douglas Schilling Landgraf dougsland@redhat.com Gerrit-Reviewer: Federico Simoncelli fsimonce@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
vdsm-patches@lists.fedorahosted.org