[gnome-packagekit] Add a GConf key to add program exec names to ignore all DBus requests from. Fixes rh#501023
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-packagekit] Add a GConf key to add program exec names to ignore all DBus requests from. Fixes rh#501023
- Date: Tue, 17 Nov 2009 13:39:32 +0000 (UTC)
commit a8113a8b2abe2900b1ab87f3a79c7f1247e0b2a4
Author: Richard Hughes <richard hughsie com>
Date: Tue Nov 17 12:49:25 2009 +0000
Add a GConf key to add program exec names to ignore all DBus requests from. Fixes rh#501023
data/gnome-packagekit.schemas.in | 12 ++++++++++
src/gpk-common.h | 1 +
src/gpk-dbus-task.c | 45 +++++++++++++++++++++++++++++++++++++-
3 files changed, 57 insertions(+), 1 deletions(-)
---
diff --git a/data/gnome-packagekit.schemas.in b/data/gnome-packagekit.schemas.in
index 6f418fa..bc381e1 100644
--- a/data/gnome-packagekit.schemas.in
+++ b/data/gnome-packagekit.schemas.in
@@ -500,6 +500,18 @@
</schema>
<schema>
+ <key>/schemas/apps/gnome-packagekit/ignored_dbus_requests</key>
+ <applyto>/apps/gnome-packagekit/ignored_dbus_requests</applyto>
+ <owner>gnome-packagekit</owner>
+ <type>string</type>
+ <default>/usr/bin/gnome-terminal,/usr/bin/nm-applet</default>
+ <locale name="C">
+ <short>Programs that should be ignored when they issue session D-Bus requests</short>
+ <long>Programs that should be ignored when they issue session D-Bus requests, separated by commas.</long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/gnome-packagekit/enable_codec_helper</key>
<applyto>/apps/gnome-packagekit/enable_codec_helper</applyto>
<owner>gnome-packagekit</owner>
diff --git a/src/gpk-common.h b/src/gpk-common.h
index e6a6305..c9a0576 100644
--- a/src/gpk-common.h
+++ b/src/gpk-common.h
@@ -42,6 +42,7 @@ G_BEGIN_DECLS
#define GPK_CONF_ENABLE_MIME_TYPE_HELPER "/apps/gnome-packagekit/enable_mime_type_helper"
#define GPK_CONF_ENABLE_CHECK_FIRMWARE "/apps/gnome-packagekit/enable_check_firmware"
#define GPK_CONF_ENABLE_CHECK_HARDWARE "/apps/gnome-packagekit/enable_check_hardware"
+#define GPK_CONF_IGNORED_DBUS_REQUESTS "/apps/gnome-packagekit/ignored_dbus_requests"
#define GPK_CONF_REPO_SHOW_DETAILS "/apps/gnome-packagekit/repo/show_details"
#define GPK_CONF_CONNECTION_USE_MOBILE "/apps/gnome-packagekit/update-icon/connection_use_mobile"
#define GPK_CONF_CONNECTION_USE_WIFI "/apps/gnome-packagekit/update-icon/connection_use_wifi"
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 52bf4e4..2899bcf 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -85,7 +85,8 @@ struct _GpkDbusTaskPrivate
guint timestamp;
gchar *parent_title;
gchar *parent_icon_name;
- PkError *cached_error_code;
+ gchar *exec;
+ PkError *cached_error_code;
gint timeout;
GpkHelperRun *helper_run;
GpkHelperChooser *helper_chooser;
@@ -1926,6 +1927,36 @@ out:
}
/**
+ * gpk_dbus_task_install_check_exec_ignored:
+ **/
+static gboolean
+gpk_dbus_task_install_check_exec_ignored (GpkDbusTask *dtask)
+{
+ gchar *ignored_str;
+ gchar **ignored = NULL;
+ gboolean ret = FALSE;
+ guint i;
+
+ /* check it's not session wide banned in gconf */
+ ignored_str = gconf_client_get_string (dtask->priv->gconf_client, GPK_CONF_IGNORED_DBUS_REQUESTS, NULL);
+ if (ignored_str == NULL)
+ goto out;
+
+ /* check each one */
+ ignored = g_strsplit (ignored_str, ",", -1);
+ for (i=0; ignored[i] != NULL; i++) {
+ if (g_strcmp0 (dtask->priv->exec, ignored[i]) == 0) {
+ ret = TRUE;
+ break;
+ }
+ }
+out:
+ g_free (ignored_str);
+ g_strfreev (ignored);
+ return ret;
+}
+
+/**
* gpk_dbus_task_install_fontconfig_resources:
* @task: a valid #GpkDbusTask instance
* @fonts: font description such as <literal>lang:fr</literal>
@@ -1955,6 +1986,14 @@ gpk_dbus_task_install_fontconfig_resources (GpkDbusTask *dtask, gchar **fonts)
g_return_if_fail (GPK_IS_DBUS_TASK (dtask));
g_return_if_fail (fonts != NULL);
+ /* if this program banned? */
+ ret = gpk_dbus_task_install_check_exec_ignored (dtask);
+ if (!ret) {
+ error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FORBIDDEN, "skipping ignored program: %s", dtask->priv->exec);
+ dbus_g_method_return_error (dtask->priv->context, error_dbus);
+ goto out;
+ }
+
/* get number of fonts to install */
len = g_strv_length (fonts);
@@ -2490,8 +2529,10 @@ gpk_dbus_task_set_exec (GpkDbusTask *dtask, const gchar *exec)
g_return_val_if_fail (GPK_IS_DBUS_TASK (dtask), FALSE);
/* old values invalid */
+ g_free (dtask->priv->exec);
g_free (dtask->priv->parent_title);
g_free (dtask->priv->parent_icon_name);
+ dtask->priv->exec = g_strdup (exec);
dtask->priv->parent_title = NULL;
dtask->priv->parent_icon_name = NULL;
@@ -2560,6 +2601,7 @@ gpk_dbus_task_init (GpkDbusTask *dtask)
dtask->priv->files = NULL;
dtask->priv->parent_window = NULL;
dtask->priv->parent_title = NULL;
+ dtask->priv->exec = NULL;
dtask->priv->parent_icon_name = NULL;
dtask->priv->cached_error_code = NULL;
dtask->priv->context = NULL;
@@ -2634,6 +2676,7 @@ gpk_dbus_task_finalize (GObject *object)
g_free (dtask->priv->parent_title);
g_free (dtask->priv->parent_icon_name);
+ g_free (dtask->priv->exec);
if (dtask->priv->cached_error_code != NULL)
g_object_unref (dtask->priv->cached_error_code);
g_strfreev (dtask->priv->files);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]