summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2015-05-06 11:47:46 -0400
committerSimo Sorce <simo@redhat.com>2015-05-06 13:45:30 -0400
commit59cf67c8613dcbc70730bb4f005fa63ad3899c5f (patch)
tree125cce6b618940e1d1032e99fe66a54ce7af79f3
parent158c4cdefc0bd5b8dabe38685c1bebccc24d656b (diff)
downloadipsilon-preconf.zip
ipsilon-preconf.tar.gz
ipsilon-preconf.tar.xz
Make SSSD config 'preconfigured' and unmodifiablepreconf
Also fail to enable if not pre-configured Fixes #111 Signed-off-by: Simo Sorce <simo@redhat.com>
-rw-r--r--ipsilon/admin/common.py10
-rw-r--r--ipsilon/info/common.py8
-rw-r--r--ipsilon/info/infosssd.py23
3 files changed, 37 insertions, 4 deletions
diff --git a/ipsilon/admin/common.py b/ipsilon/admin/common.py
index 743c71c..a85a15d 100644
--- a/ipsilon/admin/common.py
+++ b/ipsilon/admin/common.py
@@ -282,7 +282,10 @@ class AdminPlugins(AdminPage):
except AdminError, e:
return self.root_with_msg(str(e), ADMIN_STATUS_WARN)
if not obj.is_enabled:
- obj.enable()
+ try:
+ obj.enable()
+ except Exception as e: # pylint: disable=broad-except
+ return self.root_with_msg(str(e), ADMIN_STATUS_WARN)
obj.save_enabled_state()
msg = "Plugin %s enabled" % obj.name
return self.root_with_msg(msg, ADMIN_STATUS_OK,
@@ -297,7 +300,10 @@ class AdminPlugins(AdminPage):
except AdminError, e:
return self.root_with_msg(str(e), ADMIN_STATUS_WARN)
if obj.is_enabled:
- obj.disable()
+ try:
+ obj.disable()
+ except Exception as e: # pylint: disable=broad-except
+ return self.root_with_msg(str(e), ADMIN_STATUS_WARN)
obj.save_enabled_state()
msg = "Plugin %s disabled" % obj.name
return self.root_with_msg(msg, ADMIN_STATUS_OK,
diff --git a/ipsilon/info/common.py b/ipsilon/info/common.py
index a97d648..6907c72 100644
--- a/ipsilon/info/common.py
+++ b/ipsilon/info/common.py
@@ -65,7 +65,13 @@ class Info(Log):
if item not in plugins.available:
self.debug('Info Plugin %s not found' % item)
continue
- plugins.available[item].enable()
+ try:
+ plugins.available[item].enable()
+ except Exception as e: # pylint: disable=broad-except
+ while item in plugins.enabled:
+ plugins.enabled.remove(item)
+ self.debug("Info Plugin %s couldn't be enabled: %s" % (
+ item, str(e)))
def get_user_attrs(self, user, requested=None):
plugins = self._site[FACILITY].available
diff --git a/ipsilon/info/infosssd.py b/ipsilon/info/infosssd.py
index 0dd78cc..559469a 100644
--- a/ipsilon/info/infosssd.py
+++ b/ipsilon/info/infosssd.py
@@ -9,6 +9,7 @@ from ipsilon.info.common import InfoProviderBase
from ipsilon.info.common import InfoProviderInstaller
from ipsilon.util.plugin import PluginObject
from ipsilon.util.policy import Policy
+from ipsilon.util import config as pconfig
from string import Template
import cherrypy
import time
@@ -46,7 +47,13 @@ class InfoProvider(InfoProviderBase):
super(InfoProvider, self).__init__(*pargs)
self.mapper = Policy(sssd_mapping)
self.name = 'sssd'
- self.new_config(self.name)
+ self.new_config(
+ self.name,
+ pconfig.Condition(
+ 'preconfigured',
+ 'SSSD can only be used when pre-configured',
+ False),
+ )
def _get_user_data(self, user):
reply = dict()
@@ -80,6 +87,18 @@ class InfoProvider(InfoProviderBase):
return reply
+ def save_plugin_config(self, *args, **kwargs):
+ raise ValueError('Configuration cannot be modified live for SSSD')
+
+ def get_config_obj(self):
+ return None
+
+ def enable(self):
+ self.refresh_plugin_config()
+ if not self.get_config_value('preconfigured'):
+ raise Exception("SSSD Can be enabled only if pre-configured")
+ super(InfoProvider, self).enable()
+
CONF_TEMPLATE = """
LoadModule lookup_identity_module modules/mod_lookup_identity.so
@@ -192,6 +211,8 @@ class Installer(InfoProviderInstaller):
po.name = 'sssd'
po.wipe_data()
po.wipe_config_values()
+ config = {'preconfigured': True}
+ po.save_plugin_config(config)
# Update global config to add info plugin
po.is_enabled = True