diff options
| author | Karel Klíč <kklic@localhost.localdomain> | 2009-10-07 09:03:23 +0200 |
|---|---|---|
| committer | Karel Klíč <kklic@localhost.localdomain> | 2009-10-07 09:03:23 +0200 |
| commit | 5ca01da2ca21ac33dff245ef89af6b12b6a02bed (patch) | |
| tree | c4893f4d4ec026dfb7cdc48967f6765568504189 /src | |
| parent | 01c00832d83b71ac68af257c41dca98e46a34fd7 (diff) | |
| parent | 678a880a9e5aeb0b0742c69125789842fe32b9fc (diff) | |
| download | abrt-5ca01da2ca21ac33dff245ef89af6b12b6a02bed.tar.gz abrt-5ca01da2ca21ac33dff245ef89af6b12b6a02bed.tar.xz abrt-5ca01da2ca21ac33dff245ef89af6b12b6a02bed.zip | |
Merge branch 'master' of git://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src')
| -rw-r--r-- | src/Daemon/CommLayerServerDBus.cpp | 12 | ||||
| -rw-r--r-- | src/Daemon/Makefile.am | 2 | ||||
| -rw-r--r-- | src/Daemon/PluginManager.cpp | 13 | ||||
| -rw-r--r-- | src/Daemon/abrtd.8 (renamed from src/Daemon/abrt.8) | 0 | ||||
| -rw-r--r-- | src/Gui/ABRTExceptions.py | 11 | ||||
| -rw-r--r-- | src/Gui/ABRTPlugin.py | 52 | ||||
| -rw-r--r-- | src/Gui/CCDBusBackend.py | 2 | ||||
| -rw-r--r-- | src/Gui/CCMainWindow.py | 3 | ||||
| -rw-r--r-- | src/Gui/CCReport.py | 1 | ||||
| -rw-r--r-- | src/Gui/ConfBackend.py | 62 | ||||
| -rw-r--r-- | src/Gui/Makefile.am | 2 | ||||
| -rw-r--r-- | src/Gui/PluginList.py | 33 | ||||
| -rw-r--r-- | src/Gui/PluginSettingsUI.py | 7 | ||||
| -rw-r--r-- | src/Gui/PluginsSettingsDialog.py | 3 | ||||
| -rw-r--r-- | src/Gui/SettingsDialog.py | 7 |
15 files changed, 151 insertions, 59 deletions
diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index 22dc2e6..1085d80 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.cpp @@ -253,14 +253,19 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply) } + const char * sender = dbus_message_get_sender(call); if (!user_conf_data.empty()) { -#if DEBUG + std::string PluginName; + map_plugin_settings_t plugin_settings; map_map_string_t::const_iterator it_user_conf_data; for (it_user_conf_data = user_conf_data.begin(); it_user_conf_data != user_conf_data.end(); it_user_conf_data++) { map_string_t::const_iterator it_plugin_config; map_string_t plugin_config = it_user_conf_data->second; + PluginName = it_user_conf_data->first; + plugin_settings = it_user_conf_data->second; +#if DEBUG std::cout << "plugin name: " << it_user_conf_data->first; for (it_plugin_config = it_user_conf_data->second.begin(); it_plugin_config != it_user_conf_data->second.end(); @@ -268,10 +273,9 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply) { std::cout << " key: " << it_plugin_config->first << " value: " << it_plugin_config->second << std::endl; } - } #endif - const char * sender = dbus_message_get_sender(call); - SetSettings(user_conf_data, sender); + g_pPluginManager->SetPluginSettings(PluginName, sender, plugin_settings); + } } //so far, user_conf_data is unused diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am index b41f8ec..29c7f1b 100644 --- a/src/Daemon/Makefile.am +++ b/src/Daemon/Makefile.am @@ -42,7 +42,7 @@ dist_polkitconf_DATA = org.fedoraproject.abrt.policy comredhatabrtservicedir = ${datadir}/dbus-1/system-services dist_comredhatabrtservice_DATA = com.redhat.abrt.service -man_MANS = abrt.8 abrt.conf.5 +man_MANS = abrtd.8 abrt.conf.5 EXTRA_DIST = $(man_MANS) DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp index 4c1dae5..bd5727e 100644 --- a/src/Daemon/PluginManager.cpp +++ b/src/Daemon/PluginManager.cpp @@ -420,12 +420,18 @@ void CPluginManager::SetPluginSettings(const std::string& pName, return; } + /** we don't want to save it from daemon if it's running under root + but wi might get back to this once we make the daemon to not run + with root privileges + */ + /* SavePluginSettings(confPath, pSettings); if (chown(confPath.c_str(), uid, gid) == -1) { perror_msg("Can't change '%s' ownership to %u:%u", confPath.c_str(), (int)uid, (int)gid); return; } + */ } } } @@ -443,7 +449,11 @@ map_plugin_settings_t CPluginManager::GetPluginSettings(const std::string& pName if (plugin != m_mapPlugins.end()) { ret = plugin->second->GetSettings(); - + /** we don't want to load it from daemon if it's running under root + but wi might get back to this once we make the daemon to not run + with root privileges + */ + /* if (abrt_plugin->second->GetType() == REPORTER) { std::string home = get_home_dir(atoi(pUID.c_str())); @@ -452,6 +462,7 @@ map_plugin_settings_t CPluginManager::GetPluginSettings(const std::string& pName LoadPluginSettings(home + "/.abrt/" + pName + "."PLUGINS_CONF_EXTENSION, ret); } } + */ return ret; } } diff --git a/src/Daemon/abrt.8 b/src/Daemon/abrtd.8 index b106041..b106041 100644 --- a/src/Daemon/abrt.8 +++ b/src/Daemon/abrtd.8 diff --git a/src/Gui/ABRTExceptions.py b/src/Gui/ABRTExceptions.py index 791654f..3049638 100644 --- a/src/Gui/ABRTExceptions.py +++ b/src/Gui/ABRTExceptions.py @@ -2,14 +2,23 @@ from abrt_utils import _ class IsRunning(Exception): def __init__(self): + Exception.__init__(self) self.what = _("Another client is already running, trying to wake it.") def __str__(self): return self.what class WrongData(Exception): def __init__(self): + Exception.__init__(self) self.what = _("Got unexpected data from daemon (is the database properly updated?).") 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 181126a..8d687f8 100644 --- a/src/Gui/ABRTPlugin.py +++ b/src/Gui/ABRTPlugin.py @@ -16,27 +16,33 @@ from ConfBackend import ConfBackendGnomeKeyring class PluginSettings(dict): def __init__(self): dict.__init__(self) - #print "Init plugin settings" + self.conf = ConfBackendGnomeKeyring() - def __init__(self, settings_dict): - dict.__init__(self) - for key in settings_dict.keys(): - self[key] = settings_dict[key] - def check(self): - if "Password" in self.keys(): - # password is missing - if not self["Password"]: - return False + for key in ["Password", "Login"]: + if key in self.keys(): + # some of the required keys is missing + if not self[key]: + return False # settings are OK return True - - def load(self, name): - print "load:", name - + + def load(self, name, default_settings): + # load settings from daemon + 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]) + def save(self, name): - print "save: ", name - + self.conf.save(name, self) + class PluginInfo(): """Class to represent common plugin info""" types = {"Analyzer":_("Analyzer plugins"), @@ -57,7 +63,7 @@ class PluginInfo(): self.Type = None self.Email = None self.Description = None - self.Settings = PluginSettings({}) + self.Settings = PluginSettings() def getName(self): return self.Name @@ -76,12 +82,12 @@ class PluginInfo(): def __getitem__(self, item): return self.__dict__[item] - - def load_settings(self): + + def load_settings(self, default_settings): if self.Name: - self.Settings.load(self.Name) + self.Settings.load(self.Name, default_settings) else: - print "plugin name is not set, can't load it's settings" - + print _("Plugin name is not set, can't load it's settings") + def save_settings(self): - self.Settings.save(self.Name) + self.Settings.save(str(self.Name)) diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py index 71a50e2..f1ab443 100644 --- a/src/Gui/CCDBusBackend.py +++ b/src/Gui/CCDBusBackend.py @@ -176,7 +176,7 @@ class DBusManager(gobject.GObject): def Report(self, report, reporters_settings = None): # map < Plguin_name vec <status, message> > - self.cc.Report(report,reporters_settings, reply_handler=self.report_done, error_handler=self.error_handler_cb, timeout=60) + self.cc.Report(report, reporters_settings, reply_handler=self.report_done, error_handler=self.error_handler_cb, timeout=60) def DeleteDebugDump(self,UUID): return self.cc.DeleteDebugDump(UUID) diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index f8a2054..1b4848d 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -126,7 +126,7 @@ class MainWindow(): # load data #self.load() - self.pluginlist = getPluginInfoList(self.ccdaemon) + self.pluginlist = None def on_daemon_state_changed_cb(self, widget, state): if state == "up": @@ -299,6 +299,7 @@ class MainWindow(): self.pBarWindow.show_all() self.timer = gobject.timeout_add(100, self.progress_update_cb) reporters_settings = {} + self.pluginlist = getPluginInfoList(self.ccdaemon, refresh=True) for plugin in self.pluginlist.getReporterPlugins(): reporters_settings[str(plugin)] = plugin.Settings self.ccdaemon.Report(result, reporters_settings) diff --git a/src/Gui/CCReport.py b/src/Gui/CCReport.py index 66de1e9..90c8a3b 100644 --- a/src/Gui/CCReport.py +++ b/src/Gui/CCReport.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from datetime import datetime class Report(): """Class for mapping the report to pyhon object""" diff --git a/src/Gui/ConfBackend.py b/src/Gui/ConfBackend.py new file mode 100644 index 0000000..e0f6434 --- /dev/null +++ b/src/Gui/ConfBackend.py @@ -0,0 +1,62 @@ +from ABRTExceptions import ConfBackendInitError +from abrt_utils import _ + +#FIXME: add some backend factory + +try: + import gnomekeyring as gkey +except ImportError, e: + gkey = None + +class ConfBackend(object): + def __init__(self): + pass + + def save(self, name, settings): + """ Default save method has to be implemented in derived class """ + raise NotImplementedError + + def load(self, name): + """ Default load method has to be implemented in derived class """ + raise NotImplementedError + + +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")) + + def save(self, name, settings): + settings_tmp = settings.copy() + settings_tmp["AbrtPluginInfo"] = name + password = "" + + if "Password" in settings_tmp: + password = settings_tmp["Password"] + del settings_tmp["Password"] + gkey.item_create_sync(self.default_key_ring, + gkey.ITEM_GENERIC_SECRET, + "abrt:%s" % name, + settings_tmp, + password, + True) + + def load(self, name): + item_list = None + try: + item_list = gkey.find_items_sync(gkey.ITEM_GENERIC_SECRET, {"AbrtPluginInfo":str(name)}) + except gkey.NoMatchError, ex: + # nothing found + pass + + if item_list: + retval = item_list[0].attributes.copy() + retval["Password"] = item_list[0].secret + return retval + else: + return {} + #for i in item_list: + # for attr in i.attributes: + # print attr, i.attributes[attr] diff --git a/src/Gui/Makefile.am b/src/Gui/Makefile.am index 66317f9..a3993fa 100644 --- a/src/Gui/Makefile.am +++ b/src/Gui/Makefile.am @@ -6,7 +6,7 @@ PYTHON_FILES = CCDBusBackend.py CCDumpList.py CCDump.py CC_gui_functions.py \ CCReporterDialog.py CCReport.py abrt_utils.py \ CCMainWindow.py CellRenderers.py ABRTExceptions.py \ SettingsDialog.py ABRTPlugin.py PluginList.py PluginSettingsUI.py \ - PluginsSettingsDialog.py + PluginsSettingsDialog.py ConfBackend.py GLADE_FILES = ccgui.glade report.glade settings.glade dialogs.glade diff --git a/src/Gui/PluginList.py b/src/Gui/PluginList.py index 13c9537..e57040d 100644 --- a/src/Gui/PluginList.py +++ b/src/Gui/PluginList.py @@ -11,26 +11,19 @@ class PluginInfoList(list): def load(self): if self.dm: #print "loading PluginList" - try: - rows = self.dm.getPluginsInfo() - #print rows - for row in rows: - entry = PluginInfo() - for column in row: - #print "PluginInfoList adding %s:%s" % (column,row[column]) - entry.__dict__[column] = row[column] - if entry.Enabled == "yes": - #print ">>%s<<" % entry - entry.Settings = PluginSettings(self.dm.getPluginSettings(str(entry))) - #for i in entry.Settings.keys(): - # print "%s: %s" % (i, entry.Settings[i]) - #else: - # print "%s is disabled" % entry - self.append(entry) - self.ddict[entry.getName()] = entry - except Exception, e: - print e - return + rows = self.dm.getPluginsInfo() + #print rows + for row in rows: + entry = PluginInfo() + for column in row: + #print "PluginInfoList adding %s:%s" % (column,row[column]) + entry.__dict__[column] = row[column] + if entry.Enabled == "yes": + #entry.Settings = PluginSettings(self.dm.getPluginSettings(str(entry))) + default_settings = self.dm.getPluginSettings(str(entry)) + entry.load_settings(default_settings) + self.append(entry) + self.ddict[entry.getName()] = entry else: print "db == None!" diff --git a/src/Gui/PluginSettingsUI.py b/src/Gui/PluginSettingsUI.py index 02c0317..ae5b64d 100644 --- a/src/Gui/PluginSettingsUI.py +++ b/src/Gui/PluginSettingsUI.py @@ -1,7 +1,8 @@ import gtk from abrt_utils import _ + class PluginSettingsUI(gtk.Dialog): - def __init__(self, pluginfo): + def __init__(self, pluginfo, parent=None): #print "Init PluginSettingsUI" gtk.Dialog.__init__(self) self.plugin_name = pluginfo.Name @@ -16,6 +17,8 @@ class PluginSettingsUI(gtk.Dialog): if not self.dialog: raise Exception(_("Can't find PluginDialog widget in UI description!")) self.dialog.set_title("%s" % pluginfo.getName()) + if parent: + self.dialog.set_transient_for(parent) else: # we shouldn't get here, but just to be safe no_ui_label = gtk.Label(_("No UI for plugin %s" % pluginfo)) @@ -27,7 +30,7 @@ class PluginSettingsUI(gtk.Dialog): if self.pluginfo.Enabled == "yes": if self.Settings: #print "Hydrating %s" % self.plugin_name - for key,value in self.Settings.iteritems(): + for key, value in self.Settings.iteritems(): #print "%s:%s" % (key,value) widget = self.plugin_gui.get_object("conf_%s" % key) if type(widget) == gtk.Entry: diff --git a/src/Gui/PluginsSettingsDialog.py b/src/Gui/PluginsSettingsDialog.py index a6420b1..a346455 100644 --- a/src/Gui/PluginsSettingsDialog.py +++ b/src/Gui/PluginsSettingsDialog.py @@ -130,9 +130,10 @@ class PluginsSettingsDialog: ui.dehydrate() if pluginfo.Settings: try: + pluginfo.save_settings() self.ccdaemon.setPluginSettings(pluginfo.getName(), pluginfo.Settings) except Exception, e: - gui_error_message(_("Can't save plugin settings:\n %s", e)) + gui_error_message(_("Can't save plugin settings:\n %s" % e)) #for key, val in pluginfo.Settings.iteritems(): # print "%s:%s" % (key, val) elif response == gtk.RESPONSE_CANCEL: diff --git a/src/Gui/SettingsDialog.py b/src/Gui/SettingsDialog.py index 4d85cd7..b3af501 100644 --- a/src/Gui/SettingsDialog.py +++ b/src/Gui/SettingsDialog.py @@ -76,7 +76,7 @@ class SettingsDialog: self.pluginlist = getPluginInfoList(self.ccdaemon, refresh=True) except Exception, e: print "SettingsDialog: ", e - + ## hydrate cron jobs: for key,val in self.settings["Cron"].iteritems(): # actionas are separated by ',' @@ -91,6 +91,9 @@ class SettingsDialog: self.settings["Cron"][key].remove(plugin.getName()) # hydrate common common = self.settings["Common"] + # ensure that all expected keys exist: + if "OpenGPGCheck" not in common: + common["OpenGPGCheck"] = "no" # check unsigned pkgs too ## gpgcheck self.builder.get_object("cbOpenGPGCheck").set_active(common["OpenGPGCheck"] == 'yes') ## database @@ -112,7 +115,7 @@ class SettingsDialog: AnalyzerActionsAndReporters = self.settings["AnalyzerActionsAndReporters"] for analplugin in self.pluginlist.getAnalyzerPlugins(): it = self.analyzerPluginsListStore.append([analplugin.getName(), analplugin]) - if AnalyzerActionsAndReporters.has_key(analplugin.getName()): + if analplugin.getName() in AnalyzerActionsAndReporters: action = (AnalyzerActionsAndReporters[analplugin.getName()], it) self.add_AnalyzerAction(action) |
