Change in vdsm[ovirt-3.5]: tool: moving setup booleans verb to be part of the configura...

ybronhei at redhat.com ybronhei at redhat.com
Sat Oct 25 14:20:00 UTC 2014


Yaniv Bronhaim has uploaded a new change for review.

Change subject: tool: moving setup booleans verb to be part of the configurators
......................................................................

tool: moving setup booleans verb to be part of the configurators

Change-Id: Icc97ba04c3b3463ae353815cdcf77b2212644e99
Signed-off-by: Yaniv Bronhaim <ybronhei at redhat.com>
---
M debian/vdsm-python.install
M debian/vdsm.postinst
M debian/vdsm.prerm
M lib/vdsm/tool/Makefile.am
M lib/vdsm/tool/configurator.py
M lib/vdsm/tool/configurators/Makefile.am
A lib/vdsm/tool/configurators/sebool.py
D lib/vdsm/tool/seboolsetup.py
M vdsm-tool/vdsm-tool.1.in
M vdsm.spec.in
10 files changed, 101 insertions(+), 96 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/63/34463/1

diff --git a/debian/vdsm-python.install b/debian/vdsm-python.install
index 42f08c2..b89f30d 100644
--- a/debian/vdsm-python.install
+++ b/debian/vdsm-python.install
@@ -23,7 +23,6 @@
 ./usr/lib/python2.7/dist-packages/vdsm/tool/nwfilter.py
 ./usr/lib/python2.7/dist-packages/vdsm/tool/passwd.py
 ./usr/lib/python2.7/dist-packages/vdsm/tool/restore_nets.py
-./usr/lib/python2.7/dist-packages/vdsm/tool/seboolsetup.py
 ./usr/lib/python2.7/dist-packages/vdsm/tool/service.py
 ./usr/lib/python2.7/dist-packages/vdsm/tool/transient.py
 ./usr/lib/python2.7/dist-packages/vdsm/tool/unified_persistence.py
diff --git a/debian/vdsm.postinst b/debian/vdsm.postinst
index 224e021..c00a1a6 100644
--- a/debian/vdsm.postinst
+++ b/debian/vdsm.postinst
@@ -68,7 +68,6 @@
         chmod g+x /var/lib/libvirt/qemu
         chmod 644 /etc/iscsi/initiatorname.iscsi
 
-        vdsm-tool sebool-config || :
         sysctl -q -p /etc/sysctl.d/vdsm.conf
         vdsm-tool load-needed-modules
 
diff --git a/debian/vdsm.prerm b/debian/vdsm.prerm
index 596c5be..7f647a9 100644
--- a/debian/vdsm.prerm
+++ b/debian/vdsm.prerm
@@ -37,7 +37,6 @@
 
         # Restoring backuped logrotate.d/libvirtd
         sed -i -e 's/# VDSM backup//' /etc/logrotate.d/libvirtd
-        vdsm-tool sebool-unconfig || :
         saslpasswd2 -p -a libvirt -d vdsm at ovirt
     ;;
 
diff --git a/lib/vdsm/tool/Makefile.am b/lib/vdsm/tool/Makefile.am
index a181617..3d8b4ff 100644
--- a/lib/vdsm/tool/Makefile.am
+++ b/lib/vdsm/tool/Makefile.am
@@ -45,7 +45,6 @@
 	configurator.py \
 	passwd.py \
 	restore_nets.py \
-	seboolsetup.py \
 	service.py \
 	transient.py \
 	unified_persistence.py \
diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
index 9160d75..ec3d75e 100644
--- a/lib/vdsm/tool/configurator.py
+++ b/lib/vdsm/tool/configurator.py
@@ -34,13 +34,15 @@
     InvalidRun, \
     libvirt, \
     NOT_CONFIGURED, \
-    sanlock
+    sanlock, \
+    sebool
 
 
 _CONFIGURATORS = dict((m.getName(), m) for m in (
     certificates.Certificates(),
     libvirt.Libvirt(),
     sanlock.Sanlock(),
+    sebool.SEBool(),
 ))
 
 
diff --git a/lib/vdsm/tool/configurators/Makefile.am b/lib/vdsm/tool/configurators/Makefile.am
index 02c6f82..3c153cc 100644
--- a/lib/vdsm/tool/configurators/Makefile.am
+++ b/lib/vdsm/tool/configurators/Makefile.am
@@ -25,4 +25,5 @@
 	configfile.py \
 	libvirt.py \
 	sanlock.py \
+	sebool.py \
 	$(NULL)
diff --git a/lib/vdsm/tool/configurators/sebool.py b/lib/vdsm/tool/configurators/sebool.py
new file mode 100644
index 0000000..9d34781
--- /dev/null
+++ b/lib/vdsm/tool/configurators/sebool.py
@@ -0,0 +1,96 @@
+# 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
+#
+
+from .import \
+    CONFIGURED, \
+    ModuleConfigure, \
+    NOT_CONFIGURED
+
+from ... import utils
+
+
+SEBOOL_ENABLED = "on"
+SEBOOL_DISABLED = "off"
+
+VDSM_SEBOOL_LIST = (
+    "virt_use_fusefs",
+    "virt_use_nfs",
+    "virt_use_samba",
+    "virt_use_sanlock",
+    "sanlock_use_fusefs",
+    "sanlock_use_nfs",
+    "sanlock_use_samba",
+)
+
+
+class SEBool(ModuleConfigure):
+
+    @property
+    def name(self):
+        return 'sebool'
+
+    def _setup_booleans(self, status):
+        # loading seobject is slow. Deferring its loading can reduce VDSM
+        # startings time, because most utilities are and will be moved
+        # to vdsm-tool.
+        import seobject
+
+        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()
+
+    def isconfigured(self):
+        """
+        True all selinux booleans in the list above are set properly
+        """
+        import seobject
+        ret = CONFIGURED
+
+        sebool_obj = seobject.booleanRecords()
+        sebool_status = sebool_obj.get_all()
+
+        for sebool_variable in VDSM_SEBOOL_LIST:
+            if not all(sebool_status[sebool_variable]):
+                ret = NOT_CONFIGURED
+
+        return ret
+
+    def configure(self):
+        """
+        Configure selinux booleans (see list above)
+        """
+        if utils.get_selinux_enforce_mode() > -1:
+            self._setup_booleans(True)
+
+    def removeConf(self):
+        """
+        Disabling selinux booleans (see list above)
+        """
+        if utils.get_selinux_enforce_mode() > -1:
+            self._setup_booleans(False)
diff --git a/lib/vdsm/tool/seboolsetup.py b/lib/vdsm/tool/seboolsetup.py
deleted file mode 100644
index fc8f726..0000000
--- a/lib/vdsm/tool/seboolsetup.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# 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
-#
-
-from . import expose, ExtraArgsError
-
-SEBOOL_ENABLED = "on"
-SEBOOL_DISABLED = "off"
-
-VDSM_SEBOOL_LIST = [
-    "virt_use_fusefs",
-    "virt_use_nfs",
-    "virt_use_samba",
-    "virt_use_sanlock",
-    "sanlock_use_fusefs",
-    "sanlock_use_nfs",
-    "sanlock_use_samba",
-]
-
-
-def setup_booleans(status):
-    # loading seobject is slow. Deferring its loading can reduce VDSM starting
-    # time, because most utilities are and will be moved to vdsm-tool.
-    import seobject
-    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()
-
-
- at expose("sebool-config")
-def sebool_config(*args):
-    """
-    sebool-config
-    Enable the required selinux booleans
-    """
-
-    if len(args) > 1:
-        raise ExtraArgsError()
-
-    setup_booleans(True)
-
-
- at expose("sebool-unconfig")
-def sebool_unconfig(*args):
-    """
-    sebool-unconfig
-    Disable the required selinux booleans
-    """
-    if len(args) > 1:
-        raise ExtraArgsError()
-    setup_booleans(False)
diff --git a/vdsm-tool/vdsm-tool.1.in b/vdsm-tool/vdsm-tool.1.in
index 68dfaf7..5d52857 100644
--- a/vdsm-tool/vdsm-tool.1.in
+++ b/vdsm-tool/vdsm-tool.1.in
@@ -100,16 +100,6 @@
 Restores the networks to what was previously persisted via VDSM.
 .RE
 .TP
-Options for the \fIseboolsetup\fP module:
-.RS
-.TP
-.B sebool-config
-Enables the required SELinux booleans.
-.TP
-.B sebool-unconfig
-Disables the required SELinux booleans.
-.RE
-.TP
 Options for the \fIservice\fP module:
 .RS
 .TP
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 024cfdc..1e4c16c 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -738,7 +738,6 @@
 
 %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
 
@@ -802,8 +801,6 @@
 
     /bin/sed -i '/# VDSM section begin/,/# VDSM section end/d' \
         /etc/sysctl.conf
-
-    %{_bindir}/vdsm-tool sebool-unconfig || :
 
     %{_bindir}/vdsm-tool remove-saslpasswd
 
@@ -1217,9 +1214,9 @@
 %{python_sitelib}/%{vdsm_name}/tool/configurators/certificates.py*
 %{python_sitelib}/%{vdsm_name}/tool/configurators/libvirt.py*
 %{python_sitelib}/%{vdsm_name}/tool/configurators/sanlock.py*
+%{python_sitelib}/%{vdsm_name}/tool/configurators/sebool.py*
 %{python_sitelib}/%{vdsm_name}/tool/passwd.py*
 %{python_sitelib}/%{vdsm_name}/tool/restore_nets.py*
-%{python_sitelib}/%{vdsm_name}/tool/seboolsetup.py*
 %{python_sitelib}/%{vdsm_name}/tool/service.py*
 %{python_sitelib}/%{vdsm_name}/tool/transient.py*
 %{python_sitelib}/%{vdsm_name}/tool/unified_persistence.py*


-- 
To view, visit http://gerrit.ovirt.org/34463
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc97ba04c3b3463ae353815cdcf77b2212644e99
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Yaniv Bronhaim <ybronhei at redhat.com>


More information about the vdsm-patches mailing list