[PackageKit-commit] packagekit: Branch 'master' - 9 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Mon Nov 24 09:54:12 PST 2008
RELEASE | 16
backends/dummy/pk-backend-dummy.c | 3
configure.ac | 4
lib/packagekit-glib/pk-client.c | 261 +++++----
lib/packagekit-glib/pk-desktop.c | 2
policy/org.freedesktop.packagekit.policy.in | 14
src/org.freedesktop.PackageKit.Transaction.xml | 2
src/org.freedesktop.PackageKit.xml | 1
src/pk-engine.c | 17
src/pk-engine.h | 5
src/pk-security-polkit.c | 3
src/pk-security.h | 4
src/pk-transaction-list.c | 15
src/pk-transaction-list.h | 3
src/pk-transaction.c | 716 +++++++++++++------------
src/pk-transaction.h | 12
16 files changed, 596 insertions(+), 482 deletions(-)
New commits:
commit dce0f2a838b2f9922460aa535094f76925172549
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Nov 24 17:51:22 2008 +0000
bugfix: Check the sender for SetLocale and the UID for Cancel
For a long time other users were able to cancel each others jobs.
On a multiuser workstation this is not a good idea and is now
controlled using PolicyKit.
Another issue was that a different connection could set the locale
from the connection that asked for the TID. We should always verify
that the sender is the same, as this prevents a local DOS on a
multiuser system.
diff --git a/src/org.freedesktop.PackageKit.Transaction.xml b/src/org.freedesktop.PackageKit.Transaction.xml
index 8b4917f..d87b893 100644
--- a/src/org.freedesktop.PackageKit.Transaction.xml
+++ b/src/org.freedesktop.PackageKit.Transaction.xml
@@ -15,6 +15,7 @@
<!--*****************************************************************************************-->
<method name="SetLocale">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<doc:doc>
<doc:description>
<doc:para>
@@ -59,6 +60,7 @@
<!--*****************************************************************************************-->
<method name="Cancel">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<doc:doc>
<doc:description>
<doc:para>
diff --git a/src/org.freedesktop.PackageKit.xml b/src/org.freedesktop.PackageKit.xml
index 6aa07d3..3e27f3a 100644
--- a/src/org.freedesktop.PackageKit.xml
+++ b/src/org.freedesktop.PackageKit.xml
@@ -124,6 +124,7 @@
<!--*****************************************************************************************-->
<method name="GetTid">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<doc:doc>
<doc:description>
<doc:para>
diff --git a/src/pk-engine.c b/src/pk-engine.c
index d3eda9f..189f331 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -252,26 +252,29 @@ pk_engine_finished_cb (PkBackend *backend, PkExitEnum exit, PkEngine *engine)
/**
* pk_engine_get_tid:
**/
-gboolean
-pk_engine_get_tid (PkEngine *engine, gchar **tid, GError **error)
+void
+pk_engine_get_tid (PkEngine *engine, DBusGMethodInvocation *context)
{
gchar *new_tid;
gboolean ret;
+ gchar *sender = NULL;
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (PK_IS_ENGINE (engine));
egg_debug ("GetTid method called");
+ sender = dbus_g_method_get_sender (context);
new_tid = pk_transaction_id_generate ();
- ret = pk_transaction_list_create (engine->priv->transaction_list, new_tid);
+ ret = pk_transaction_list_create (engine->priv->transaction_list, new_tid, sender);
egg_debug ("sending tid: '%s'", new_tid);
- *tid = g_strdup (new_tid);
- g_free (new_tid);
/* reset the timer */
pk_engine_reset_timer (engine);
- return TRUE;
+ /* return TID */
+ dbus_g_method_return (context, new_tid);
+ g_free (new_tid);
+ g_free (sender);
}
/**
diff --git a/src/pk-engine.h b/src/pk-engine.h
index b4ebce2..58bb864 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -89,9 +89,8 @@ gboolean pk_engine_get_groups (PkEngine *engine,
gboolean pk_engine_get_mime_types (PkEngine *engine,
gchar **types,
GError **error);
-gboolean pk_engine_get_tid (PkEngine *engine,
- gchar **tid,
- GError **error);
+void pk_engine_get_tid (PkEngine *engine,
+ DBusGMethodInvocation *context);
gboolean pk_engine_get_network_state (PkEngine *engine,
gchar **state,
GError **error);
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 897d84f..64d5ca1 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -353,7 +353,7 @@ pk_transaction_list_no_commit_cb (PkTransactionItem *item)
* pk_transaction_list_create:
**/
gboolean
-pk_transaction_list_create (PkTransactionList *tlist, const gchar *tid)
+pk_transaction_list_create (PkTransactionList *tlist, const gchar *tid, const gchar *sender)
{
gboolean ret;
PkTransactionItem *item;
@@ -395,6 +395,11 @@ pk_transaction_list_create (PkTransactionList *tlist, const gchar *tid)
if (!ret)
egg_error ("failed to set TID");
+ /* set the DBUS sender on the transaction */
+ ret = pk_transaction_set_sender (item->transaction, sender);
+ if (!ret)
+ egg_error ("failed to set sender");
+
/* put on the bus */
dbus_g_object_type_install_info (PK_TYPE_TRANSACTION, &dbus_glib_pk_transaction_object_info);
dbus_g_connection_register_g_object (connection, item->tid, G_OBJECT (item->transaction));
@@ -772,7 +777,7 @@ pk_transaction_list_test_get_item (PkTransactionList *tlist)
tid = pk_transaction_id_generate ();
/* create PkTransaction instance */
- pk_transaction_list_create (tlist, tid);
+ pk_transaction_list_create (tlist, tid, ":0");
item = pk_transaction_list_get_from_tid (tlist, tid);
g_free (tid);
@@ -815,7 +820,7 @@ pk_transaction_list_test (EggTest *test)
/************************************************************/
egg_test_title (test, "create a transaction object");
- ret = pk_transaction_list_create (tlist, tid);
+ ret = pk_transaction_list_create (tlist, tid, ":0");
if (ret)
egg_test_success (test, "created transaction %s", tid);
else
@@ -859,7 +864,7 @@ pk_transaction_list_test (EggTest *test)
/************************************************************/
egg_test_title (test, "add again the same tid (should fail)");
- ret = pk_transaction_list_create (tlist, tid);
+ ret = pk_transaction_list_create (tlist, tid, ":0");
if (!ret)
egg_test_success (test, NULL);
else
@@ -887,7 +892,7 @@ pk_transaction_list_test (EggTest *test)
/************************************************************/
egg_test_title (test, "create another item");
- ret = pk_transaction_list_create (tlist, tid);
+ ret = pk_transaction_list_create (tlist, tid, ":0");
if (ret)
egg_test_success (test, "created transaction %s", tid);
else
diff --git a/src/pk-transaction-list.h b/src/pk-transaction-list.h
index ee58511..c6f1ebd 100644
--- a/src/pk-transaction-list.h
+++ b/src/pk-transaction-list.h
@@ -55,7 +55,8 @@ GType pk_transaction_list_get_type (void) G_GNUC_CONST;
PkTransactionList *pk_transaction_list_new (void);
gboolean pk_transaction_list_create (PkTransactionList *tlist,
- const gchar *tid);
+ const gchar *tid,
+ const gchar *sender);
gboolean pk_transaction_list_remove (PkTransactionList *tlist,
const gchar *tid);
gboolean pk_transaction_list_commit (PkTransactionList *tlist,
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 282b38d..ddcccfd 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -87,6 +87,7 @@ struct PkTransactionPrivate
gboolean emit_eula_required;
gboolean emit_signature_required;
gchar *locale;
+ guint uid;
EggDbusMonitor *monitor;
PkBackend *backend;
PkInhibit *inhibit;
@@ -101,8 +102,8 @@ struct PkTransactionPrivate
/* needed for gui coldplugging */
gchar *last_package_id;
- gchar *dbus_name;
gchar *tid;
+ gchar *sender;
PkPackageList *package_list;
PkTransactionList *transaction_list;
PkTransactionDb *transaction_db;
@@ -238,26 +239,6 @@ pk_transaction_get_runtime (PkTransaction *transaction)
}
/**
- * pk_transaction_set_dbus_name:
- */
-gboolean
-pk_transaction_set_dbus_name (PkTransaction *transaction, const gchar *dbus_name)
-{
- g_return_val_if_fail (PK_IS_TRANSACTION (transaction), FALSE);
- g_return_val_if_fail (transaction->priv->tid != NULL, FALSE);
- g_return_val_if_fail (dbus_name != NULL, FALSE);
-
- if (transaction->priv->dbus_name != NULL) {
- egg_warning ("you can't assign more than once!");
- return FALSE;
- }
- transaction->priv->dbus_name = g_strdup (dbus_name);
- egg_debug ("assigning %s to %p", dbus_name, transaction);
- egg_dbus_monitor_assign (transaction->priv->monitor, EGG_DBUS_MONITOR_SYSTEM, dbus_name);
- return TRUE;
-}
-
-/**
* pk_transaction_set_role:
* We should only set this when we are creating a manual cache
**/
@@ -554,7 +535,6 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit, PkTransaction *
guint i, length;
PkPackageList *list;
const PkPackageObj *obj;
- guint uid = PK_SECURITY_UID_INVALID;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -683,10 +663,6 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit, PkTransaction *
time = pk_transaction_get_runtime (transaction);
egg_debug ("backend was running for %i ms", time);
- /* get user for logging */
- if (transaction->priv->caller != NULL)
- uid = pk_security_get_uid (transaction->priv->security, transaction->priv->caller);
-
/* add to the database if we are going to log it */
if (transaction->priv->role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
transaction->priv->role == PK_ROLE_ENUM_UPDATE_PACKAGES ||
@@ -708,7 +684,8 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit, PkTransaction *
obj->info == PK_INFO_ENUM_UPDATING) {
packages = pk_package_id_to_string (obj->id);
pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_INFO, "in %s for %s package %s was %s for uid %i",
- transaction->priv->tid, pk_role_enum_to_text (transaction->priv->role), packages, pk_info_enum_to_text (obj->info), uid);
+ transaction->priv->tid, pk_role_enum_to_text (transaction->priv->role),
+ packages, pk_info_enum_to_text (obj->info), transaction->priv->uid);
g_free (packages);
}
}
@@ -734,9 +711,10 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit, PkTransaction *
pk_inhibit_remove (transaction->priv->inhibit, transaction);
/* report to syslog */
- if (uid != G_MAXUINT)
+ if (transaction->priv->uid != PK_SECURITY_UID_INVALID)
pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_INFO, "%s transaction %s from uid %i finished with %s after %ims",
- pk_role_enum_to_text (transaction->priv->role), transaction->priv->tid, uid, pk_exit_enum_to_text (exit), time);
+ pk_role_enum_to_text (transaction->priv->role), transaction->priv->tid,
+ transaction->priv->uid, pk_exit_enum_to_text (exit), time);
else
pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_INFO, "%s transaction %s finished with %s after %ims",
pk_role_enum_to_text (transaction->priv->role), transaction->priv->tid, pk_exit_enum_to_text (exit), time);
@@ -1211,6 +1189,23 @@ pk_transaction_set_tid (PkTransaction *transaction, const gchar *tid)
}
/**
+ * pk_transaction_set_sender:
+ */
+gboolean
+pk_transaction_set_sender (PkTransaction *transaction, const gchar *sender)
+{
+ g_return_val_if_fail (PK_IS_TRANSACTION (transaction), FALSE);
+ g_return_val_if_fail (sender != NULL, FALSE);
+ g_return_val_if_fail (transaction->priv->sender == NULL, FALSE);
+
+ egg_debug ("setting sender to %s", sender);
+ transaction->priv->sender = g_strdup (sender);
+ egg_dbus_monitor_assign (transaction->priv->monitor, EGG_DBUS_MONITOR_SYSTEM, sender);
+
+ return TRUE;
+}
+
+/**
* pk_transaction_release_tid:
**/
static gboolean
@@ -1231,7 +1226,6 @@ G_GNUC_WARN_UNUSED_RESULT static gboolean
pk_transaction_commit (PkTransaction *transaction)
{
gboolean ret;
- guint uid;
gchar *cmdline;
g_return_val_if_fail (PK_IS_TRANSACTION (transaction), FALSE);
@@ -1246,6 +1240,10 @@ pk_transaction_commit (PkTransaction *transaction)
return FALSE;
}
+ /* save uid */
+ if (transaction->priv->caller != NULL)
+ transaction->priv->uid = pk_security_get_uid (transaction->priv->security, transaction->priv->caller);
+
/* only save into the database for useful stuff */
if (transaction->priv->role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
transaction->priv->role == PK_ROLE_ENUM_REMOVE_PACKAGES ||
@@ -1259,8 +1257,7 @@ pk_transaction_commit (PkTransaction *transaction)
pk_transaction_db_set_role (transaction->priv->transaction_db, transaction->priv->tid, transaction->priv->role);
/* save uid */
- uid = pk_security_get_uid (transaction->priv->security, transaction->priv->caller);
- pk_transaction_db_set_uid (transaction->priv->transaction_db, transaction->priv->tid, uid);
+ pk_transaction_db_set_uid (transaction->priv->transaction_db, transaction->priv->tid, transaction->priv->uid);
/* save cmdline */
cmdline = pk_security_get_cmdline (transaction->priv->security, transaction->priv->caller);
@@ -1268,7 +1265,7 @@ pk_transaction_commit (PkTransaction *transaction)
/* report to syslog */
pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_INFO, "new %s transaction %s scheduled from uid %i",
- pk_role_enum_to_text (transaction->priv->role), transaction->priv->tid, uid);
+ pk_role_enum_to_text (transaction->priv->role), transaction->priv->tid, transaction->priv->uid);
g_free (cmdline);
}
@@ -1393,13 +1390,13 @@ pk_transaction_action_is_allowed (PkTransaction *transaction, gboolean trusted,
gboolean ret;
gchar *error_detail;
- g_return_val_if_fail (transaction->priv->dbus_name != NULL, FALSE);
+ g_return_val_if_fail (transaction->priv->sender != NULL, FALSE);
/* get caller */
- transaction->priv->caller = pk_security_caller_new_from_sender (transaction->priv->security, transaction->priv->dbus_name);
+ transaction->priv->caller = pk_security_caller_new_from_sender (transaction->priv->security, transaction->priv->sender);
if (transaction->priv->caller == NULL) {
*error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_REFUSED_BY_POLICY,
- "caller %s not found", transaction->priv->dbus_name);
+ "caller %s not found", transaction->priv->sender);
return FALSE;
}
@@ -1421,6 +1418,39 @@ pk_transaction_priv_get_role (PkTransaction *transaction)
}
/**
+ * pk_transaction_verify_sender:
+ *
+ * Verify caller of this method matches the one that got the Tid
+ **/
+static gboolean
+pk_transaction_verify_sender (PkTransaction *transaction, DBusGMethodInvocation *context, GError **error)
+{
+ gboolean ret = FALSE;
+ gchar *sender = NULL;
+
+ g_return_val_if_fail (transaction->priv->sender != NULL, FALSE);
+
+ /* not set inside the test suite */
+ if (context == NULL) {
+ *error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_REFUSED_BY_POLICY,
+ "context not available for sender %s", transaction->priv->sender);
+ goto out;
+ }
+
+ /* check is the same as the sender that did GetTid */
+ sender = dbus_g_method_get_sender (context);
+ ret = egg_strequal (transaction->priv->sender, sender);
+ if (!ret) {
+ *error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_REFUSED_BY_POLICY,
+ "sender does not match (%s vs %s)", sender, transaction->priv->sender);
+ goto out;
+ }
+out:
+ g_free (sender);
+ return ret;
+}
+
+/**
* pk_transaction_accept_eula:
*
* This should be called when a eula_id needs to be added into an internal db.
@@ -1430,11 +1460,18 @@ pk_transaction_accept_eula (PkTransaction *transaction, const gchar *eula_id, DB
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check for sanity */
ret = pk_strvalidate (eula_id);
if (!ret) {
@@ -1445,14 +1482,6 @@ pk_transaction_accept_eula (PkTransaction *transaction, const gchar *eula_id, DB
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* check if the action is allowed from this client - if not, set an error */
ret = pk_transaction_action_is_allowed (transaction, FALSE, PK_ROLE_ENUM_ACCEPT_EULA, &error);
if (!ret) {
@@ -1482,49 +1511,89 @@ pk_transaction_accept_eula (PkTransaction *transaction, const gchar *eula_id, DB
/**
* pk_transaction_cancel:
**/
-gboolean
-pk_transaction_cancel (PkTransaction *transaction, GError **error)
+void
+pk_transaction_cancel (PkTransaction *transaction, DBusGMethodInvocation *context)
{
- g_return_val_if_fail (PK_IS_TRANSACTION (transaction), FALSE);
- g_return_val_if_fail (transaction->priv->tid != NULL, FALSE);
+ gboolean ret;
+ GError *error = NULL;
+ gchar *sender;
+ guint uid;
+ PkSecurityCaller *caller;
+
+ g_return_if_fail (PK_IS_TRANSACTION (transaction));
+ g_return_if_fail (transaction->priv->tid != NULL);
egg_debug ("Cancel method called on %s", transaction->priv->tid);
- /* if it's never been run, just remove this transaction from the list */
- if (!transaction->priv->has_been_run) {
- pk_transaction_progress_changed_emit (transaction, 100, 100, 0, 0);
- pk_transaction_allow_cancel_emit (transaction, FALSE);
- pk_transaction_status_changed_emit (transaction, PK_STATUS_ENUM_FINISHED);
- pk_transaction_finished_emit (transaction, PK_EXIT_ENUM_CANCELLED, 0);
- pk_transaction_list_remove (transaction->priv->transaction_list, transaction->priv->tid);
- return TRUE;
+ /* not implemented yet */
+ if (transaction->priv->backend->desc->cancel == NULL) {
+ error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
+ "Cancel not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
- /* if it's finished, cancelling will have no action */
+ /* if it's finished, cancelling will have no action regardless of uid */
if (transaction->priv->finished) {
egg_debug ("No point trying to cancel a finished transaction, ignoring");
- return TRUE;
- }
-
- /* not implemented yet */
- if (transaction->priv->backend->desc->cancel == NULL) {
- egg_debug ("Not implemented yet: Cancel");
- g_set_error (error, PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
- "Cancel not yet supported by backend");
- return FALSE;
+ goto out;
}
/* check to see if we have an action */
if (transaction->priv->role == PK_ROLE_ENUM_UNKNOWN) {
- g_set_error (error, PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NO_ROLE, "No role");
- return FALSE;
+ error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NO_ROLE, "No role");
+ dbus_g_method_return_error (context, error);
+ return;
}
/* check if it's safe to kill */
- if (transaction->priv->allow_cancel == FALSE) {
- g_set_error (error, PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_CANNOT_CANCEL,
- "Tried to cancel a transaction that is not safe to kill");
- return FALSE;
+ if (!transaction->priv->allow_cancel) {
+ error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_CANNOT_CANCEL,
+ "Tried to cancel a transaction that is not safe to kill");
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
+ /* check if we saved the uid */
+ if (transaction->priv->uid == PK_SECURITY_UID_INVALID) {
+ error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_CANNOT_CANCEL,
+ "No context from caller to get UID from");
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
+ /* get the UID of the caller */
+ sender = dbus_g_method_get_sender (context);
+ caller = pk_security_caller_new_from_sender (transaction->priv->security, sender);
+ uid = pk_security_get_uid (transaction->priv->security, caller);
+ g_free (sender);
+ pk_security_caller_unref (caller);
+
+ /* check we got a valid value */
+ if (uid == PK_SECURITY_UID_INVALID) {
+ error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_INVALID_STATE, "unable to get uid of caller");
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
+ /* check the caller uid with the originator uid */
+ if (transaction->priv->uid != uid) {
+ egg_debug ("uid does not match (%i vs. %i)", transaction->priv->uid, uid);
+ ret = pk_transaction_action_is_allowed (transaction, FALSE, PK_ROLE_ENUM_CANCEL, &error);
+ if (!ret) {
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+ }
+
+ /* if it's never been run, just remove this transaction from the list */
+ if (!transaction->priv->has_been_run) {
+ pk_transaction_progress_changed_emit (transaction, 100, 100, 0, 0);
+ pk_transaction_allow_cancel_emit (transaction, FALSE);
+ pk_transaction_status_changed_emit (transaction, PK_STATUS_ENUM_FINISHED);
+ pk_transaction_finished_emit (transaction, PK_EXIT_ENUM_CANCELLED, 0);
+ pk_transaction_release_tid (transaction);
+ goto out;
}
/* set the state, as cancelling might take a few seconds */
@@ -1538,7 +1607,11 @@ pk_transaction_cancel (PkTransaction *transaction, GError **error)
/* actually run the method */
transaction->priv->backend->desc->cancel (transaction->priv->backend);
- return TRUE;
+
+out:
+ /* not set inside the test suite */
+ if (context != NULL)
+ dbus_g_method_return (context);
}
/**
@@ -1552,7 +1625,6 @@ pk_transaction_download_packages (PkTransaction *transaction, gchar **package_id
gchar *package_ids_temp;
gchar *directory;
gint retval;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -1568,6 +1640,14 @@ pk_transaction_download_packages (PkTransaction *transaction, gchar **package_id
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check package_ids */
ret = pk_package_ids_check (package_ids);
if (!ret) {
@@ -1591,14 +1671,6 @@ pk_transaction_download_packages (PkTransaction *transaction, gchar **package_id
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_package_ids = g_strdupv (package_ids);
transaction->priv->cached_directory = g_strdup (directory);
@@ -1628,6 +1700,7 @@ pk_transaction_get_allow_cancel (PkTransaction *transaction, gboolean *allow_can
g_return_val_if_fail (PK_IS_TRANSACTION (transaction), FALSE);
g_return_val_if_fail (transaction->priv->tid != NULL, FALSE);
+ /* we do not need to get the context and check the uid */
egg_debug ("GetAllowCancel method called");
*allow_cancel = transaction->priv->allow_cancel;
return TRUE;
@@ -1641,7 +1714,6 @@ pk_transaction_get_categories (PkTransaction *transaction, DBusGMethodInvocation
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -1657,12 +1729,12 @@ pk_transaction_get_categories (PkTransaction *transaction, DBusGMethodInvocation
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
}
/* are we already performing an update? */
@@ -1699,7 +1771,6 @@ pk_transaction_get_depends (PkTransaction *transaction, const gchar *filter, gch
gboolean ret;
GError *error;
gchar *package_ids_temp;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -1710,7 +1781,6 @@ pk_transaction_get_depends (PkTransaction *transaction, const gchar *filter, gch
/* not implemented yet */
if (transaction->priv->backend->desc->get_depends == NULL) {
- egg_debug ("Not implemented yet: GetDepends");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"GetDepends not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -1718,6 +1788,14 @@ pk_transaction_get_depends (PkTransaction *transaction, const gchar *filter, gch
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check the filter */
ret = pk_transaction_filter_check (filter, &error);
if (!ret) {
@@ -1738,14 +1816,6 @@ pk_transaction_get_depends (PkTransaction *transaction, const gchar *filter, gch
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_filters = pk_filter_bitfield_from_text (filter);
transaction->priv->cached_package_ids = g_strdupv (package_ids);
@@ -1776,7 +1846,6 @@ pk_transaction_get_details (PkTransaction *transaction, gchar **package_ids, DBu
gboolean ret;
GError *error;
gchar *package_ids_temp;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -1787,7 +1856,6 @@ pk_transaction_get_details (PkTransaction *transaction, gchar **package_ids, DBu
/* not implemented yet */
if (transaction->priv->backend->desc->get_details == NULL) {
- egg_debug ("Not implemented yet: GetDetails");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"GetDetails not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -1795,6 +1863,14 @@ pk_transaction_get_details (PkTransaction *transaction, gchar **package_ids, DBu
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check package_ids */
ret = pk_package_ids_check (package_ids);
if (!ret) {
@@ -1807,14 +1883,6 @@ pk_transaction_get_details (PkTransaction *transaction, gchar **package_ids, DBu
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_package_ids = g_strdupv (package_ids);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_DETAILS);
@@ -1842,7 +1910,6 @@ pk_transaction_get_distro_upgrades (PkTransaction *transaction, DBusGMethodInvoc
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -1851,7 +1918,6 @@ pk_transaction_get_distro_upgrades (PkTransaction *transaction, DBusGMethodInvoc
/* not implemented yet */
if (transaction->priv->backend->desc->get_distro_upgrades == NULL) {
- egg_debug ("Not implemented yet: GetDistroUpgrades");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"GetDistroUpgrades not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -1859,12 +1925,12 @@ pk_transaction_get_distro_upgrades (PkTransaction *transaction, DBusGMethodInvoc
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
}
/* save so we can run later */
@@ -1895,7 +1961,6 @@ pk_transaction_get_files (PkTransaction *transaction, gchar **package_ids, DBusG
gboolean ret;
GError *error;
gchar *package_ids_temp;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -1906,7 +1971,6 @@ pk_transaction_get_files (PkTransaction *transaction, gchar **package_ids, DBusG
/* not implemented yet */
if (transaction->priv->backend->desc->get_files == NULL) {
- egg_debug ("Not implemented yet: GetFiles");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"GetFiles not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -1914,6 +1978,14 @@ pk_transaction_get_files (PkTransaction *transaction, gchar **package_ids, DBusG
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check package_ids */
ret = pk_package_ids_check (package_ids);
if (!ret) {
@@ -1926,14 +1998,6 @@ pk_transaction_get_files (PkTransaction *transaction, gchar **package_ids, DBusG
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_package_ids = g_strdupv (package_ids);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_FILES);
@@ -1961,7 +2025,6 @@ pk_transaction_get_packages (PkTransaction *transaction, const gchar *filter, DB
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -1970,7 +2033,6 @@ pk_transaction_get_packages (PkTransaction *transaction, const gchar *filter, DB
/* not implemented yet */
if (transaction->priv->backend->desc->get_packages == NULL) {
- egg_debug ("Not implemented yet: GetPackages");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"GetPackages not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -1978,6 +2040,14 @@ pk_transaction_get_packages (PkTransaction *transaction, const gchar *filter, DB
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check the filter */
ret = pk_transaction_filter_check (filter, &error);
if (!ret) {
@@ -1986,14 +2056,6 @@ pk_transaction_get_packages (PkTransaction *transaction, const gchar *filter, DB
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_filters = pk_filter_bitfield_from_text (filter);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_PACKAGES);
@@ -2079,7 +2141,6 @@ pk_transaction_get_repo_list (PkTransaction *transaction, const gchar *filter, D
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -2088,7 +2149,6 @@ pk_transaction_get_repo_list (PkTransaction *transaction, const gchar *filter, D
/* not implemented yet */
if (transaction->priv->backend->desc->get_repo_list == NULL) {
- egg_debug ("Not implemented yet: GetRepoList");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"GetRepoList not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -2096,6 +2156,14 @@ pk_transaction_get_repo_list (PkTransaction *transaction, const gchar *filter, D
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check the filter */
ret = pk_transaction_filter_check (filter, &error);
if (!ret) {
@@ -2104,14 +2172,6 @@ pk_transaction_get_repo_list (PkTransaction *transaction, const gchar *filter, D
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_filters = pk_filter_bitfield_from_text (filter);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_REPO_LIST);
@@ -2141,7 +2201,6 @@ pk_transaction_get_requires (PkTransaction *transaction, const gchar *filter, gc
gboolean ret;
GError *error;
gchar *package_ids_temp;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -2152,7 +2211,6 @@ pk_transaction_get_requires (PkTransaction *transaction, const gchar *filter, gc
/* not implemented yet */
if (transaction->priv->backend->desc->get_requires == NULL) {
- egg_debug ("Not implemented yet: GetRequires");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"GetRequires not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -2160,6 +2218,14 @@ pk_transaction_get_requires (PkTransaction *transaction, const gchar *filter, gc
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check the filter */
ret = pk_transaction_filter_check (filter, &error);
if (!ret) {
@@ -2180,14 +2246,6 @@ pk_transaction_get_requires (PkTransaction *transaction, const gchar *filter, gc
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_filters = pk_filter_bitfield_from_text (filter);
transaction->priv->cached_package_ids = g_strdupv (package_ids);
@@ -2267,7 +2325,6 @@ pk_transaction_get_update_detail (PkTransaction *transaction, gchar **package_id
GPtrArray *array;
guint i;
guint len;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -2281,7 +2338,6 @@ pk_transaction_get_update_detail (PkTransaction *transaction, gchar **package_id
/* not implemented yet */
if (transaction->priv->backend->desc->get_update_detail == NULL) {
- egg_debug ("Not implemented yet: GetUpdateDetail");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"GetUpdateDetail not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -2289,6 +2345,14 @@ pk_transaction_get_update_detail (PkTransaction *transaction, gchar **package_id
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check package_ids */
ret = pk_package_ids_check (package_ids);
if (!ret) {
@@ -2301,14 +2365,6 @@ pk_transaction_get_update_detail (PkTransaction *transaction, gchar **package_id
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_package_ids = g_strdupv (package_ids);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_UPDATE_DETAIL);
@@ -2386,7 +2442,6 @@ pk_transaction_get_updates (PkTransaction *transaction, const gchar *filter, DBu
GError *error;
PkPackageList *updates_cache;
gchar *package_id;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -2395,7 +2450,6 @@ pk_transaction_get_updates (PkTransaction *transaction, const gchar *filter, DBu
/* not implemented yet */
if (transaction->priv->backend->desc->get_updates == NULL) {
- egg_debug ("Not implemented yet: GetUpdates");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"GetUpdates not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -2403,6 +2457,14 @@ pk_transaction_get_updates (PkTransaction *transaction, const gchar *filter, DBu
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check the filter */
ret = pk_transaction_filter_check (filter, &error);
if (!ret) {
@@ -2411,14 +2473,6 @@ pk_transaction_get_updates (PkTransaction *transaction, const gchar *filter, DBu
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_filters = pk_filter_bitfield_from_text (filter);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_UPDATES);
@@ -2480,7 +2534,6 @@ pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
GError *error;
GError *error_local = NULL;
PkServicePack *service_pack;
- gchar *sender;
guint length;
guint i;
@@ -2500,6 +2553,14 @@ pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check all files exists and are valid */
length = g_strv_length (full_paths);
@@ -2529,14 +2590,6 @@ pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
}
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* check if the action is allowed from this client - if not, set an error */
ret = pk_transaction_action_is_allowed (transaction, trusted, PK_ROLE_ENUM_INSTALL_FILES, &error);
if (!ret) {
@@ -2575,7 +2628,6 @@ pk_transaction_install_packages (PkTransaction *transaction, gchar **package_ids
{
gboolean ret;
GError *error;
- gchar *sender;
gchar *package_ids_temp;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
@@ -2594,6 +2646,14 @@ pk_transaction_install_packages (PkTransaction *transaction, gchar **package_ids
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check package_ids */
ret = pk_package_ids_check (package_ids);
if (!ret) {
@@ -2606,14 +2666,6 @@ pk_transaction_install_packages (PkTransaction *transaction, gchar **package_ids
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* check if the action is allowed from this client - if not, set an error */
ret = pk_transaction_action_is_allowed (transaction, FALSE, PK_ROLE_ENUM_INSTALL_PACKAGES, &error);
if (!ret) {
@@ -2651,7 +2703,6 @@ pk_transaction_install_signature (PkTransaction *transaction, const gchar *sig_t
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -2667,6 +2718,14 @@ pk_transaction_install_signature (PkTransaction *transaction, const gchar *sig_t
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check for sanity */
ret = pk_strvalidate (key_id);
if (!ret) {
@@ -2687,14 +2746,6 @@ pk_transaction_install_signature (PkTransaction *transaction, const gchar *sig_t
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* check if the action is allowed from this client - if not, set an error */
ret = pk_transaction_action_is_allowed (transaction, FALSE, PK_ROLE_ENUM_INSTALL_SIGNATURE, &error);
if (!ret) {
@@ -2746,7 +2797,6 @@ pk_transaction_refresh_cache (PkTransaction *transaction, gboolean force, DBusGM
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -2762,12 +2812,12 @@ pk_transaction_refresh_cache (PkTransaction *transaction, gboolean force, DBusGM
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
}
/* check if the action is allowed from this client - if not, set an error */
@@ -2810,7 +2860,6 @@ pk_transaction_remove_packages (PkTransaction *transaction, gchar **package_ids,
{
gboolean ret;
GError *error;
- gchar *sender;
gchar *package_ids_temp;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
@@ -2829,6 +2878,14 @@ pk_transaction_remove_packages (PkTransaction *transaction, gchar **package_ids,
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check package_ids */
ret = pk_package_ids_check (package_ids);
if (!ret) {
@@ -2841,14 +2898,6 @@ pk_transaction_remove_packages (PkTransaction *transaction, gchar **package_ids,
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* check if the action is allowed from this client - if not, set an error */
ret = pk_transaction_action_is_allowed (transaction, FALSE, PK_ROLE_ENUM_REMOVE_PACKAGES, &error);
if (!ret) {
@@ -2886,7 +2935,6 @@ pk_transaction_repo_enable (PkTransaction *transaction, const gchar *repo_id, gb
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -2902,6 +2950,14 @@ pk_transaction_repo_enable (PkTransaction *transaction, const gchar *repo_id, gb
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check for sanity */
ret = pk_strvalidate (repo_id);
if (!ret) {
@@ -2912,14 +2968,6 @@ pk_transaction_repo_enable (PkTransaction *transaction, const gchar *repo_id, gb
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* check if the action is allowed from this client - if not, set an error */
ret = pk_transaction_action_is_allowed (transaction, FALSE, PK_ROLE_ENUM_REPO_ENABLE, &error);
if (!ret) {
@@ -2958,7 +3006,6 @@ pk_transaction_repo_set_data (PkTransaction *transaction, const gchar *repo_id,
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -2974,6 +3021,14 @@ pk_transaction_repo_set_data (PkTransaction *transaction, const gchar *repo_id,
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check for sanity */
ret = pk_strvalidate (repo_id);
if (!ret) {
@@ -2984,14 +3039,6 @@ pk_transaction_repo_set_data (PkTransaction *transaction, const gchar *repo_id,
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* check if the action is allowed from this client - if not, set an error */
ret = pk_transaction_action_is_allowed (transaction, FALSE, PK_ROLE_ENUM_REPO_SET_DATA, &error);
if (!ret) {
@@ -3033,7 +3080,6 @@ pk_transaction_resolve (PkTransaction *transaction, const gchar *filter,
gchar *packages_temp;
guint i;
guint length;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -3044,7 +3090,6 @@ pk_transaction_resolve (PkTransaction *transaction, const gchar *filter,
/* not implemented yet */
if (transaction->priv->backend->desc->resolve == NULL) {
- egg_debug ("Not implemented yet: Resolve");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"Resolve not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -3052,6 +3097,14 @@ pk_transaction_resolve (PkTransaction *transaction, const gchar *filter,
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check the filter */
ret = pk_transaction_filter_check (filter, &error);
if (!ret) {
@@ -3073,14 +3126,6 @@ pk_transaction_resolve (PkTransaction *transaction, const gchar *filter,
}
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_package_ids = g_strdupv (packages);
transaction->priv->cached_filters = pk_filter_bitfield_from_text (filter);
@@ -3110,7 +3155,6 @@ pk_transaction_rollback (PkTransaction *transaction, const gchar *transaction_id
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -3126,6 +3170,14 @@ pk_transaction_rollback (PkTransaction *transaction, const gchar *transaction_id
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check for sanity */
ret = pk_strvalidate (transaction_id);
if (!ret) {
@@ -3136,14 +3188,6 @@ pk_transaction_rollback (PkTransaction *transaction, const gchar *transaction_id
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* check if the action is allowed from this client - if not, set an error */
ret = pk_transaction_action_is_allowed (transaction, FALSE, PK_ROLE_ENUM_ROLLBACK, &error);
if (!ret) {
@@ -3180,7 +3224,6 @@ pk_transaction_search_details (PkTransaction *transaction, const gchar *filter,
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -3189,7 +3232,6 @@ pk_transaction_search_details (PkTransaction *transaction, const gchar *filter,
/* not implemented yet */
if (transaction->priv->backend->desc->search_details == NULL) {
- egg_debug ("Not implemented yet: SearchDetails");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"SearchDetails not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -3197,6 +3239,14 @@ pk_transaction_search_details (PkTransaction *transaction, const gchar *filter,
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check the search term */
ret = pk_transaction_search_check (search, &error);
if (!ret) {
@@ -3213,14 +3263,6 @@ pk_transaction_search_details (PkTransaction *transaction, const gchar *filter,
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_filters = pk_filter_bitfield_from_text (filter);
transaction->priv->cached_search = g_strdup (search);
@@ -3250,7 +3292,6 @@ pk_transaction_search_file (PkTransaction *transaction, const gchar *filter,
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -3259,7 +3300,6 @@ pk_transaction_search_file (PkTransaction *transaction, const gchar *filter,
/* not implemented yet */
if (transaction->priv->backend->desc->search_file == NULL) {
- egg_debug ("Not implemented yet: SearchFile");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"SearchFile not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -3267,6 +3307,14 @@ pk_transaction_search_file (PkTransaction *transaction, const gchar *filter,
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check the search term */
ret = pk_transaction_search_check (search, &error);
if (!ret) {
@@ -3283,14 +3331,6 @@ pk_transaction_search_file (PkTransaction *transaction, const gchar *filter,
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_filters = pk_filter_bitfield_from_text (filter);
transaction->priv->cached_search = g_strdup (search);
@@ -3320,7 +3360,6 @@ pk_transaction_search_group (PkTransaction *transaction, const gchar *filter,
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -3329,7 +3368,6 @@ pk_transaction_search_group (PkTransaction *transaction, const gchar *filter,
/* not implemented yet */
if (transaction->priv->backend->desc->search_group == NULL) {
- egg_debug ("Not implemented yet: SearchGroup");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"SearchGroup not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -3337,6 +3375,14 @@ pk_transaction_search_group (PkTransaction *transaction, const gchar *filter,
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check the search term */
ret = pk_transaction_search_check (search, &error);
if (!ret) {
@@ -3353,14 +3399,6 @@ pk_transaction_search_group (PkTransaction *transaction, const gchar *filter,
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_filters = pk_filter_bitfield_from_text (filter);
transaction->priv->cached_search = g_strdup (search);
@@ -3390,7 +3428,6 @@ pk_transaction_search_name (PkTransaction *transaction, const gchar *filter,
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -3399,7 +3436,6 @@ pk_transaction_search_name (PkTransaction *transaction, const gchar *filter,
/* not implemented yet */
if (transaction->priv->backend->desc->search_name == NULL) {
- egg_debug ("Not implemented yet: SearchName");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"SearchName not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -3407,6 +3443,14 @@ pk_transaction_search_name (PkTransaction *transaction, const gchar *filter,
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check the search term */
ret = pk_transaction_search_check (search, &error);
if (!ret) {
@@ -3423,14 +3467,6 @@ pk_transaction_search_name (PkTransaction *transaction, const gchar *filter,
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_filters = pk_filter_bitfield_from_text (filter);
transaction->priv->cached_search = g_strdup (search);
@@ -3454,23 +3490,38 @@ pk_transaction_search_name (PkTransaction *transaction, const gchar *filter,
/**
* pk_transaction_set_locale:
*/
-gboolean
-pk_transaction_set_locale (PkTransaction *transaction, const gchar *code, GError **error)
+void
+pk_transaction_set_locale (PkTransaction *transaction, const gchar *code, DBusGMethodInvocation *context)
{
- g_return_val_if_fail (PK_IS_TRANSACTION (transaction), FALSE);
- g_return_val_if_fail (transaction->priv->tid != NULL, FALSE);
+ GError *error;
+ gboolean ret;
+
+ g_return_if_fail (PK_IS_TRANSACTION (transaction));
+ g_return_if_fail (transaction->priv->tid != NULL);
+
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
/* already set? */
if (transaction->priv->locale != NULL) {
egg_warning ("Already set locale");
- g_set_error (error, PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
- "Already set locale to %s", transaction->priv->locale);
- return FALSE;
+ error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
+ "Already set locale to %s", transaction->priv->locale);
+ dbus_g_method_return_error (context, error);
+ return;
}
/* save so we can pass to the backend */
transaction->priv->locale = g_strdup (code);
- return TRUE;
+
+ /* not set inside the test suite */
+ if (context != NULL)
+ dbus_g_method_return (context);
}
/**
@@ -3481,7 +3532,6 @@ pk_transaction_update_packages (PkTransaction *transaction, gchar **package_ids,
{
gboolean ret;
GError *error;
- gchar *sender;
gchar *package_ids_temp;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
@@ -3500,6 +3550,14 @@ pk_transaction_update_packages (PkTransaction *transaction, gchar **package_ids,
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check package_ids */
ret = pk_package_ids_check (package_ids);
if (!ret) {
@@ -3512,14 +3570,6 @@ pk_transaction_update_packages (PkTransaction *transaction, gchar **package_ids,
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* check if the action is allowed from this client - if not, set an error */
ret = pk_transaction_action_is_allowed (transaction, FALSE, PK_ROLE_ENUM_UPDATE_PACKAGES, &error);
if (!ret) {
@@ -3555,7 +3605,6 @@ pk_transaction_update_system (PkTransaction *transaction, DBusGMethodInvocation
{
gboolean ret;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -3571,12 +3620,12 @@ pk_transaction_update_system (PkTransaction *transaction, DBusGMethodInvocation
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
}
/* check if the action is allowed from this client - if not, set an error */
@@ -3623,7 +3672,6 @@ pk_transaction_what_provides (PkTransaction *transaction, const gchar *filter, c
gboolean ret;
PkProvidesEnum provides;
GError *error;
- gchar *sender;
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -3632,7 +3680,6 @@ pk_transaction_what_provides (PkTransaction *transaction, const gchar *filter, c
/* not implemented yet */
if (transaction->priv->backend->desc->what_provides == NULL) {
- egg_debug ("Not implemented yet: WhatProvides");
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED,
"WhatProvides not yet supported by backend");
pk_transaction_release_tid (transaction);
@@ -3640,6 +3687,14 @@ pk_transaction_what_provides (PkTransaction *transaction, const gchar *filter, c
return;
}
+ /* check if the sender is the same */
+ ret = pk_transaction_verify_sender (transaction, context, &error);
+ if (!ret) {
+ /* don't release tid */
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check the search term */
ret = pk_transaction_search_check (search, &error);
if (!ret) {
@@ -3656,6 +3711,7 @@ pk_transaction_what_provides (PkTransaction *transaction, const gchar *filter, c
return;
}
+ /* check provides */
provides = pk_provides_enum_from_text (type);
if (provides == PK_PROVIDES_ENUM_UNKNOWN) {
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_INVALID_PROVIDE,
@@ -3665,14 +3721,6 @@ pk_transaction_what_provides (PkTransaction *transaction, const gchar *filter, c
return;
}
- /* set the dbus name, so we can get the disconnect */
- if (context != NULL) {
- /* not set inside the test suite */
- sender = dbus_g_method_get_sender (context);
- pk_transaction_set_dbus_name (transaction, sender);
- g_free (sender);
- }
-
/* save so we can run later */
transaction->priv->cached_filters = pk_filter_bitfield_from_text (filter);
transaction->priv->cached_search = g_strdup (search);
@@ -3823,7 +3871,6 @@ pk_transaction_init (PkTransaction *transaction)
transaction->priv->allow_cancel = TRUE;
transaction->priv->emit_eula_required = FALSE;
transaction->priv->emit_signature_required = FALSE;
- transaction->priv->dbus_name = NULL;
transaction->priv->cached_enabled = FALSE;
transaction->priv->cached_key_id = NULL;
transaction->priv->cached_package_id = NULL;
@@ -3838,8 +3885,10 @@ pk_transaction_init (PkTransaction *transaction)
transaction->priv->cached_value = NULL;
transaction->priv->last_package_id = NULL;
transaction->priv->tid = NULL;
+ transaction->priv->sender = NULL;
transaction->priv->locale = NULL;
transaction->priv->caller = NULL;
+ transaction->priv->uid = PK_SECURITY_UID_INVALID;
transaction->priv->role = PK_ROLE_ENUM_UNKNOWN;
transaction->priv->status = PK_STATUS_ENUM_WAIT;
transaction->priv->percentage = PK_BACKEND_PERCENTAGE_INVALID;
@@ -3891,7 +3940,6 @@ pk_transaction_finalize (GObject *object)
g_signal_emit (transaction, signals [PK_TRANSACTION_DESTROY], 0);
g_free (transaction->priv->last_package_id);
- g_free (transaction->priv->dbus_name);
g_free (transaction->priv->locale);
g_free (transaction->priv->cached_package_id);
g_free (transaction->priv->cached_key_id);
diff --git a/src/pk-transaction.h b/src/pk-transaction.h
index 962afe7..c1b66f3 100644
--- a/src/pk-transaction.h
+++ b/src/pk-transaction.h
@@ -90,12 +90,16 @@ const gchar *pk_transaction_get_tid (PkTransaction *transaction);
gboolean pk_transaction_set_tid (PkTransaction *transaction,
const gchar *tid);
+/* set DBUS sender */
+gboolean pk_transaction_set_sender (PkTransaction *transaction,
+ const gchar *sender);
+
/* dbus methods */
void pk_transaction_accept_eula (PkTransaction *transaction,
const gchar *eula_id,
DBusGMethodInvocation *context);
-gboolean pk_transaction_cancel (PkTransaction *transaction,
- GError **error);
+void pk_transaction_cancel (PkTransaction *transaction,
+ DBusGMethodInvocation *context);
void pk_transaction_download_packages (PkTransaction *transaction,
gchar **package_ids,
DBusGMethodInvocation *context);
@@ -208,9 +212,9 @@ void pk_transaction_search_name (PkTransaction *transaction,
const gchar *filter,
const gchar *search,
DBusGMethodInvocation *context);
-gboolean pk_transaction_set_locale (PkTransaction *transaction,
+void pk_transaction_set_locale (PkTransaction *transaction,
const gchar *code,
- GError **error);
+ DBusGMethodInvocation *context);
void pk_transaction_update_packages (PkTransaction *transaction,
gchar **package_ids,
DBusGMethodInvocation *context);
commit 8450b37d72e0f88930e62a9a47dc7f1d6b602fcf
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Nov 24 17:48:36 2008 +0000
trivial: the role list is no longer a bitfield
diff --git a/src/pk-security.h b/src/pk-security.h
index 339fd73..aa0bc07 100644
--- a/src/pk-security.h
+++ b/src/pk-security.h
@@ -34,8 +34,8 @@ G_BEGIN_DECLS
#define PK_IS_SECURITY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_SECURITY))
#define PK_SECURITY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_SECURITY, PkSecurityClass))
-/* not actually a role, but treated as one */
-#define PK_ROLE_ENUM_SET_PROXY_PRIVATE 1 << 31
+/* not actually roles */
+#define PK_ROLE_ENUM_SET_PROXY_PRIVATE (PK_ROLE_ENUM_UNKNOWN + 1)
/* when the UID is invalid or not known */
#define PK_SECURITY_UID_INVALID G_MAXUINT
commit 726653b71ccca69ecfd90560579b0e0efb476a20
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Nov 24 17:48:07 2008 +0000
trivial: provide a mapping from the Cancel enum andthe new policy action
diff --git a/src/pk-security-polkit.c b/src/pk-security-polkit.c
index 450f260..bffd16e 100644
--- a/src/pk-security-polkit.c
+++ b/src/pk-security-polkit.c
@@ -67,6 +67,7 @@ pk_security_caller_new_from_sender (PkSecurity *security, const gchar *sender)
DBusError dbus_error;
g_return_val_if_fail (PK_IS_SECURITY (security), FALSE);
+ g_return_val_if_fail (sender != NULL, FALSE);
/* get the PolKitCaller information */
dbus_error_init (&dbus_error);
@@ -180,6 +181,8 @@ pk_security_role_to_action (PkSecurity *security, gboolean trusted, PkRoleEnum r
policy = "org.freedesktop.packagekit.package-install-untrusted";
} else if (role == PK_ROLE_ENUM_ACCEPT_EULA) {
policy = "org.freedesktop.packagekit.package-eula-accept";
+ } else if (role == PK_ROLE_ENUM_CANCEL) {
+ policy = "org.freedesktop.packagekit.cancel-foreign";
}
return policy;
}
commit 5a81daaa00cb8409eed485976f298dfb30c2ae89
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Nov 24 17:47:35 2008 +0000
feature: add a PolicyKit rule so other users can cancel tasks from other users
diff --git a/policy/org.freedesktop.packagekit.policy.in b/policy/org.freedesktop.packagekit.policy.in
index b2ee0df..e805b87 100644
--- a/policy/org.freedesktop.packagekit.policy.in
+++ b/policy/org.freedesktop.packagekit.policy.in
@@ -13,8 +13,19 @@
<vendor_url>http://www.packagekit.org/</vendor_url>
<icon_name>package-x-generic</icon_name>
+ <action id="org.freedesktop.packagekit.cancel-foreign">
+ <_description>Cancel foreign task</_description>
+ <_message>Authentication is required to cancel a task that was not started by yourself</_message>
+ <icon_name>pk-package-delete</icon_name>
+ <vendor_url>http://www.packagekit.org/pk-reference.html#methods-cancel</vendor_url>
+ <defaults>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>auth_admin_keep_always</allow_active>
+ </defaults>
+ </action>
+
<action id="org.freedesktop.packagekit.package-install">
- <_description>Install local file</_description>
+ <_description>Install signed package</_description>
<_message>Authentication is required to install a signed package</_message>
<icon_name>pk-package-add</icon_name>
<vendor_url>http://www.packagekit.org/pk-reference.html#methods-install-package</vendor_url>
@@ -35,7 +46,6 @@
</defaults>
</action>
-
<action id="org.freedesktop.packagekit.system-trust-signing-key">
<_description>Trust a key used for signing packages</_description>
<_message>Authentication is required to consider a key used for signing packages as trusted</_message>
commit 9eeda48cc8ac73fa9b208482cc7cab5edd6c406b
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Nov 24 17:46:21 2008 +0000
trivial: some distros strip out some client tools, make the check less strict
diff --git a/lib/packagekit-glib/pk-desktop.c b/lib/packagekit-glib/pk-desktop.c
index 2ba2824..b57ff6c 100644
--- a/lib/packagekit-glib/pk-desktop.c
+++ b/lib/packagekit-glib/pk-desktop.c
@@ -367,7 +367,7 @@ pk_desktop_test (EggTest *test)
/************************************************************/
egg_test_title (test, "get files");
array = pk_desktop_get_files_for_package (desktop, "gnome-packagekit", NULL);
- if (array->len == 7)
+ if (array->len > 5)
egg_test_success (test, NULL);
else
egg_test_failed (test, "length=%i", array->len);
commit 6ee31d34def24740736621d23f395125e2d7ddd2
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Nov 24 17:45:54 2008 +0000
trivial: Cancel() will soo be able to refuse an action, retry if the error is polkit auth
diff --git a/lib/packagekit-glib/pk-client.c b/lib/packagekit-glib/pk-client.c
index e37d964..a49a17e 100644
--- a/lib/packagekit-glib/pk-client.c
+++ b/lib/packagekit-glib/pk-client.c
@@ -1112,6 +1112,27 @@ pk_client_get_role (PkClient *client, PkRoleEnum *role, gchar **text, GError **e
}
/**
+ * pk_client_cancel_action:
+ **/
+static gboolean
+pk_client_cancel_action (PkClient *client, GError **error)
+{
+ gboolean ret;
+
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ /* check to see if we have a valid proxy */
+ if (client->priv->proxy == NULL) {
+ *error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
+ return FALSE;
+ }
+ ret = dbus_g_proxy_call (client->priv->proxy, "Cancel", error,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+ return ret;
+}
+
+/**
* pk_client_cancel:
* @client: a valid #PkClient instance
* @error: a %GError to put the error code and message in, or %NULL
@@ -1144,27 +1165,41 @@ pk_client_cancel (PkClient *client, GError **error)
return FALSE;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "Cancel", &error_local,
- G_TYPE_INVALID, G_TYPE_INVALID);
- /* no error to process */
- if (ret) {
- return TRUE;
+ /* save this so we can re-issue it */
+ client->priv->role = PK_ROLE_ENUM_CANCEL;
+
+ /* hopefully do the operation first time */
+ ret = pk_client_cancel_action (client, &error_local);
+
+ /* we were refused by policy */
+ if (!ret && pk_client_error_refused_by_policy (error_local)) {
+ /* try to get auth */
+ if (pk_client_error_auth_obtain (error_local)) {
+ /* clear old error */
+ g_clear_error (&error_local);
+
+ /* retry the action now we have got auth */
+ ret = pk_client_cancel_action (client, &error_local);
+ }
}
+ /* no error to process */
+ if (ret)
+ goto out;
+
/* special case - if the tid is already finished, then cancel should return TRUE */
if (g_str_has_suffix (error_local->message, " doesn't exist\n")) {
egg_debug ("error ignored '%s' as we are trying to cancel", error_local->message);
g_error_free (error_local);
- return TRUE;
+ ret = TRUE;
+ goto out;
}
- /* if we got an error we don't recognise, just fix it up and copy it */
- if (error != NULL) {
- pk_client_error_fixup (&error_local);
- *error = g_error_copy (error_local);
- g_error_free (error_local);
- }
- return FALSE;
+ /* we failed one of these, return the error to the user */
+ pk_client_error_fixup (&error_local);
+ g_propagate_error (error, error_local);
+out:
+ return ret;
}
/**
@@ -1370,7 +1405,7 @@ gboolean
pk_client_update_system (PkClient *client, GError **error)
{
gboolean ret;
- GError *error_pk = NULL; /* we can't use the same error as we might be NULL */
+ GError *error_local = NULL; /* we can't use the same error as we might be NULL */
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -1383,7 +1418,7 @@ pk_client_update_system (PkClient *client, GError **error)
}
/* get and set a new ID */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
@@ -1391,30 +1426,30 @@ pk_client_update_system (PkClient *client, GError **error)
client->priv->role = PK_ROLE_ENUM_UPDATE_SYSTEM;
/* hopefully do the operation first time */
- ret = pk_client_update_system_action (client, &error_pk);
+ ret = pk_client_update_system_action (client, &error_local);
/* we were refused by policy */
- if (!ret && pk_client_error_refused_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_local)) {
/* try to get auth */
- if (pk_client_error_auth_obtain (error_pk)) {
+ if (pk_client_error_auth_obtain (error_local)) {
/* clear old error */
- g_clear_error (&error_pk);
+ g_clear_error (&error_local);
/* get a new tid */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
/* retry the action now we have got auth */
- ret = pk_client_update_system_action (client, &error_pk);
+ ret = pk_client_update_system_action (client, &error_local);
}
}
out:
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_pk);
- g_propagate_error (error, error_pk);
+ pk_client_error_fixup (&error_local);
+ g_propagate_error (error, error_local);
}
if (ret && !client->priv->is_finished) {
@@ -2495,7 +2530,7 @@ pk_client_remove_packages (PkClient *client, gchar **package_ids, gboolean allow
{
gboolean ret;
gchar *package_ids_temp;
- GError *error_pk = NULL; /* we can't use the same error as we might be NULL */
+ GError *error_local = NULL; /* we can't use the same error as we might be NULL */
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (package_ids != NULL, FALSE);
@@ -2519,7 +2554,7 @@ pk_client_remove_packages (PkClient *client, gchar **package_ids, gboolean allow
}
/* get and set a new ID */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
@@ -2530,30 +2565,30 @@ pk_client_remove_packages (PkClient *client, gchar **package_ids, gboolean allow
client->priv->cached_package_ids = g_strdupv (package_ids);
/* hopefully do the operation first time */
- ret = pk_client_remove_packages_action (client, package_ids, allow_deps, autoremove, &error_pk);
+ ret = pk_client_remove_packages_action (client, package_ids, allow_deps, autoremove, &error_local);
/* we were refused by policy */
- if (!ret && pk_client_error_refused_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_local)) {
/* try to get auth */
- if (pk_client_error_auth_obtain (error_pk)) {
+ if (pk_client_error_auth_obtain (error_local)) {
/* clear old error */
- g_clear_error (&error_pk);
+ g_clear_error (&error_local);
/* get a new tid */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
/* retry the action now we have got auth */
- ret = pk_client_remove_packages_action (client, package_ids, allow_deps, autoremove, &error_pk);
+ ret = pk_client_remove_packages_action (client, package_ids, allow_deps, autoremove, &error_local);
}
}
out:
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_pk);
- g_propagate_error (error, error_pk);
+ pk_client_error_fixup (&error_local);
+ g_propagate_error (error, error_local);
}
if (ret && !client->priv->is_finished) {
@@ -2608,7 +2643,7 @@ gboolean
pk_client_refresh_cache (PkClient *client, gboolean force, GError **error)
{
gboolean ret;
- GError *error_pk = NULL; /* we can't use the same error as we might be NULL */
+ GError *error_local = NULL; /* we can't use the same error as we might be NULL */
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -2621,7 +2656,7 @@ pk_client_refresh_cache (PkClient *client, gboolean force, GError **error)
}
/* get and set a new ID */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
@@ -2630,30 +2665,30 @@ pk_client_refresh_cache (PkClient *client, gboolean force, GError **error)
client->priv->cached_force = force;
/* hopefully do the operation first time */
- ret = pk_client_refresh_cache_action (client, force, &error_pk);
+ ret = pk_client_refresh_cache_action (client, force, &error_local);
/* we were refused by policy */
- if (!ret && pk_client_error_refused_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_local)) {
/* try to get auth */
- if (pk_client_error_auth_obtain (error_pk)) {
+ if (pk_client_error_auth_obtain (error_local)) {
/* clear old error */
- g_clear_error (&error_pk);
+ g_clear_error (&error_local);
/* get a new tid */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
/* retry the action now we have got auth */
- ret = pk_client_refresh_cache_action (client, force, &error_pk);
+ ret = pk_client_refresh_cache_action (client, force, &error_local);
}
}
out:
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_pk);
- g_propagate_error (error, error_pk);
+ pk_client_error_fixup (&error_local);
+ g_propagate_error (error, error_local);
}
if (ret && !client->priv->is_finished) {
@@ -2706,7 +2741,7 @@ pk_client_install_packages (PkClient *client, gchar **package_ids, GError **erro
{
gboolean ret;
gchar *package_ids_temp;
- GError *error_pk = NULL; /* we can't use the same error as we might be NULL */
+ GError *error_local = NULL; /* we can't use the same error as we might be NULL */
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (package_ids != NULL, FALSE);
@@ -2730,7 +2765,7 @@ pk_client_install_packages (PkClient *client, gchar **package_ids, GError **erro
}
/* get and set a new ID */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
@@ -2739,30 +2774,30 @@ pk_client_install_packages (PkClient *client, gchar **package_ids, GError **erro
client->priv->cached_package_ids = g_strdupv (package_ids);
/* hopefully do the operation first time */
- ret = pk_client_install_package_action (client, package_ids, &error_pk);
+ ret = pk_client_install_package_action (client, package_ids, &error_local);
/* we were refused by policy */
- if (!ret && pk_client_error_refused_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_local)) {
/* try to get auth */
- if (pk_client_error_auth_obtain (error_pk)) {
+ if (pk_client_error_auth_obtain (error_local)) {
/* clear old error */
- g_clear_error (&error_pk);
+ g_clear_error (&error_local);
/* get a new tid */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
/* retry the action now we have got auth */
- ret = pk_client_install_package_action (client, package_ids, &error_pk);
+ ret = pk_client_install_package_action (client, package_ids, &error_local);
}
}
out:
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_pk);
- g_propagate_error (error, error_pk);
+ pk_client_error_fixup (&error_local);
+ g_propagate_error (error, error_local);
}
if (ret && !client->priv->is_finished) {
@@ -2820,7 +2855,7 @@ pk_client_install_signature (PkClient *client, PkSigTypeEnum type, const gchar *
const gchar *package_id, GError **error)
{
gboolean ret;
- GError *error_pk = NULL; /* we can't use the same error as we might be NULL */
+ GError *error_local = NULL; /* we can't use the same error as we might be NULL */
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (type != PK_SIGTYPE_ENUM_UNKNOWN, FALSE);
@@ -2836,7 +2871,7 @@ pk_client_install_signature (PkClient *client, PkSigTypeEnum type, const gchar *
}
/* get and set a new ID */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
@@ -2846,30 +2881,30 @@ pk_client_install_signature (PkClient *client, PkSigTypeEnum type, const gchar *
client->priv->cached_key_id = g_strdup (key_id);
/* hopefully do the operation first time */
- ret = pk_client_install_signature_action (client, type, key_id, package_id, &error_pk);
+ ret = pk_client_install_signature_action (client, type, key_id, package_id, &error_local);
/* we were refused by policy */
- if (!ret && pk_client_error_refused_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_local)) {
/* try to get auth */
- if (pk_client_error_auth_obtain (error_pk)) {
+ if (pk_client_error_auth_obtain (error_local)) {
/* clear old error */
- g_clear_error (&error_pk);
+ g_clear_error (&error_local);
/* get a new tid */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
/* retry the action now we have got auth */
- ret = pk_client_install_signature_action (client, type, key_id, package_id, &error_pk);
+ ret = pk_client_install_signature_action (client, type, key_id, package_id, &error_local);
}
}
out:
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_pk);
- g_propagate_error (error, error_pk);
+ pk_client_error_fixup (&error_local);
+ g_propagate_error (error, error_local);
}
if (ret && !client->priv->is_finished) {
@@ -2922,7 +2957,7 @@ pk_client_update_packages (PkClient *client, gchar **package_ids, GError **error
{
gboolean ret;
gchar *package_ids_temp;
- GError *error_pk = NULL; /* we can't use the same error as we might be NULL */
+ GError *error_local = NULL; /* we can't use the same error as we might be NULL */
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (package_ids != NULL, FALSE);
@@ -2946,7 +2981,7 @@ pk_client_update_packages (PkClient *client, gchar **package_ids, GError **error
}
/* get and set a new ID */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
@@ -2959,30 +2994,30 @@ pk_client_update_packages (PkClient *client, gchar **package_ids, GError **error
}
/* hopefully do the operation first time */
- ret = pk_client_update_packages_action (client, package_ids, &error_pk);
+ ret = pk_client_update_packages_action (client, package_ids, &error_local);
/* we were refused by policy */
- if (!ret && pk_client_error_refused_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_local)) {
/* try to get auth */
- if (pk_client_error_auth_obtain (error_pk)) {
+ if (pk_client_error_auth_obtain (error_local)) {
/* clear old error */
- g_clear_error (&error_pk);
+ g_clear_error (&error_local);
/* get a new tid */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
/* retry the action now we have got auth */
- ret = pk_client_update_packages_action (client, package_ids, &error_pk);
+ ret = pk_client_update_packages_action (client, package_ids, &error_local);
}
}
out:
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_pk);
- g_propagate_error (error, error_pk);
+ pk_client_error_fixup (&error_local);
+ g_propagate_error (error, error_local);
}
if (ret && !client->priv->is_finished) {
@@ -3069,7 +3104,7 @@ pk_client_install_files (PkClient *client, gboolean trusted, gchar **files_rel,
gboolean ret;
gchar **files = NULL;
gchar *file;
- GError *error_pk = NULL; /* we can't use the same error as we might be NULL */
+ GError *error_local = NULL; /* we can't use the same error as we might be NULL */
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (files_rel != NULL, FALSE);
@@ -3083,7 +3118,7 @@ pk_client_install_files (PkClient *client, gboolean trusted, gchar **files_rel,
}
/* get and set a new ID */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
@@ -3108,30 +3143,30 @@ pk_client_install_files (PkClient *client, gboolean trusted, gchar **files_rel,
client->priv->cached_full_paths = g_strdupv (files);
/* hopefully do the operation first time */
- ret = pk_client_install_files_action (client, trusted, files, &error_pk);
+ ret = pk_client_install_files_action (client, trusted, files, &error_local);
/* we were refused by policy */
- if (!ret && pk_client_error_refused_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_local)) {
/* try to get auth */
- if (pk_client_error_auth_obtain (error_pk)) {
+ if (pk_client_error_auth_obtain (error_local)) {
/* clear old error */
- g_clear_error (&error_pk);
+ g_clear_error (&error_local);
/* get a new tid */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
/* retry the action now we have got auth */
- ret = pk_client_install_files_action (client, trusted, files, &error_pk);
+ ret = pk_client_install_files_action (client, trusted, files, &error_local);
}
}
out:
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_pk);
- g_propagate_error (error, error_pk);
+ pk_client_error_fixup (&error_local);
+ g_propagate_error (error, error_local);
}
if (ret && !client->priv->is_finished) {
@@ -3241,7 +3276,7 @@ gboolean
pk_client_accept_eula (PkClient *client, const gchar *eula_id, GError **error)
{
gboolean ret;
- GError *error_pk = NULL; /* we can't use the same error as we might be NULL */
+ GError *error_local = NULL; /* we can't use the same error as we might be NULL */
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (eula_id != NULL, FALSE);
@@ -3255,7 +3290,7 @@ pk_client_accept_eula (PkClient *client, const gchar *eula_id, GError **error)
}
/* get and set a new ID */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
@@ -3263,30 +3298,30 @@ pk_client_accept_eula (PkClient *client, const gchar *eula_id, GError **error)
client->priv->role = PK_ROLE_ENUM_ACCEPT_EULA;
/* hopefully do the operation first time */
- ret = pk_client_accept_eula_action (client, eula_id, &error_pk);
+ ret = pk_client_accept_eula_action (client, eula_id, &error_local);
/* we were refused by policy */
- if (!ret && pk_client_error_refused_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_local)) {
/* try to get auth */
- if (pk_client_error_auth_obtain (error_pk)) {
+ if (pk_client_error_auth_obtain (error_local)) {
/* clear old error */
- g_clear_error (&error_pk);
+ g_clear_error (&error_local);
/* get a new tid */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
/* retry the action now we have got auth */
- ret = pk_client_accept_eula_action (client, eula_id, &error_pk);
+ ret = pk_client_accept_eula_action (client, eula_id, &error_local);
}
}
out:
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_pk);
- g_propagate_error (error, error_pk);
+ pk_client_error_fixup (&error_local);
+ g_propagate_error (error, error_local);
}
if (ret && !client->priv->is_finished) {
@@ -3340,7 +3375,7 @@ gboolean
pk_client_repo_enable (PkClient *client, const gchar *repo_id, gboolean enabled, GError **error)
{
gboolean ret;
- GError *error_pk = NULL; /* we can't use the same error as we might be NULL */
+ GError *error_local = NULL; /* we can't use the same error as we might be NULL */
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (repo_id != NULL, FALSE);
@@ -3354,7 +3389,7 @@ pk_client_repo_enable (PkClient *client, const gchar *repo_id, gboolean enabled,
}
/* get and set a new ID */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
@@ -3362,30 +3397,30 @@ pk_client_repo_enable (PkClient *client, const gchar *repo_id, gboolean enabled,
client->priv->role = PK_ROLE_ENUM_REPO_ENABLE;
/* hopefully do the operation first time */
- ret = pk_client_repo_enable_action (client, repo_id, enabled, &error_pk);
+ ret = pk_client_repo_enable_action (client, repo_id, enabled, &error_local);
/* we were refused by policy */
- if (!ret && pk_client_error_refused_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_local)) {
/* try to get auth */
- if (pk_client_error_auth_obtain (error_pk)) {
+ if (pk_client_error_auth_obtain (error_local)) {
/* clear old error */
- g_clear_error (&error_pk);
+ g_clear_error (&error_local);
/* get a new tid */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
/* retry the action now we have got auth */
- ret = pk_client_repo_enable_action (client, repo_id, enabled, &error_pk);
+ ret = pk_client_repo_enable_action (client, repo_id, enabled, &error_local);
}
}
out:
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_pk);
- g_propagate_error (error, error_pk);
+ pk_client_error_fixup (&error_local);
+ g_propagate_error (error, error_local);
}
if (ret && !client->priv->is_finished) {
@@ -3444,7 +3479,7 @@ pk_client_repo_set_data (PkClient *client, const gchar *repo_id, const gchar *pa
const gchar *value, GError **error)
{
gboolean ret;
- GError *error_pk = NULL; /* we can't use the same error as we might be NULL */
+ GError *error_local = NULL; /* we can't use the same error as we might be NULL */
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (repo_id != NULL, FALSE);
@@ -3460,7 +3495,7 @@ pk_client_repo_set_data (PkClient *client, const gchar *repo_id, const gchar *pa
}
/* get and set a new ID */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
@@ -3468,30 +3503,30 @@ pk_client_repo_set_data (PkClient *client, const gchar *repo_id, const gchar *pa
client->priv->role = PK_ROLE_ENUM_REPO_SET_DATA;
/* hopefully do the operation first time */
- ret = pk_client_repo_set_data_action (client, repo_id, parameter, value, &error_pk);
+ ret = pk_client_repo_set_data_action (client, repo_id, parameter, value, &error_local);
/* we were refused by policy */
- if (!ret && pk_client_error_refused_by_policy (error_pk)) {
+ if (!ret && pk_client_error_refused_by_policy (error_local)) {
/* try to get auth */
- if (pk_client_error_auth_obtain (error_pk)) {
+ if (pk_client_error_auth_obtain (error_local)) {
/* clear old error */
- g_clear_error (&error_pk);
+ g_clear_error (&error_local);
/* get a new tid */
- ret = pk_client_allocate_transaction_id (client, &error_pk);
+ ret = pk_client_allocate_transaction_id (client, &error_local);
if (!ret)
goto out;
/* retry the action now we have got auth */
- ret = pk_client_repo_set_data_action (client, repo_id, parameter, value, &error_pk);
+ ret = pk_client_repo_set_data_action (client, repo_id, parameter, value, &error_local);
}
}
out:
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_pk);
- g_propagate_error (error, error_pk);
+ pk_client_error_fixup (&error_local);
+ g_propagate_error (error, error_local);
}
if (ret && !client->priv->is_finished) {
commit d6c6a9fb846a2052b9068373a0e8cbbc9df58886
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Nov 24 17:44:47 2008 +0000
trivial: set allow_cancel correctly for RefreshCache inthe dummy backend
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index f080fcc..01074a8 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -483,6 +483,8 @@ backend_refresh_cache_timeout (gpointer data)
pk_backend_finished (backend);
return FALSE;
}
+ if (_progress_percentage == 80)
+ pk_backend_set_allow_cancel (backend, FALSE);
_progress_percentage += 10;
pk_backend_set_percentage (backend, _progress_percentage);
return TRUE;
@@ -501,6 +503,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
_updated_kernel = FALSE;
_updated_powertop = FALSE;
+ pk_backend_set_allow_cancel (backend, TRUE);
pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
_signal_timeout = g_timeout_add (500, backend_refresh_cache_timeout, backend);
}
commit 5b5bbf9898cb03a7c49f4ec7bf37878f78dd592c
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Nov 24 16:26:51 2008 +0000
trivial: post release version bump
diff --git a/RELEASE b/RELEASE
index bb224a3..8e7e198 100644
--- a/RELEASE
+++ b/RELEASE
@@ -12,8 +12,8 @@ git-shortlog GNOME_PACKAGEKIT_0_3_11.. | grep -v trivial | grep -v Merge > NEWS.
4. Commit changes in PackageKit git:
-git commit -a -m "Release version 0.3.12"
-git tag -a -f -m "Release 0.3.12" PACKAGEKIT_0_3_12
+git commit -a -m "Release version 0.4.0"
+git tag -a -f -m "Release 0.4.0" PACKAGEKIT_0_4_0
git push --tags
git push
git push git+ssh://hughsient@git.freedesktop.org/git/packagekit
@@ -21,8 +21,8 @@ git push --tags git+ssh://hughsient@git.freedesktop.org/git/packagekit
5. Commit changes in gnome-packagekit git:
-git commit -a -m "Release version 0.3.12"
-git-tag GNOME_PACKAGEKIT_0_3_12
+git commit -a -m "Release version 0.4.0"
+git-tag GNOME_PACKAGEKIT_0_4_0
git push --tags
git push
@@ -44,9 +44,9 @@ git push
11. Send an email to packagekit at lists.freedesktop.org
=================================================
-Subject: PackageKit and gnome-packagekit 0.3.12 released!
+Subject: PackageKit and gnome-packagekit 0.4.0 released!
-Today I released PackageKit and gnome-packagekit 0.3.12.
+Today I released PackageKit and gnome-packagekit 0.4.0.
PackageKit release notes: http://gitweb.freedesktop.org/?p=packagekit.git;a=blob;f=NEWS
diff --git a/configure.ac b/configure.ac
index 16f47b7..ec81ca2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,13 +1,13 @@
AC_PREREQ(2.52)
-AC_INIT(PackageKit, 0.3.12)
+AC_INIT(PackageKit, 0.4.0)
AC_CONFIG_SRCDIR(src)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AM_CONFIG_HEADER(config.h)
# Should we enable extra stuff automatically?
# set no for release builds, yes for development builds
-DEVELOPMENT_RELEASE=no
+DEVELOPMENT_RELEASE=yes
# libtool versioning - this applies to libpackagekit
#
commit d21398712e21725eff7eefecca870188531ed134
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Nov 24 16:11:39 2008 +0000
trivial: post release version bump
diff --git a/RELEASE b/RELEASE
index 3ba93fa..bb224a3 100644
--- a/RELEASE
+++ b/RELEASE
@@ -3,8 +3,8 @@ PackageKit Release Notes
1. Write NEWS entries for PackageKit and gnome-packagekit in the same
format as usual. Ignore any trivial commits.
-git-shortlog PACKAGEKIT_0_3_10.. | grep -v trivial | grep -v Merge > NEWS.new
-git-shortlog GNOME_PACKAGEKIT_0_3_10.. | grep -v trivial | grep -v Merge > NEWS.new
+git-shortlog PACKAGEKIT_0_3_11.. | grep -v trivial | grep -v Merge > NEWS.new
+git-shortlog GNOME_PACKAGEKIT_0_3_11.. | grep -v trivial | grep -v Merge > NEWS.new
2. Add download date to docs/html/pk-download.html, save file.
@@ -12,8 +12,8 @@ git-shortlog GNOME_PACKAGEKIT_0_3_10.. | grep -v trivial | grep -v Merge > NEWS.
4. Commit changes in PackageKit git:
-git commit -a -m "Release version 0.3.11"
-git tag -a -f -m "Release 0.3.11" PACKAGEKIT_0_3_11
+git commit -a -m "Release version 0.3.12"
+git tag -a -f -m "Release 0.3.12" PACKAGEKIT_0_3_12
git push --tags
git push
git push git+ssh://hughsient@git.freedesktop.org/git/packagekit
@@ -21,8 +21,8 @@ git push --tags git+ssh://hughsient@git.freedesktop.org/git/packagekit
5. Commit changes in gnome-packagekit git:
-git commit -a -m "Release version 0.3.11"
-git-tag GNOME_PACKAGEKIT_0_3_11
+git commit -a -m "Release version 0.3.12"
+git-tag GNOME_PACKAGEKIT_0_3_12
git push --tags
git push
@@ -44,9 +44,9 @@ git push
11. Send an email to packagekit at lists.freedesktop.org
=================================================
-Subject: PackageKit and gnome-packagekit 0.3.11 released!
+Subject: PackageKit and gnome-packagekit 0.3.12 released!
-Today I released PackageKit and gnome-packagekit 0.3.11.
+Today I released PackageKit and gnome-packagekit 0.3.12.
PackageKit release notes: http://gitweb.freedesktop.org/?p=packagekit.git;a=blob;f=NEWS
diff --git a/configure.ac b/configure.ac
index 8fe60f7..16f47b7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
AC_PREREQ(2.52)
-AC_INIT(PackageKit, 0.3.11)
+AC_INIT(PackageKit, 0.3.12)
AC_CONFIG_SRCDIR(src)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AM_CONFIG_HEADER(config.h)
More information about the PackageKit-commit
mailing list