diff options
author | Rob Crittenden <rcritten@redhat.com> | 2015-04-22 15:38:55 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2015-04-22 15:38:55 -0400 |
commit | f6d2225ec4325275f1eeb0b8089f1d598a7e7fc4 (patch) | |
tree | 435a4afb2b666b6231c126b28fb129ef9406fe3c /ipsilon/admin/common.py | |
parent | bf5398120e33ff3e88d7b3794c9437e7e75ee369 (diff) | |
download | ipsilon.git-no_sssd_ui.tar.gz ipsilon.git-no_sssd_ui.tar.xz ipsilon.git-no_sssd_ui.zip |
Don't allow the SSSD info plugin to enabled/disabled in UIno_sssd_ui
This is due to the fact that it requires root to modify the
SSSD configuration, modify the Apache configuration and
restart those services.
This uses the call location (from the stack) to determine the
source of the caller. We want to let enable() happen when the
Ipsilon service starts but not when it is accessed via the
admin UI. Ideally this would be passed in via a flag but since
there is only one use-case right now I went with the hackish
method.
https://fedorahosted.org/ipsilon/ticket/111
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Diffstat (limited to 'ipsilon/admin/common.py')
-rw-r--r-- | ipsilon/admin/common.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/ipsilon/admin/common.py b/ipsilon/admin/common.py index 7484806..2364df7 100644 --- a/ipsilon/admin/common.py +++ b/ipsilon/admin/common.py @@ -273,30 +273,42 @@ class AdminPlugins(AdminPage): @admin_protect def enable(self, plugin): msg = None + status = ADMIN_STATUS_OK try: obj = self._get_plugin_obj(plugin) except AdminError, e: return self.root_with_msg(str(e), ADMIN_STATUS_WARN) if not obj.is_enabled: - obj.enable() - obj.save_enabled_state() - msg = "Plugin %s enabled" % obj.name - return self.root_with_msg(msg, ADMIN_STATUS_OK, + try: + obj.enable() + obj.save_enabled_state() + except AdminError as e: + msg = str(e) + status = ADMIN_STATUS_WARN + else: + msg = "Plugin %s enabled" % obj.name + return self.root_with_msg(msg, status, changed={obj.name: 'enabled'}) enable.public_function = True @admin_protect def disable(self, plugin): msg = None + status = ADMIN_STATUS_OK try: obj = self._get_plugin_obj(plugin) except AdminError, e: return self.root_with_msg(str(e), ADMIN_STATUS_WARN) if obj.is_enabled: - obj.disable() - obj.save_enabled_state() - msg = "Plugin %s disabled" % obj.name - return self.root_with_msg(msg, ADMIN_STATUS_OK, + try: + obj.disable() + obj.save_enabled_state() + except AdminError as e: + msg = str(e) + status = ADMIN_STATUS_WARN + else: + msg = "Plugin %s disabled" % obj.name + return self.root_with_msg(msg, status, changed={obj.name: 'disabled'}) disable.public_function = True |