diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-10-22 16:56:00 +0200 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-10-22 16:56:00 +0200 |
commit | 6c0ebcba31940fe8b622eafeb7aa96e5209f5738 (patch) | |
tree | a6c74759633b1aa914258374df2299c18ab8661a /src/Gui | |
parent | d478476d72ae923db3b843e921254383bd4b1cd6 (diff) | |
download | abrt-6c0ebcba31940fe8b622eafeb7aa96e5209f5738.tar.gz abrt-6c0ebcba31940fe8b622eafeb7aa96e5209f5738.tar.xz abrt-6c0ebcba31940fe8b622eafeb7aa96e5209f5738.zip |
GUI: fixed problem with keyring when run after "su -"
- keyring daemon works only for the session owner so, if user "su"
to other user abrt will fail to read/write any settings and will load
the defaults, user still can change the settings and use them, but
it will be lost when he quit the gui
Diffstat (limited to 'src/Gui')
-rw-r--r-- | src/Gui/ABRTExceptions.py | 8 | ||||
-rw-r--r-- | src/Gui/ABRTPlugin.py | 27 | ||||
-rw-r--r-- | src/Gui/ConfBackend.py | 21 |
3 files changed, 34 insertions, 22 deletions
diff --git a/src/Gui/ABRTExceptions.py b/src/Gui/ABRTExceptions.py index 0d357a30..c4d6b594 100644 --- a/src/Gui/ABRTExceptions.py +++ b/src/Gui/ABRTExceptions.py @@ -14,11 +14,3 @@ class WrongData(Exception): def __str__(self): return self.what - -class ConfBackendInitError(Exception): - def __init__(self, msg): - Exception.__init__(self) - self.what = msg - - def __str__(self): - return self.what diff --git a/src/Gui/ABRTPlugin.py b/src/Gui/ABRTPlugin.py index 8d687f83..8483be44 100644 --- a/src/Gui/ABRTPlugin.py +++ b/src/Gui/ABRTPlugin.py @@ -11,12 +11,17 @@ Email Description """ from abrt_utils import _ -from ConfBackend import ConfBackendGnomeKeyring +from ConfBackend import ConfBackendGnomeKeyring, ConfBackendInitError class PluginSettings(dict): def __init__(self): dict.__init__(self) - self.conf = ConfBackendGnomeKeyring() + self.conf = None + try: + self.conf = ConfBackendGnomeKeyring() + except ConfBackendInitError, e: + print e + pass def check(self): for key in ["Password", "Login"]: @@ -32,16 +37,18 @@ class PluginSettings(dict): for key in default_settings.keys(): self[str(key)] = str(default_settings[key]) - settings = self.conf.load(name) - # overwrite defaluts with user setting - for key in settings.keys(): - # only rewrite keys needed by the plugin - # e.g we don't want a pass field for logger - if key in default_settings.keys(): - self[str(key)] = str(settings[key]) + if self.conf: + settings = self.conf.load(name) + # overwrite defaluts with user setting + for key in settings.keys(): + # only rewrite keys needed by the plugin + # e.g we don't want a pass field for logger + if key in default_settings.keys(): + self[str(key)] = str(settings[key]) def save(self, name): - self.conf.save(name, self) + if self.conf: + self.conf.save(name, self) class PluginInfo(): """Class to represent common plugin info""" diff --git a/src/Gui/ConfBackend.py b/src/Gui/ConfBackend.py index eb94b87b..db25984b 100644 --- a/src/Gui/ConfBackend.py +++ b/src/Gui/ConfBackend.py @@ -1,4 +1,3 @@ -from ABRTExceptions import ConfBackendInitError from abrt_utils import _ #FIXME: add some backend factory @@ -8,6 +7,15 @@ try: except ImportError, e: gkey = None +# Exceptions +class ConfBackendInitError(Exception): + def __init__(self, msg): + Exception.__init__(self) + self.what = msg + + def __str__(self): + return self.what + class ConfBackend(object): def __init__(self): pass @@ -24,9 +32,14 @@ class ConfBackend(object): class ConfBackendGnomeKeyring(ConfBackend): def __init__(self): ConfBackend.__init__(self) - self.default_key_ring = gkey.get_default_keyring_sync() if not gkey.is_available(): raise ConfBackendInitError(_("Can't connect do Gnome Keyring daemon")) + try: + self.default_key_ring = gkey.get_default_keyring_sync() + except: + # could happen if keyring daemon is running, but we run gui under + # user who is not owner is the running session - using su + raise ConfBackendInitError(_("Can't get default keyring")) def save(self, name, settings): settings_tmp = settings.copy() @@ -36,7 +49,7 @@ class ConfBackendGnomeKeyring(ConfBackend): item_list = [] try: item_list = gkey.find_items_sync(gkey.ITEM_GENERIC_SECRET, {"AbrtPluginInfo":str(name)}) - except gkey.NoMatchError, ex: + except gkey.NoMatchError: # nothing found pass @@ -59,7 +72,7 @@ class ConfBackendGnomeKeyring(ConfBackend): item_list = None try: item_list = gkey.find_items_sync(gkey.ITEM_GENERIC_SECRET, {"AbrtPluginInfo":str(name)}) - except gkey.NoMatchError, ex: + except gkey.NoMatchError: # nothing found pass |