pessulus r395 - in trunk: . Pessulus
- From: vuntz svn gnome org
- To: svn-commits-list gnome org
- Subject: pessulus r395 - in trunk: . Pessulus
- Date: Sat, 31 Jan 2009 07:36:08 +0000 (UTC)
Author: vuntz
Date: Sat Jan 31 07:36:08 2009
New Revision: 395
URL: http://svn.gnome.org/viewvc/pessulus?rev=395&view=rev
Log:
2009-01-31 Vincent Untz <vuntz gnome org>
Handle the case where pessulus fails under "su" because gconf doesn't
work (you now need to use "su -" because of its dbus usage)
See http://bugs.freedesktop.org/show_bug.cgi?id=17970 for some
background.
Fixes https://bugzilla.novell.com/show_bug.cgi?id=468319
* Pessulus/lockdownapplier.py: add a supports_normal_settings method
* Pessulus/lockdownappliergconf.py: implement this method, and add a
SafeGConfClient class that will simulate a working gconf use when
there's no gconf access. It might be useful in the future.
* Pessulus/main.py: display an error dialog with clear instructions
when the application cannot be used because we have no access to gconf
Modified:
trunk/ChangeLog
trunk/Pessulus/lockdownapplier.py
trunk/Pessulus/lockdownappliergconf.py
trunk/Pessulus/main.py
Modified: trunk/Pessulus/lockdownapplier.py
==============================================================================
--- trunk/Pessulus/lockdownapplier.py (original)
+++ trunk/Pessulus/lockdownapplier.py Sat Jan 31 07:36:08 2009
@@ -22,6 +22,9 @@
def __init__ (self):
raise NotImplementedError
+ def supports_normal_settings (self):
+ raise NotImplementedError
+
def supports_mandatory_settings (self):
raise NotImplementedError
Modified: trunk/Pessulus/lockdownappliergconf.py
==============================================================================
--- trunk/Pessulus/lockdownappliergconf.py (original)
+++ trunk/Pessulus/lockdownappliergconf.py Sat Jan 31 07:36:08 2009
@@ -51,6 +51,73 @@
return False
+# We have this safe class to be able to use gconf methods even if we don't have
+# any gconf access. In the future, we might have non-gconf sources, so it's
+# important to keep the gconf applier working (by being effectively disabled),
+# even when gconf is not working.
+class SafeGConfClient:
+ def __init__ (self):
+ self.client = gconf.client_get_default ()
+
+ try:
+ self.client.get_bool ("/apps/gconf-editor/can_edit_source")
+ self.can_use = True
+ except gobject.GError:
+ self.can_use = False
+
+ def really_works (self):
+ return self.can_use
+
+ def get_schema (self, key):
+ if not self.can_use:
+ return None
+ return self.client.get_schema (key)
+
+ def get_bool (self, key):
+ if not self.can_use:
+ return False
+ return self.client.get_bool (key)
+
+ def set_bool (self, key, value):
+ if not self.can_use:
+ return
+ self.client.set_bool (key, value)
+
+ def get_list (self, key, list_type):
+ if not self.can_use:
+ return []
+ return self.client.get_list (key, list_type)
+
+ def set_list (self, key, list_type, value):
+ if not self.can_use:
+ return
+ self.client.set_list (key, list_type, value)
+
+ def key_is_writable (self, key):
+ if not self.can_use:
+ return False
+ return self.client.key_is_writable (key)
+
+ def notify_add (self, key, handler, data = None):
+ if not self.can_use:
+ return None
+ return self.client.notify_add (key, handler, data)
+
+ def notify_remove (self, monitor):
+ if not self.can_use:
+ return
+ self.client.notify_remove (monitor)
+
+ def add_dir (self, dir, preloadtype):
+ if not self.can_use:
+ return
+ self.client.add_dir (dir, preloadtype)
+
+ def remove_dir (self, dir):
+ if not self.can_use:
+ return
+ self.client.remove_dir (dir)
+
class PessulusLockdownApplierGconf (lockdownapplier.PessulusLockdownApplier):
def __init__ (self):
self.can_edit_mandatory = can_edit_mandatory ()
@@ -60,7 +127,10 @@
engine = gconf.engine_get_for_address (GCONF_MANDATORY_SOURCE)
self.client_mandatory = gconf.client_get_for_engine (engine)
- self.client = gconf.client_get_default ()
+ self.client = SafeGConfClient ()
+
+ def supports_normal_settings (self):
+ return self.client.really_works ()
def supports_mandatory_settings (self):
return self.can_edit_mandatory
Modified: trunk/Pessulus/main.py
==============================================================================
--- trunk/Pessulus/main.py (original)
+++ trunk/Pessulus/main.py Sat Jan 31 07:36:08 2009
@@ -48,6 +48,15 @@
applier = lockdownappliergconf.PessulusLockdownApplierGconf ()
+ if not applier.supports_normal_settings () and not applier.supports_mandatory_settings ():
+ dialog = gtk.MessageDialog (flags = gtk.MESSAGE_ERROR, buttons = gtk.BUTTONS_CLOSE, message_format = _("Cannot contact the GConf server"))
+ dialog.format_secondary_text (_("This usually happens when running this application with 'su' instead of 'su -'.\nIf this is not the case, you can look at the output of the application to get more details."))
+ # this is a dialog with no parent
+ dialog.set_skip_taskbar_hint (False)
+ dialog.set_title (_("Lockdown Editor"))
+ dialog.run ()
+ return
+
dialog = maindialog.PessulusMainDialog (applier, gnome_program = prog)
gtk.main ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]