[PackageKit-commit] packagekit: Branch 'master' - 27 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Wed Jun 17 14:07:59 PDT 2009
backends/alpm/pk-backend-alpm.c | 7
backends/apt.deprecated/aptBackend.py | 3
backends/apt/aptBackend.py | 23
backends/apt/pk-backend-apt.c | 16
backends/box/pk-backend-box.c | 13
backends/conary/conaryBackend.py | 18
backends/conary/pk-backend-conary.c | 16
backends/dummy/pk-backend-dummy.c | 16
backends/opkg/pk-backend-opkg.c | 8
backends/pisi/pisiBackend.py | 21
backends/pisi/pk-backend-pisi.c | 16
backends/poldek/pk-backend-poldek.c | 9
backends/portage/pk-backend-portage.c | 17
backends/portage/portageBackend.py | 50
backends/smart/pk-backend-smart.c | 16
backends/smart/smartBackend.py | 36
backends/test/pk-backend-test-fail.c | 8
backends/test/pk-backend-test-succeed.c | 8
backends/urpmi/helpers/urpmi-dispatched-backend.pl | 12
backends/urpmi/pk-backend-urpmi.c | 12
backends/yum/pk-backend-yum.c | 16
backends/yum/yumBackend.py | 113 -
backends/zypp/pk-backend-zypp.cpp | 11
client/pk-console.c | 245 +-
configure.ac | 15
contrib/PackageKit.spec.in | 15
docs/api/spec/pk-concepts.xml | 10
docs/html/img/users-sles.png |binary
etc/PackageKit.conf.in | 16
lib/packagekit-glib/pk-client.c | 1739 +++++++++------------
lib/packagekit-glib/pk-client.h | 9
lib/packagekit-glib/pk-common.c | 26
lib/packagekit-glib/pk-common.h | 2
lib/packagekit-glib/pk-enum.c | 3
lib/packagekit-glib/pk-enum.h | 3
lib/packagekit-qt/src/client.cpp | 34
lib/packagekit-qt/src/client.h | 6
lib/packagekit-qt/src/polkitclient.cpp | 9
lib/packagekit-qt/src/polkitclient.h | 2
lib/packagekit-qt/src/transaction.cpp | 3
lib/packagekit-qt/src/transactionproxy.h | 4
lib/packagekit-sharp/packagekit-api.raw | 4
lib/packagekit-sharp/packagekit-api.xml | 4
lib/python/packagekit/backend.py | 43
lib/python/packagekit/client.py | 4
po/POTFILES.in | 1
po/nl.po | 135 -
policy/.gitignore | 2
policy/Makefile.am | 7
policy/org.freedesktop.packagekit.policy.in | 25
src/.gitignore | 2
src/Makefile.am | 62
src/org.freedesktop.PackageKit.Transaction.xml | 61
src/pk-backend.c | 15
src/pk-backend.h | 7
src/pk-engine.c | 220 +-
src/pk-polkit-action-lookup.c | 276 +++
src/pk-post-trans.c | 42
src/pk-security-dummy.c | 155 -
src/pk-security-polkit.c | 424 -----
src/pk-security.h | 77
src/pk-self-test.c | 2
src/pk-transaction-list.c | 6
src/pk-transaction.c | 602 +++++--
src/pk-transaction.h | 5
65 files changed, 2428 insertions(+), 2359 deletions(-)
New commits:
commit 4f26af24ab5e1b15e88efa85e4919be5a46488b4
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 21:52:19 2009 +0100
Add a PolicyKit action lookup so we can do the translated warning from the server, not the client
diff --git a/contrib/PackageKit.spec.in b/contrib/PackageKit.spec.in
index e3491b4..4303eb9 100644
--- a/contrib/PackageKit.spec.in
+++ b/contrib/PackageKit.spec.in
@@ -221,7 +221,7 @@ and are unable to learn any new tricks.
%setup -q
%build
-%configure --enable-yum --enable-smart --with-default-backend=yum --disable-local
+%configure --disable-static --enable-yum --enable-smart --with-default-backend=yum --disable-local
make %{?_smp_mflags}
@@ -229,14 +229,11 @@ make %{?_smp_mflags}
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
-rm -f $RPM_BUILD_ROOT%{_libdir}/libpackagekit*.a
rm -f $RPM_BUILD_ROOT%{_libdir}/libpackagekit*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/packagekit-backend/*.la
-rm -f $RPM_BUILD_ROOT%{_libdir}/packagekit-backend/*.a
-rm -f $RPM_BUILD_ROOT%{_libdir}/mozilla/plugins/packagekit-plugin.a
rm -f $RPM_BUILD_ROOT%{_libdir}/mozilla/plugins/packagekit-plugin.la
-rm -f $RPM_BUILD_ROOT%{_libdir}/gtk-2.0/modules/*.a
rm -f $RPM_BUILD_ROOT%{_libdir}/gtk-2.0/modules/*.la
+rm -f $RPM_BUILD_ROOT%{_libdir}/polkit-1/extensions/libpackagekit-action-lookup.la
touch $RPM_BUILD_ROOT%{_localstatedir}/cache/PackageKit/groups.sqlite
@@ -305,6 +302,7 @@ update-mime-database %{_datadir}/mime &> /dev/null || :
%ghost %verify(not md5 size mtime) %{_localstatedir}/lib/PackageKit/transactions.db
%{_datadir}/dbus-1/system-services/*.service
%{_libdir}/pm-utils/sleep.d/95packagekit
+%{_libdir}/polkit-1/extensions/libpackagekit-action-lookup.so
%files docs
%defattr(-,root,root,-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9887fec..561af4f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -12,4 +12,5 @@ data/packagekit-package-list.xml.in
data/packagekit-servicepack.xml.in
policy/org.freedesktop.packagekit.policy.in
src/pk-main.c
+src/pk-polkit-action-lookup.c
diff --git a/src/.gitignore b/src/.gitignore
index e66aa01..d2ce3e8 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,6 +1,8 @@
.deps
.libs
*.o
+*.la
+*.lo
pk-marshal.h
pk-marshal.c
org.freedesktop.PackageKit*.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 62d1ff4..f309272 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,17 +17,17 @@ INCLUDES = \
$(LIBNM_CFLAGS) \
$(CONNMAN_CFLAGS) \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
- -DBINDIR=\"$(bindir)\" \
- -DSBINDIR=\"$(sbindir)\" \
+ -DBINDIR=\"$(bindir)\" \
+ -DSBINDIR=\"$(sbindir)\" \
-DDATADIR=\"$(datadir)\" \
- -DPREFIX=\""$(prefix)"\" \
- -DSYSCONFDIR=\""$(sysconfdir)"\" \
- -DLIBDIR=\""$(libdir)"\" \
- -DLIBEXECDIR=\""$(libexecdir)"\" \
- -DVERSION="\"$(VERSION)\"" \
+ -DPREFIX=\""$(prefix)"\" \
+ -DSYSCONFDIR=\""$(sysconfdir)"\" \
+ -DLIBDIR=\""$(libdir)"\" \
+ -DLIBEXECDIR=\""$(libexecdir)"\" \
+ -DVERSION="\"$(VERSION)\"" \
-DPK_DATA=\"$(pkgdatadir)\" \
- -DLOCALSTATEDIR=\""$(localstatedir)"\" \
- -DPK_DB_DIR=\""$(PK_DB_DIR)"\" \
+ -DLOCALSTATEDIR=\""$(localstatedir)"\" \
+ -DPK_DB_DIR=\""$(PK_DB_DIR)"\" \
-DEGG_LOG_FILE=\""$(PK_LOG_DIR)/PackageKit"\" \
-DEGG_VERBOSE="\"PK_VERBOSE\"" \
-DEGG_LOGGING="\"PK_LOGGING\"" \
@@ -136,13 +136,13 @@ packagekitd_CFLAGS = \
$(NULL)
if BACKEND_TYPE_BOX
-packagekitd_INCLUDES = \
+packagekitd_INCLUDES = \
$(BOX_CFLAGS)
-packagekitd_LDADD += \
+packagekitd_LDADD += \
$(BOX_LIBS)
endif
-BUILT_SOURCES = \
+BUILT_SOURCES = \
pk-marshal.c \
pk-marshal.h \
org.freedesktop.PackageKit.h \
@@ -178,6 +178,31 @@ org.freedesktop.PackageKit.Backend.h: org.freedesktop.PackageKit.Backend.xml
--output=org.freedesktop.PackageKit.Backend.h \
$(srcdir)/org.freedesktop.PackageKit.Backend.xml
+# provide a PolicyKit extensions to make the authorization dialogs better
+polkitmodulesdir = $(libdir)/polkit-1/extensions
+polkitmodules_LTLIBRARIES = libpackagekit-action-lookup.la
+
+libpackagekit_action_lookup_la_SOURCES = \
+ pk-polkit-action-lookup.c \
+ $(NULL)
+
+libpackagekit_action_lookup_la_CFLAGS = \
+ -DPOLKIT_BACKEND_I_KNOW_API_IS_SUBJECT_TO_CHANGE \
+ -DG_LOG_DOMAIN=\"PackageKit-Action-Lookup\" \
+ $(POLKIT_BACKEND_1_CFLAGS) \
+ $(NULL)
+
+libpackagekit_action_lookup_la_LDFLAGS = \
+ -export_dynamic -avoid-version -module -no-undefined \
+ -export-symbols-regex '^g_io_module_(load|unload)' \
+ $(POLKIT_BACKEND_1_LIBS) \
+ $(NULL)
+
+libpackagekit_action_lookup_la_LIBADD = \
+ $(GLIB_LIBS) \
+ $(PK_GLIB_LIBS) \
+ $(NULL)
+
if EGG_BUILD_TESTS
check_PROGRAMS = \
diff --git a/src/pk-polkit-action-lookup.c b/src/pk-polkit-action-lookup.c
new file mode 100644
index 0000000..7c19599
--- /dev/null
+++ b/src/pk-polkit-action-lookup.c
@@ -0,0 +1,276 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 David Zeuthen <davidz at redhat.com>
+ * Copyright (C) 2009 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <polkitbackend/polkitbackend.h>
+#include <packagekit-glib/packagekit.h>
+#include <glib/gi18n-lib.h>
+
+#define PK_TYPE_ACTION_LOOKUP (pk_action_lookup_get_type())
+#define PK_ACTION_LOOKUP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_ACTION_LOOKUP, PkActionLookup))
+#define PK_ACTION_LOOKUP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_ACTION_LOOKUP, PkActionLookupClass))
+#define PK_ACTION_LOOKUP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_ACTION_LOOKUP, PkActionLookupClass))
+#define PK_IS_ACTION_LOOKUP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_ACTION_LOOKUP))
+#define PK_IS_ACTION_LOOKUP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_ACTION_LOOKUP))
+
+typedef struct _PkActionLookup PkActionLookup;
+typedef struct _PkActionLookupClass PkActionLookupClass;
+
+struct _PkActionLookup
+{
+ GObject parent;
+};
+
+struct _PkActionLookupClass
+{
+ GObjectClass parent_class;
+};
+
+GType pk_action_lookup_get_type (void) G_GNUC_CONST;
+
+static void polkit_backend_action_lookup_iface_init (PolkitBackendActionLookupIface *iface);
+
+#define _G_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init) \
+{ \
+ const GInterfaceInfo g_implement_interface_info = { \
+ (GInterfaceInitFunc) iface_init, NULL, NULL \
+ }; \
+ g_type_module_add_interface (type_module, g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
+}
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (PkActionLookup,
+ pk_action_lookup,
+ G_TYPE_OBJECT,
+ 0,
+ _G_IMPLEMENT_INTERFACE_DYNAMIC (POLKIT_BACKEND_TYPE_ACTION_LOOKUP,
+ polkit_backend_action_lookup_iface_init))
+
+/**
+ * pk_action_lookup_init:
+ **/
+static void
+pk_action_lookup_init (PkActionLookup *lookup)
+{
+}
+
+/**
+ * pk_action_lookup_class_finalize:
+ **/
+static void
+pk_action_lookup_class_finalize (PkActionLookupClass *klass)
+{
+}
+
+/**
+ * pk_action_lookup_class_init:
+ **/
+static void
+pk_action_lookup_class_init (PkActionLookupClass *klass)
+{
+}
+
+/**
+ * pk_action_lookup_get_message:
+ **/
+static gchar *
+pk_action_lookup_get_message (PolkitBackendActionLookup *lookup, const gchar *action_id,
+ PolkitDetails *details, PolkitActionDescription *action_description)
+{
+ PkRoleEnum role = PK_ROLE_ENUM_UNKNOWN;
+ gboolean only_trusted = TRUE;
+ const gchar *role_text;
+ const gchar *only_trusted_text;
+ gchar *message = NULL;
+ GString *string;
+
+ if (!g_str_has_prefix (action_id, "org.freedesktop.packagekit."))
+ goto out;
+
+ /* get role */
+ role_text = polkit_details_lookup (details, "role");
+ if (role_text != NULL)
+ role = pk_role_enum_from_text (role_text);
+
+ /* get only-trusted */
+ only_trusted_text = polkit_details_lookup (details, "only-trusted");
+ if (only_trusted_text != NULL)
+ only_trusted = g_str_equal (only_trusted_text, "true");
+
+ /* use the message shipped in the policy file */
+ if (only_trusted)
+ goto out;
+
+ /* UpdatePackages */
+ if (role == PK_ROLE_ENUM_UPDATE_PACKAGES) {
+ string = g_string_new ("");
+
+ /* TRANSLATORS: is not GPG signed */
+ g_string_append (string, g_dgettext (GETTEXT_PACKAGE, N_("The software is not from a trusted source.")));
+ g_string_append (string, "\n");
+
+ /* TRANSLATORS: user has to trust provider -- I know, this sucks */
+ g_string_append (string, g_dgettext (GETTEXT_PACKAGE, N_("Do not update this package unless you are sure it is safe to do so.")));
+ g_string_append (string, "\n\n");
+
+ /* TRANSLATORS: warn the user that all bets are off */
+ g_string_append (string, g_dgettext (GETTEXT_PACKAGE, N_("Malicious software can damage your computer or cause other harm.")));
+
+ message = g_string_free (string, FALSE);
+ goto out;
+ }
+
+ /* InstallPackages */
+ if (role == PK_ROLE_ENUM_INSTALL_PACKAGES) {
+ string = g_string_new ("");
+
+ /* TRANSLATORS: is not GPG signed */
+ g_string_append (string, g_dgettext (GETTEXT_PACKAGE, N_("The software is not from a trusted source.")));
+ g_string_append (string, "\n");
+
+ /* TRANSLATORS: user has to trust provider -- I know, this sucks */
+ g_string_append (string, g_dgettext (GETTEXT_PACKAGE, N_("Do not install this package unless you are sure it is safe to do so.")));
+ g_string_append (string, "\n\n");
+
+ /* TRANSLATORS: warn the user that all bets are off */
+ g_string_append (string, g_dgettext (GETTEXT_PACKAGE, N_("Malicious software can damage your computer or cause other harm.")));
+
+ message = g_string_free (string, FALSE);
+ goto out;
+ }
+out:
+ return message;
+}
+
+/**
+ * pk_action_lookup_get_icon_name:
+ **/
+static gchar *
+pk_action_lookup_get_icon_name (PolkitBackendActionLookup *lookup, const gchar *action_id,
+ PolkitDetails *details, PolkitActionDescription *action_description)
+{
+ PkRoleEnum role = PK_ROLE_ENUM_UNKNOWN;
+ gboolean only_trusted = TRUE;
+ const gchar *role_text;
+ const gchar *only_trusted_text;
+ gchar *value = NULL;
+
+ if (!g_str_has_prefix (action_id, "org.freedesktop.packagekit."))
+ goto out;
+
+ /* get role */
+ role_text = polkit_details_lookup (details, "role");
+ if (role_text != NULL)
+ role = pk_role_enum_from_text (role_text);
+
+ /* get only-trusted */
+ only_trusted_text = polkit_details_lookup (details, "only-trusted");
+ if (only_trusted_text != NULL)
+ only_trusted = g_str_equal (only_trusted_text, "true");
+
+ /* set proxy */
+ if (role == PK_ROLE_ENUM_UNKNOWN) {
+ value = g_strdup ("preferences-system-network-proxy");
+ goto out;
+ }
+
+ /* only-trusted */
+ if (!only_trusted) {
+ value = g_strdup ("emblem-important");
+ goto out;
+ }
+
+ /* fallback */
+ value = g_strdup ("package-x-generic");
+
+out:
+ return value;
+}
+
+/**
+ * pk_action_lookup_get_details:
+ **/
+static PolkitDetails *
+pk_action_lookup_get_details (PolkitBackendActionLookup *lookup, const gchar *action_id,
+ PolkitDetails *action_details, PolkitActionDescription *action_description)
+{
+ const gchar *str;
+ PolkitDetails *details;
+
+ if (!g_str_has_prefix (action_id, "org.freedesktop.packagekit."))
+ return NULL;
+
+ details = polkit_details_new ();
+
+ /* role */
+ str = polkit_details_lookup (action_details, "role");
+ if (str != NULL) {
+ /* TRANSLATORS: the trasaction role, e.g. update-system */
+ polkit_details_insert (details, _("Role"), str);
+ }
+
+ /* only-trusted */
+ str = polkit_details_lookup (action_details, "only-trusted");
+ if (str != NULL) {
+ /* TRANSLATORS: if the transaction is forced to install only trusted packages */
+ polkit_details_insert (details, _("Only trusted"), str);
+ }
+
+ return details;
+}
+
+/**
+ * polkit_backend_action_lookup_iface_init:
+ **/
+static void
+polkit_backend_action_lookup_iface_init (PolkitBackendActionLookupIface *iface)
+{
+ iface->get_message = pk_action_lookup_get_message;
+ iface->get_icon_name = pk_action_lookup_get_icon_name;
+ iface->get_details = pk_action_lookup_get_details;
+}
+
+/**
+ * g_io_module_load:
+ **/
+void
+g_io_module_load (GIOModule *module)
+{
+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ pk_action_lookup_register_type (G_TYPE_MODULE (module));
+
+ g_io_extension_point_implement (POLKIT_BACKEND_ACTION_LOOKUP_EXTENSION_POINT_NAME,
+ PK_TYPE_ACTION_LOOKUP,
+ "PackageKit action lookup extension " PACKAGE_VERSION,
+ 0);
+}
+
+/**
+ * g_io_module_unload:
+ **/
+void
+g_io_module_unload (GIOModule *module)
+{
+}
+
commit b838746e431d500de054c83aa4ccbb1abb335174
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 16:31:38 2009 +0100
Populate some initial PolkitDetails when we ask PoicyKit1 for authorization
diff --git a/src/pk-engine.c b/src/pk-engine.c
index c9983a9..532a8dd 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -612,6 +612,7 @@ pk_engine_set_proxy (PkEngine *engine, const gchar *proxy_http, const gchar *pro
#ifdef USE_SECURITY_POLKIT
gchar *sender = NULL;
PolkitSubject *subject;
+ PolkitDetails *details;
#else
gboolean ret;
GError *error = NULL;
@@ -632,13 +633,22 @@ pk_engine_set_proxy (PkEngine *engine, const gchar *proxy_http, const gchar *pro
/* check subject */
sender = dbus_g_method_get_sender (context);
subject = polkit_system_bus_name_new (sender);
+
+ /* insert details about the authorization */
+ details = polkit_details_new ();
+ polkit_details_insert (details, "role", pk_role_enum_to_text (PK_ROLE_ENUM_UNKNOWN));
+
+ /* do authorization async */
polkit_authority_check_authorization (engine->priv->authority, subject,
"org.freedesktop.packagekit.system-network-proxy-configure",
- NULL,
+ details,
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
NULL,
(GAsyncReadyCallback) pk_engine_action_obtain_authorization_finished_cb,
engine);
+
+ /* check_authorization ref's this */
+ g_object_unref (details);
#else
egg_warning ("*** THERE IS NO SECURITY MODEL BEING USED!!! ***");
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 4637337..97218cd 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -1673,6 +1673,7 @@ pk_transaction_role_to_action_untrusted (PkRoleEnum role)
static gboolean
pk_transaction_obtain_authorization (PkTransaction *transaction, gboolean only_trusted, PkRoleEnum role, GError **error)
{
+ PolkitDetails *details;
const gchar *action_id;
gboolean ret = FALSE;
@@ -1700,14 +1701,25 @@ pk_transaction_obtain_authorization (PkTransaction *transaction, gboolean only_t
/* check subject */
transaction->priv->waiting_for_auth = TRUE;
+
+ /* insert details about the authorization */
+ details = polkit_details_new ();
+ polkit_details_insert (details, "role", pk_role_enum_to_text (transaction->priv->role));
+ polkit_details_insert (details, "only-trusted", transaction->priv->cached_only_trusted ? "true" : "false");
+
+ /* do authorization async */
polkit_authority_check_authorization (transaction->priv->authority,
transaction->priv->subject,
action_id,
- NULL,
+ details,
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
transaction->priv->cancellable,
(GAsyncReadyCallback) pk_transaction_action_obtain_authorization_finished_cb,
transaction);
+
+ /* check_authorization ref's this */
+ g_object_unref (details);
+
/* assume success, as this is async */
ret = TRUE;
out:
@@ -4136,6 +4148,7 @@ pk_transaction_init (PkTransaction *transaction)
transaction->priv->emit_signature_required = FALSE;
transaction->priv->emit_media_change_required = FALSE;
transaction->priv->cached_enabled = FALSE;
+ transaction->priv->cached_only_trusted = TRUE;
transaction->priv->cached_key_id = NULL;
transaction->priv->cached_package_id = NULL;
transaction->priv->cached_package_ids = NULL;
commit 8b7a63648d325144331b3b9dfcc11d3bfc154691
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 16:05:38 2009 +0100
pkcon; trivially disable the destroy loop quit for now
diff --git a/client/pk-console.c b/client/pk-console.c
index db313a0..9281af4 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -535,8 +535,8 @@ pk_console_destroy_cb (PkClient *client, gpointer data)
/* exit our private loop if it's running */
ret = g_main_loop_is_running (loop);
if (ret) {
- egg_warning ("quitting loop due to transaction being destroyed");
- g_main_loop_quit (loop);
+ egg_warning ("maybe quit loop due to transaction being destroyed?");
+// g_main_loop_quit (loop);
}
}
commit 65806032a68be6c27975ac412c4af0f28a02f2e5
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 16:03:52 2009 +0100
pkcon: make the use_trusted logic a lot simpler
diff --git a/client/pk-console.c b/client/pk-console.c
index a2464c2..db313a0 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -49,15 +49,12 @@ static gboolean has_output_bar = FALSE;
static gboolean need_requeue = FALSE;
static gboolean nowait = FALSE;
static gboolean awaiting_space = FALSE;
-static gboolean only_trusted = TRUE;
static guint timer_id = 0;
static guint percentage_last = 0;
-static gchar **untrusted_strv_cache = NULL;
static PkControl *control = NULL;
-static PkClient *client_async = NULL;
-static PkClient *client_task = NULL;
-static PkClient *client_trusted = NULL;
-static PkClient *client_signature = NULL;
+static PkClient *client_primary = NULL;
+static PkClient *client_secondary = NULL;
+static PkClient *client_sync = NULL;
typedef struct {
gint position;
@@ -501,7 +498,7 @@ pk_console_signature_finished_cb (PkClient *client, PkExitEnum exit_enum, guint
GError *error = NULL;
egg_debug ("trying to requeue");
- ret = pk_client_requeue (client_async, &error);
+ ret = pk_client_requeue (client_primary, &error);
if (!ret) {
egg_warning ("failed to requeue action: %s", error->message);
g_error_free (error);
@@ -510,15 +507,6 @@ pk_console_signature_finished_cb (PkClient *client, PkExitEnum exit_enum, guint
}
/**
- * pk_console_install_files_finished_cb:
- **/
-static void
-pk_console_install_files_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime, gpointer data)
-{
- g_main_loop_quit (loop);
-}
-
-/**
* pk_console_require_restart_cb:
**/
static void
@@ -562,6 +550,8 @@ pk_console_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime, g
const gchar *role_text;
gfloat time_s;
PkRestartEnum restart;
+ gboolean ret;
+ GError *error = NULL;
pk_client_get_role (client, &role, NULL, NULL);
@@ -594,6 +584,20 @@ pk_console_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime, g
g_print ("%s\n", _("Please restart the application as it is being used."));
}
+ /* need to handle retry with only_trusted=FALSE */
+ if (exit_enum == PK_EXIT_ENUM_NEED_UNTRUSTED) {
+ egg_debug ("need to handle untrusted");
+
+ /* retry new action with untrusted */
+ pk_client_set_only_trusted (client, FALSE);
+ ret = pk_client_requeue (client, &error);
+ if (!ret) {
+ egg_warning ("Failed to requeue: %s", error->message);
+ g_error_free (error);
+ }
+ return;
+ }
+
if ((role == PK_ROLE_ENUM_INSTALL_FILES || role == PK_ROLE_ENUM_INSTALL_PACKAGES) &&
exit_enum == PK_EXIT_ENUM_FAILED && need_requeue) {
egg_warning ("waiting for second install file to finish");
@@ -733,10 +737,6 @@ pk_console_install_stuff (PkClient *client, gchar **packages, GError **error)
/* convert to strv */
package_ids = pk_ptr_array_to_strv (array_packages);
- /* save for untrusted callback */
- g_strfreev (untrusted_strv_cache);
- untrusted_strv_cache = g_strdupv (files);
-
/* reset */
ret = pk_client_reset (client, &error_local);
if (!ret) {
@@ -746,7 +746,7 @@ pk_console_install_stuff (PkClient *client, gchar **packages, GError **error)
goto out;
}
- ret = pk_client_install_packages (client, only_trusted, package_ids, &error_local);
+ ret = pk_client_install_packages (client, TRUE, package_ids, &error_local);
if (!ret) {
/* TRANSLATORS: There was an error installing the packages. The detailed error follows */
*error = g_error_new (1, 0, _("This tool could not install the packages: %s"), error_local->message);
@@ -760,10 +760,6 @@ pk_console_install_stuff (PkClient *client, gchar **packages, GError **error)
/* convert to strv */
files = pk_ptr_array_to_strv (array_files);
- /* save for untrusted callback */
- g_strfreev (untrusted_strv_cache);
- untrusted_strv_cache = g_strdupv (files);
-
/* reset */
ret = pk_client_reset (client, &error_local);
if (!ret) {
@@ -773,7 +769,7 @@ pk_console_install_stuff (PkClient *client, gchar **packages, GError **error)
goto out;
}
- ret = pk_client_install_files (client, only_trusted, files, &error_local);
+ ret = pk_client_install_files (client, TRUE, files, &error_local);
if (!ret) {
/* TRANSLATORS: There was an error installing the files. The detailed error follows */
*error = g_error_new (1, 0, _("This tool could not install the files: %s"), error_local->message);
@@ -861,7 +857,7 @@ pk_console_remove_packages (PkClient *client, gchar **packages, GError **error)
goto out;
}
- ret = pk_client_reset (client_task, &error_local);
+ ret = pk_client_reset (client_sync, &error_local);
if (!ret) {
/* TRANSLATORS: There was a programming error that shouldn't happen. The detailed error follows */
*error = g_error_new (1, 0, _("Internal error: %s"), error_local->message);
@@ -871,14 +867,14 @@ pk_console_remove_packages (PkClient *client, gchar **packages, GError **error)
egg_debug ("Getting installed requires for %s", package_ids[0]);
/* see if any packages require this one */
- ret = pk_client_get_requires (client_task, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), package_ids, TRUE, error);
+ ret = pk_client_get_requires (client_sync, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), package_ids, TRUE, error);
if (!ret) {
egg_warning ("failed to get requires");
goto out;
}
/* see how many packages there are */
- list_single = pk_client_get_package_list (client_task);
+ list_single = pk_client_get_package_list (client_sync);
pk_obj_list_add_list (PK_OBJ_LIST(list), PK_OBJ_LIST(list_single));
g_object_unref (list_single);
@@ -1022,11 +1018,6 @@ pk_console_update_package (PkClient *client, const gchar *package, GError **erro
}
package_ids = pk_package_ids_from_id (package_id);
-
- /* save for untrusted callback */
- g_strfreev (untrusted_strv_cache);
- untrusted_strv_cache = g_strdupv (package_ids);
-
ret = pk_client_update_packages (client, TRUE, package_ids, error);
if (!ret) {
/* TRANSLATORS: There was an error getting the list of files for the package. The detailed error follows */
@@ -1180,7 +1171,7 @@ pk_console_list_create (PkClient *client, const gchar *file, GError **error)
g_print ("%s...\n", _("Getting package list"));
/* get all installed packages and save it to disk */
- ret = pk_client_get_packages (client_task, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), &error_local);
+ ret = pk_client_get_packages (client_sync, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), &error_local);
if (!ret) {
/* TRANSLATORS: There was an error getting the list of packages. The detailed error follows */
*error = g_error_new (1, 0, _("This tool could not get package list: %s"), error_local->message);
@@ -1189,7 +1180,7 @@ pk_console_list_create (PkClient *client, const gchar *file, GError **error)
}
/* save list to disk */
- list = pk_client_get_package_list (client_task);
+ list = pk_client_get_package_list (client_sync);
ret = pk_obj_list_to_file (PK_OBJ_LIST(list), file);
g_object_unref (list);
if (!ret) {
@@ -1236,7 +1227,7 @@ pk_console_list_diff (PkClient *client, const gchar *file, GError **error)
g_print ("%s...\n", _("Getting package list"));
/* get all installed packages */
- ret = pk_client_get_packages (client_task, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), &error_local);
+ ret = pk_client_get_packages (client_sync, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), &error_local);
if (!ret) {
/* TRANSLATORS: There was an error getting the list of packages. The detailed error follows */
*error = g_error_new (1, 0, _("This tool could not get package list: %s"), error_local->message);
@@ -1245,7 +1236,7 @@ pk_console_list_diff (PkClient *client, const gchar *file, GError **error)
}
/* get two copies of the list */
- list = pk_client_get_package_list (client_task);
+ list = pk_client_get_package_list (client_sync);
list_copy = pk_package_list_new ();
pk_obj_list_add_list (PK_OBJ_LIST(list_copy), PK_OBJ_LIST(list));
@@ -1311,7 +1302,7 @@ pk_console_list_install (PkClient *client, const gchar *file, GError **error)
g_print ("%s...\n", _("Getting package list"));
/* get all installed packages */
- ret = pk_client_get_packages (client_task, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), &error_local);
+ ret = pk_client_get_packages (client_sync, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), &error_local);
if (!ret) {
/* TRANSLATORS: There was an error getting the list of packages. The detailed error follows */
*error = g_error_new (1, 0, _("This tool could not get package list: %s"), error_local->message);
@@ -1320,7 +1311,7 @@ pk_console_list_install (PkClient *client, const gchar *file, GError **error)
}
/* get two copies of the list */
- list = pk_client_get_package_list (client_task);
+ list = pk_client_get_package_list (client_sync);
/* get installed copy */
new = pk_package_list_new ();
@@ -1433,44 +1424,20 @@ pk_console_get_update_detail (PkClient *client, const gchar *package, GError **e
static void
pk_console_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gchar *details, gpointer data)
{
- gboolean ret = TRUE;
PkRoleEnum role;
- GError *error = NULL;
pk_client_get_role (client, &role, NULL, NULL);
/* handled */
if (need_requeue) {
- if (error_code == PK_ERROR_ENUM_GPG_FAILURE ||
- error_code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT) {
+ if (error_code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT ||
+ pk_error_code_is_need_untrusted (error_code)) {
egg_debug ("ignoring %s error as handled", pk_error_enum_to_text (error_code));
return;
}
egg_warning ("set requeue, but did not handle error");
}
- /* do we need to do the untrusted action */
- if (pk_error_code_is_need_untrusted (error_code) && only_trusted) {
- egg_debug ("need to try again with only_trusted FALSE");
- only_trusted = FALSE;
-
- if (role == PK_ROLE_ENUM_INSTALL_FILES)
- ret = pk_client_install_files (client_trusted, only_trusted, untrusted_strv_cache, &error);
- else if (role == PK_ROLE_ENUM_INSTALL_PACKAGES)
- ret = pk_client_install_packages (client_trusted, only_trusted, untrusted_strv_cache, &error);
- else if (role == PK_ROLE_ENUM_UPDATE_PACKAGES)
- ret = pk_client_update_packages (client_trusted, only_trusted, untrusted_strv_cache, &error);
- else if (role == PK_ROLE_ENUM_UPDATE_SYSTEM)
- ret = pk_client_update_system (client_trusted, only_trusted, &error);
-
- /* we succeeded, so wait for the requeue */
- if (!ret) {
- egg_warning ("failed to install package second time: %s", error->message);
- g_error_free (error);
- }
- need_requeue = ret;
- }
-
if (awaiting_space)
g_print ("\n");
/* TRANSLATORS: This was an unhandled error, and we don't have _any_ context */
@@ -1583,7 +1550,7 @@ pk_console_repo_signature_required_cb (PkClient *client, const gchar *package_id
/* install signature */
egg_debug ("install signature %s", key_id);
- ret = pk_client_install_signature (client_signature, PK_SIGTYPE_ENUM_GPG,
+ ret = pk_client_install_signature (client_secondary, PK_SIGTYPE_ENUM_GPG,
key_id, package_id, &error);
/* we succeeded, so wait for the requeue */
if (!ret) {
@@ -1628,7 +1595,7 @@ pk_console_eula_required_cb (PkClient *client, const gchar *eula_id, const gchar
/* accept eula */
egg_debug ("accept eula %s", eula_id);
- ret = pk_client_accept_eula (client_signature, eula_id, &error);
+ ret = pk_client_accept_eula (client_secondary, eula_id, &error);
/* we succeeded, so wait for the requeue */
if (!ret) {
egg_warning ("failed to accept eula: %s", error->message);
@@ -1671,18 +1638,18 @@ pk_console_sigint_handler (int sig)
signal (SIGINT, SIG_DFL);
/* cancel any tasks */
- pk_client_get_role (client_async, &role, NULL, NULL);
+ pk_client_get_role (client_primary, &role, NULL, NULL);
if (role != PK_ROLE_ENUM_UNKNOWN) {
- ret = pk_client_cancel (client_async, &error);
+ ret = pk_client_cancel (client_primary, &error);
if (!ret) {
egg_warning ("failed to cancel normal client: %s", error->message);
g_error_free (error);
error = NULL;
}
}
- pk_client_get_role (client_task, &role, NULL, NULL);
+ pk_client_get_role (client_sync, &role, NULL, NULL);
if (role != PK_ROLE_ENUM_UNKNOWN) {
- ret = pk_client_cancel (client_task, &error);
+ ret = pk_client_cancel (client_sync, &error);
if (!ret) {
egg_warning ("failed to cancel task client: %s", error->message);
g_error_free (error);
@@ -1869,59 +1836,53 @@ main (int argc, char *argv[])
g_signal_connect (pconnection, "connection-changed",
G_CALLBACK (pk_connection_changed_cb), loop);
- client_async = pk_client_new ();
- pk_client_set_use_buffer (client_async, TRUE, NULL);
- g_signal_connect (client_async, "package",
+ client_primary = pk_client_new ();
+ pk_client_set_use_buffer (client_primary, TRUE, NULL);
+ g_signal_connect (client_primary, "package",
G_CALLBACK (pk_console_package_cb), NULL);
- g_signal_connect (client_async, "transaction",
+ g_signal_connect (client_primary, "transaction",
G_CALLBACK (pk_console_transaction_cb), NULL);
- g_signal_connect (client_async, "distro-upgrade",
+ g_signal_connect (client_primary, "distro-upgrade",
G_CALLBACK (pk_console_distro_upgrade_cb), NULL);
- g_signal_connect (client_async, "category",
+ g_signal_connect (client_primary, "category",
G_CALLBACK (pk_console_category_cb), NULL);
- g_signal_connect (client_async, "details",
+ g_signal_connect (client_primary, "details",
G_CALLBACK (pk_console_details_cb), NULL);
- g_signal_connect (client_async, "files",
+ g_signal_connect (client_primary, "files",
G_CALLBACK (pk_console_files_cb), NULL);
- g_signal_connect (client_async, "repo-signature-required",
+ g_signal_connect (client_primary, "repo-signature-required",
G_CALLBACK (pk_console_repo_signature_required_cb), NULL);
- g_signal_connect (client_async, "eula-required",
+ g_signal_connect (client_primary, "eula-required",
G_CALLBACK (pk_console_eula_required_cb), NULL);
- g_signal_connect (client_async, "update-detail",
+ g_signal_connect (client_primary, "update-detail",
G_CALLBACK (pk_console_update_detail_cb), NULL);
- g_signal_connect (client_async, "repo-detail",
+ g_signal_connect (client_primary, "repo-detail",
G_CALLBACK (pk_console_repo_detail_cb), NULL);
- g_signal_connect (client_async, "progress-changed",
+ g_signal_connect (client_primary, "progress-changed",
G_CALLBACK (pk_console_progress_changed_cb), NULL);
- g_signal_connect (client_async, "finished",
+ g_signal_connect (client_primary, "finished",
G_CALLBACK (pk_console_finished_cb), NULL);
- g_signal_connect (client_async, "destroy",
+ g_signal_connect (client_primary, "destroy",
G_CALLBACK (pk_console_destroy_cb), NULL);
- g_signal_connect (client_async, "require-restart",
+ g_signal_connect (client_primary, "require-restart",
G_CALLBACK (pk_console_require_restart_cb), NULL);
- g_signal_connect (client_async, "error-code",
+ g_signal_connect (client_primary, "error-code",
G_CALLBACK (pk_console_error_code_cb), NULL);
- g_signal_connect (client_async, "message",
+ g_signal_connect (client_primary, "message",
G_CALLBACK (pk_watch_message_cb), NULL);
- client_task = pk_client_new ();
- pk_client_set_use_buffer (client_task, TRUE, NULL);
- pk_client_set_synchronous (client_task, TRUE, NULL);
- g_signal_connect (client_task, "finished",
+ client_sync = pk_client_new ();
+ pk_client_set_use_buffer (client_sync, TRUE, NULL);
+ pk_client_set_synchronous (client_sync, TRUE, NULL);
+ g_signal_connect (client_sync, "finished",
G_CALLBACK (pk_console_finished_cb), NULL);
- g_signal_connect (client_task, "message",
+ g_signal_connect (client_sync, "message",
G_CALLBACK (pk_watch_message_cb), NULL);
- g_signal_connect (client_task, "destroy",
+ g_signal_connect (client_sync, "destroy",
G_CALLBACK (pk_console_destroy_cb), NULL);
- client_trusted = pk_client_new ();
- g_signal_connect (client_trusted, "finished",
- G_CALLBACK (pk_console_install_files_finished_cb), NULL);
- g_signal_connect (client_trusted, "error-code",
- G_CALLBACK (pk_console_error_code_cb), NULL);
-
- client_signature = pk_client_new ();
- g_signal_connect (client_signature, "finished",
+ client_secondary = pk_client_new ();
+ g_signal_connect (client_secondary, "finished",
G_CALLBACK (pk_console_signature_finished_cb), NULL);
/* check filter */
@@ -1956,7 +1917,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A search term is required"));
goto out;
}
- ret = pk_client_search_name (client_async, filters, details, &error);
+ ret = pk_client_search_name (client_primary, filters, details, &error);
} else if (strcmp (value, "details") == 0) {
if (details == NULL) {
@@ -1964,7 +1925,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A search term is required"));
goto out;
}
- ret = pk_client_search_details (client_async, filters, details, &error);
+ ret = pk_client_search_details (client_primary, filters, details, &error);
} else if (strcmp (value, "group") == 0) {
if (details == NULL) {
@@ -1972,7 +1933,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A search term is required"));
goto out;
}
- ret = pk_client_search_group (client_async, filters, details, &error);
+ ret = pk_client_search_group (client_primary, filters, details, &error);
} else if (strcmp (value, "file") == 0) {
if (details == NULL) {
@@ -1980,7 +1941,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A search term is required"));
goto out;
}
- ret = pk_client_search_file (client_async, filters, details, &error);
+ ret = pk_client_search_file (client_primary, filters, details, &error);
} else {
/* TRANSLATORS: the search type was provided, but invalid */
error = g_error_new (1, 0, "%s", _("Invalid search type"));
@@ -1992,7 +1953,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A package name or filename to install is required"));
goto out;
}
- ret = pk_console_install_stuff (client_async, argv, &error);
+ ret = pk_console_install_stuff (client_primary, argv, &error);
} else if (strcmp (mode, "install-sig") == 0) {
if (value == NULL || details == NULL || parameter == NULL) {
@@ -2000,7 +1961,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A type, key_id and package_id are required"));
goto out;
}
- ret = pk_client_install_signature (client_async, PK_SIGTYPE_ENUM_GPG, details, parameter, &error);
+ ret = pk_client_install_signature (client_primary, PK_SIGTYPE_ENUM_GPG, details, parameter, &error);
} else if (strcmp (mode, "remove") == 0) {
if (value == NULL) {
@@ -2008,7 +1969,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A package name to remove is required"));
goto out;
}
- ret = pk_console_remove_packages (client_async, argv, &error);
+ ret = pk_console_remove_packages (client_primary, argv, &error);
} else if (strcmp (mode, "download") == 0) {
if (value == NULL || details == NULL) {
/* TRANSLATORS: the user did not specify anything about what to download or where */
@@ -2021,14 +1982,14 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s: %s", _("Directory not found"), value);
goto out;
}
- ret = pk_console_download_packages (client_async, argv, value, &error);
+ ret = pk_console_download_packages (client_primary, argv, value, &error);
} else if (strcmp (mode, "accept-eula") == 0) {
if (value == NULL) {
/* TRANSLATORS: geeky error, 99.9999% of users won't see this */
error = g_error_new (1, 0, "%s", _("A licence identifier (eula-id) is required"));
goto out;
}
- ret = pk_client_accept_eula (client_async, value, &error);
+ ret = pk_client_accept_eula (client_primary, value, &error);
maybe_sync = FALSE;
} else if (strcmp (mode, "rollback") == 0) {
@@ -2037,14 +1998,14 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A transaction identifier (tid) is required"));
goto out;
}
- ret = pk_client_rollback (client_async, value, &error);
+ ret = pk_client_rollback (client_primary, value, &error);
} else if (strcmp (mode, "update") == 0) {
if (value == NULL) {
/* do the system update */
- ret = pk_client_update_system (client_async, TRUE, &error);
+ ret = pk_client_update_system (client_primary, TRUE, &error);
} else {
- ret = pk_console_update_package (client_async, value, &error);
+ ret = pk_console_update_package (client_primary, value, &error);
}
} else if (strcmp (mode, "resolve") == 0) {
@@ -2053,7 +2014,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A package name to resolve is required"));
goto out;
}
- ret = pk_client_resolve (client_async, filters, argv+2, &error);
+ ret = pk_client_resolve (client_primary, filters, argv+2, &error);
} else if (strcmp (mode, "repo-enable") == 0) {
if (value == NULL) {
@@ -2061,7 +2022,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A repository name is required"));
goto out;
}
- ret = pk_client_repo_enable (client_async, value, TRUE, &error);
+ ret = pk_client_repo_enable (client_primary, value, TRUE, &error);
} else if (strcmp (mode, "repo-disable") == 0) {
if (value == NULL) {
@@ -2069,7 +2030,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A repository name is required"));
goto out;
}
- ret = pk_client_repo_enable (client_async, value, FALSE, &error);
+ ret = pk_client_repo_enable (client_primary, value, FALSE, &error);
} else if (strcmp (mode, "repo-set-data") == 0) {
if (value == NULL || details == NULL || parameter == NULL) {
@@ -2077,10 +2038,10 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A repo name, parameter and value are required"));
goto out;
}
- ret = pk_client_repo_set_data (client_async, value, details, parameter, &error);
+ ret = pk_client_repo_set_data (client_primary, value, details, parameter, &error);
} else if (strcmp (mode, "repo-list") == 0) {
- ret = pk_client_get_repo_list (client_async, filters, &error);
+ ret = pk_client_get_repo_list (client_primary, filters, &error);
} else if (strcmp (mode, "get-time") == 0) {
PkRoleEnum role;
@@ -2111,10 +2072,10 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A package name is required"));
goto out;
}
- ret = pk_console_get_depends (client_async, filters, value, &error);
+ ret = pk_console_get_depends (client_primary, filters, value, &error);
} else if (strcmp (mode, "get-distro-upgrades") == 0) {
- ret = pk_client_get_distro_upgrades (client_async, &error);
+ ret = pk_client_get_distro_upgrades (client_primary, &error);
} else if (strcmp (mode, "get-update-detail") == 0) {
if (value == NULL) {
@@ -2122,7 +2083,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A package name is required"));
goto out;
}
- ret = pk_console_get_update_detail (client_async, value, &error);
+ ret = pk_console_get_update_detail (client_primary, value, &error);
} else if (strcmp (mode, "get-requires") == 0) {
if (value == NULL) {
@@ -2130,7 +2091,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A package name is required"));
goto out;
}
- ret = pk_console_get_requires (client_async, filters, value, &error);
+ ret = pk_console_get_requires (client_primary, filters, value, &error);
} else if (strcmp (mode, "what-provides") == 0) {
if (value == NULL) {
@@ -2138,7 +2099,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A package provide string is required"));
goto out;
}
- ret = pk_client_what_provides (client_async, filters, PK_PROVIDES_ENUM_CODEC, value, &error);
+ ret = pk_client_what_provides (client_primary, filters, PK_PROVIDES_ENUM_CODEC, value, &error);
} else if (strcmp (mode, "get-details") == 0) {
if (value == NULL) {
@@ -2146,7 +2107,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A package name is required"));
goto out;
}
- ret = pk_console_get_details (client_async, value, &error);
+ ret = pk_console_get_details (client_primary, value, &error);
} else if (strcmp (mode, "get-files") == 0) {
if (value == NULL) {
@@ -2154,7 +2115,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A package name is required"));
goto out;
}
- ret = pk_console_get_files (client_async, value, &error);
+ ret = pk_console_get_files (client_primary, value, &error);
} else if (strcmp (mode, "list-create") == 0) {
if (value == NULL) {
@@ -2162,7 +2123,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A list file name to create is required"));
goto out;
}
- ret = pk_console_list_create (client_async, value, &error);
+ ret = pk_console_list_create (client_primary, value, &error);
maybe_sync = FALSE;
} else if (strcmp (mode, "list-diff") == 0) {
@@ -2171,7 +2132,7 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A list file to open is required"));
goto out;
}
- ret = pk_console_list_diff (client_async, value, &error);
+ ret = pk_console_list_diff (client_primary, value, &error);
maybe_sync = FALSE;
} else if (strcmp (mode, "list-install") == 0) {
@@ -2180,16 +2141,16 @@ main (int argc, char *argv[])
error = g_error_new (1, 0, "%s", _("A list file to open is required"));
goto out;
}
- ret = pk_console_list_install (client_async, value, &error);
+ ret = pk_console_list_install (client_primary, value, &error);
} else if (strcmp (mode, "get-updates") == 0) {
- ret = pk_client_get_updates (client_async, filters, &error);
+ ret = pk_client_get_updates (client_primary, filters, &error);
} else if (strcmp (mode, "get-categories") == 0) {
- ret = pk_client_get_categories (client_async, &error);
+ ret = pk_client_get_categories (client_primary, &error);
} else if (strcmp (mode, "get-packages") == 0) {
- ret = pk_client_get_packages (client_async, filters, &error);
+ ret = pk_client_get_packages (client_primary, filters, &error);
} else if (strcmp (mode, "get-actions") == 0) {
text = pk_role_bitfield_to_text (roles);
@@ -2221,12 +2182,12 @@ main (int argc, char *argv[])
ret = TRUE;
} else if (strcmp (mode, "get-transactions") == 0) {
- ret = pk_client_get_old_transactions (client_async, 10, &error);
+ ret = pk_client_get_old_transactions (client_primary, 10, &error);
} else if (strcmp (mode, "refresh") == 0) {
/* special case - this takes a long time, and doesn't do packages */
pk_console_start_bar ("refresh-cache");
- ret = pk_client_refresh_cache (client_async, FALSE, &error);
+ ret = pk_client_refresh_cache (client_primary, FALSE, &error);
} else {
/* TRANSLATORS: The user tried to use an unsupported option on the command line */
@@ -2254,12 +2215,10 @@ out:
g_free (options_help);
g_free (filter);
g_free (summary);
- g_strfreev (untrusted_strv_cache);
g_object_unref (control);
- g_object_unref (client_async);
- g_object_unref (client_task);
- g_object_unref (client_trusted);
- g_object_unref (client_signature);
+ g_object_unref (client_primary);
+ g_object_unref (client_sync);
+ g_object_unref (client_secondary);
return 0;
}
commit b1af926d26e08037e1bf62190cbae55b251832b2
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 15:54:33 2009 +0100
Don't egg_error when we cannot get the PID of a connection, warn instead
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 8e33f12..4637337 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -1322,7 +1322,7 @@ pk_transaction_release_tid (PkTransaction *transaction)
static guint
pk_transaction_get_pid (PkTransaction *transaction, PolkitSubject *subject)
{
- guint pid;
+ guint pid = G_MAXUINT;
gboolean ret;
gchar *sender = NULL;
GError *error = NULL;
@@ -1341,7 +1341,7 @@ pk_transaction_get_pid (PkTransaction *transaction, PolkitSubject *subject)
G_TYPE_UINT, &pid,
G_TYPE_INVALID);
if (!ret) {
- egg_error ("failed to get pid: %s", error->message);
+ egg_warning ("failed to get pid: %s", error->message);
g_error_free (error);
goto out;
}
commit 608968f530df37fa0d83cccec7a6c036396eb8b8
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 15:32:06 2009 +0100
Don't hardcode the StateChangedTimeout's and add them to the config file
diff --git a/etc/PackageKit.conf.in b/etc/PackageKit.conf.in
index 6e8fe42..aba3b06 100644
--- a/etc/PackageKit.conf.in
+++ b/etc/PackageKit.conf.in
@@ -144,3 +144,19 @@ UseUpdateCache=true
# default=false
DeveloperMode=false
+# The time in seconds to wait when we get the StateHasChanged method
+#
+# This should be used when a native tool has been used, and the update UIs
+# should be updated to reflect reality.
+#
+# default=5
+StateChangedTimeoutPriority=5
+
+# The time in seconds to wait after the computer has been resumed or any non
+# package related system event
+#
+# We don't want to be doing an update check at the busy time after a resume
+#
+# default=600
+StateChangedTimeoutNormal=600
+
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 0d88e46..c9983a9 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -64,28 +64,6 @@ static void pk_engine_finalize (GObject *object);
#define PK_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_ENGINE, PkEnginePrivate))
-/**
- * PK_ENGINE_STATE_CHANGED_PRIORITY_TIMEOUT:
- *
- * The timeout in seconds to wait when we get the StateHasChanged method.
- * We don't queue these transactions if one is already in progress.
- *
- * This should be used when a native tool has been used, and the update UI should
- * be updated to reflect reality.
- */
-#define PK_ENGINE_STATE_CHANGED_PRIORITY_TIMEOUT 5 /* seconds */
-
-/**
- * PK_ENGINE_STATE_CHANGED_NORMAL_TIMEOUT:
- *
- * The timeout in seconds to wait when we get the StateHasChanged method (for selected reasons).
- * We don't queue these transactions if one is already in progress.
- *
- * We probably don't want to be doing an update check at the busy time after a resume, or for
- * other non-critical reasons.
- */
-#define PK_ENGINE_STATE_CHANGED_NORMAL_TIMEOUT 10*60 /* seconds */
-
struct PkEnginePrivate
{
GTimer *timer;
@@ -105,8 +83,10 @@ struct PkEnginePrivate
PkBitfield groups;
PkBitfield filters;
gchar *mime_types;
- guint signal_state_priority_timeout;
- guint signal_state_normal_timeout;
+ guint timeout_priority;
+ guint timeout_normal;
+ guint timeout_priority_id;
+ guint timeout_normal_id;
#ifdef USE_SECURITY_POLKIT
PolkitAuthority *authority;
#endif
@@ -356,8 +336,8 @@ pk_engine_state_changed_cb (gpointer data)
pk_notify_updates_changed (engine->priv->notify);
/* reset, now valid */
- engine->priv->signal_state_priority_timeout = 0;
- engine->priv->signal_state_normal_timeout = 0;
+ engine->priv->timeout_priority_id = 0;
+ engine->priv->timeout_normal_id = 0;
/* reset the timer */
pk_engine_reset_timer (engine);
@@ -379,9 +359,9 @@ pk_engine_state_has_changed (PkEngine *engine, const gchar *reason, GError **err
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* have we already scheduled priority? */
- if (engine->priv->signal_state_priority_timeout != 0) {
+ if (engine->priv->timeout_priority_id != 0) {
egg_warning ("Already asked to refresh priority state less than %i seconds ago",
- PK_ENGINE_STATE_CHANGED_PRIORITY_TIMEOUT);
+ engine->priv->timeout_priority);
goto out;
}
@@ -390,25 +370,25 @@ pk_engine_state_has_changed (PkEngine *engine, const gchar *reason, GError **err
is_priority = FALSE;
/* are we normal, and already scheduled normal? */
- if (!is_priority && engine->priv->signal_state_normal_timeout != 0) {
+ if (!is_priority && engine->priv->timeout_normal_id != 0) {
egg_warning ("Already asked to refresh normal state less than %i seconds ago",
- PK_ENGINE_STATE_CHANGED_NORMAL_TIMEOUT);
+ engine->priv->timeout_normal);
goto out;
}
/* are we priority, and already scheduled normal? */
- if (is_priority && engine->priv->signal_state_normal_timeout != 0) {
+ if (is_priority && engine->priv->timeout_normal_id != 0) {
/* clear normal, as we are about to schedule a priority */
- g_source_remove (engine->priv->signal_state_normal_timeout);
- engine->priv->signal_state_normal_timeout = 0; }
+ g_source_remove (engine->priv->timeout_normal_id);
+ engine->priv->timeout_normal_id = 0; }
/* wait a little delay in case we get multiple requests */
if (is_priority)
- engine->priv->signal_state_priority_timeout = g_timeout_add_seconds (PK_ENGINE_STATE_CHANGED_PRIORITY_TIMEOUT,
- pk_engine_state_changed_cb, engine);
+ engine->priv->timeout_priority_id = g_timeout_add_seconds (engine->priv->timeout_priority,
+ pk_engine_state_changed_cb, engine);
else
- engine->priv->signal_state_normal_timeout = g_timeout_add_seconds (PK_ENGINE_STATE_CHANGED_NORMAL_TIMEOUT,
- pk_engine_state_changed_cb, engine);
+ engine->priv->timeout_normal_id = g_timeout_add_seconds (engine->priv->timeout_normal,
+ pk_engine_state_changed_cb, engine);
/* reset the timer */
pk_engine_reset_timer (engine);
@@ -883,8 +863,8 @@ pk_engine_init (PkEngine *engine)
engine->priv->cache = pk_cache_new ();
/* we need to be able to clear this */
- engine->priv->signal_state_priority_timeout = 0;
- engine->priv->signal_state_normal_timeout = 0;
+ engine->priv->timeout_priority_id = 0;
+ engine->priv->timeout_normal_id = 0;
/* get another connection */
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
@@ -922,6 +902,10 @@ pk_engine_init (PkEngine *engine)
engine->priv->proxy_ftp = pk_conf_get_string (engine->priv->conf, "ProxyFTP");
pk_backend_set_proxy (engine->priv->backend, engine->priv->proxy_http, engine->priv->proxy_ftp);
+ /* get the StateHasChanged timeouts */
+ engine->priv->timeout_priority = (guint) pk_conf_get_int (engine->priv->conf, "StateChangedTimeoutPriority");
+ engine->priv->timeout_normal = (guint) pk_conf_get_int (engine->priv->conf, "StateChangedTimeoutNormal");
+
engine->priv->transaction_list = pk_transaction_list_new ();
g_signal_connect (engine->priv->transaction_list, "changed",
G_CALLBACK (pk_engine_transaction_list_changed_cb), engine);
@@ -957,13 +941,13 @@ pk_engine_finalize (GObject *object)
egg_warning ("couldn't unlock the backend");
/* if we set an state changed notifier, clear */
- if (engine->priv->signal_state_priority_timeout != 0) {
- g_source_remove (engine->priv->signal_state_priority_timeout);
- engine->priv->signal_state_priority_timeout = 0;
+ if (engine->priv->timeout_priority_id != 0) {
+ g_source_remove (engine->priv->timeout_priority_id);
+ engine->priv->timeout_priority_id = 0;
}
- if (engine->priv->signal_state_normal_timeout != 0) {
- g_source_remove (engine->priv->signal_state_normal_timeout);
- engine->priv->signal_state_normal_timeout = 0;
+ if (engine->priv->timeout_normal_id != 0) {
+ g_source_remove (engine->priv->timeout_normal_id);
+ engine->priv->timeout_normal_id = 0;
}
/* compulsory gobjects */
commit b0093dc80fb6599c17f22ad4c4e7090a1fe53ce4
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 14:59:22 2009 +0100
Export pk_client_set_only_trusted() as API
diff --git a/lib/packagekit-glib/pk-client.c b/lib/packagekit-glib/pk-client.c
index 01f3935..46888b8 100644
--- a/lib/packagekit-glib/pk-client.c
+++ b/lib/packagekit-glib/pk-client.c
@@ -236,6 +236,26 @@ out:
}
/**
+ * pk_client_set_only_trusted:
+ * @client: a valid #PkClient instance
+ * @only_trusted: only operate on trusted packages
+ *
+ * Set the trusted mode. This is useful when doing pk_client_requeue()
+ *
+ * Return value: %TRUE if the mode was set correctly
+ **/
+gboolean
+pk_client_set_only_trusted (PkClient *client, gboolean only_trusted)
+{
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+ g_return_val_if_fail (client->priv->tid != NULL, FALSE);
+
+ client->priv->cached_only_trusted = only_trusted;
+
+ return TRUE;
+}
+
+/**
* pk_client_get_tid:
* @client: a valid #PkClient instance
*
diff --git a/lib/packagekit-glib/pk-client.h b/lib/packagekit-glib/pk-client.h
index 0d7b264..fcd8975 100644
--- a/lib/packagekit-glib/pk-client.h
+++ b/lib/packagekit-glib/pk-client.h
@@ -177,6 +177,8 @@ gboolean pk_client_set_use_buffer (PkClient *client,
gboolean pk_client_set_synchronous (PkClient *client,
gboolean synchronous,
GError **error);
+gboolean pk_client_set_only_trusted (PkClient *client,
+ gboolean only_trusted);
gboolean pk_client_set_timeout (PkClient *client,
gint timeout,
GError **error);
commit 8f030623ff6390c0ee06b30a8871103002cea533
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 14:58:50 2009 +0100
Correct the name of the policykit1 role
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 25505e7..8e33f12 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -1652,7 +1652,7 @@ pk_transaction_role_to_action_untrusted (PkRoleEnum role)
case PK_ROLE_ENUM_UPDATE_PACKAGES:
case PK_ROLE_ENUM_UPDATE_SYSTEM:
case PK_ROLE_ENUM_INSTALL_FILES:
- policy = "org.freedesktop.packagekit.install-untrusted";
+ policy = "org.freedesktop.packagekit.package-install-untrusted";
break;
default:
break;
commit a9f935ae5557697a5778a57ff4a7ed129199f2a3
Merge: 5e63e9d... b7421d8...
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 14:28:29 2009 +0100
Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit
commit 5e63e9d309c3264f4ed39e2c1e2cc56c62a6f180
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 14:19:54 2009 +0100
Add a convenience Exit enum, NEED_UNTRUSTED, and set for the correct error enums
diff --git a/lib/packagekit-glib/pk-enum.c b/lib/packagekit-glib/pk-enum.c
index f068de2..ef483b4 100644
--- a/lib/packagekit-glib/pk-enum.c
+++ b/lib/packagekit-glib/pk-enum.c
@@ -49,6 +49,7 @@ static const PkEnumMatch enum_exit[] = {
{PK_EXIT_ENUM_EULA_REQUIRED, "eula-required"},
{PK_EXIT_ENUM_MEDIA_CHANGE_REQUIRED, "media-change-required"},
{PK_EXIT_ENUM_KILLED, "killed"},
+ {PK_EXIT_ENUM_NEED_UNTRUSTED, "need-untrusted"},
{0, NULL}
};
diff --git a/lib/packagekit-glib/pk-enum.h b/lib/packagekit-glib/pk-enum.h
index e086341..0e49cb2 100644
--- a/lib/packagekit-glib/pk-enum.h
+++ b/lib/packagekit-glib/pk-enum.h
@@ -151,6 +151,7 @@ typedef enum {
PK_EXIT_ENUM_EULA_REQUIRED,
PK_EXIT_ENUM_KILLED, /* when we forced the cancel, but had to SIGKILL */
PK_EXIT_ENUM_MEDIA_CHANGE_REQUIRED,
+ PK_EXIT_ENUM_NEED_UNTRUSTED,
PK_EXIT_ENUM_UNKNOWN
} PkExitEnum;
diff --git a/src/pk-backend.c b/src/pk-backend.c
index c420439..5f8d96c 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1414,11 +1414,12 @@ out:
* pk_backend_error_code:
**/
gboolean
-pk_backend_error_code (PkBackend *backend, PkErrorCodeEnum code, const gchar *format, ...)
+pk_backend_error_code (PkBackend *backend, PkErrorCodeEnum error_code, const gchar *format, ...)
{
va_list args;
gchar *buffer;
gboolean ret = TRUE;
+ gboolean need_untrusted;
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
@@ -1445,11 +1446,15 @@ pk_backend_error_code (PkBackend *backend, PkErrorCodeEnum code, const gchar *fo
backend->priv->signal_error_timeout = g_timeout_add (PK_BACKEND_FINISHED_ERROR_TIMEOUT,
pk_backend_error_timeout_delay_cb, backend);
- /* we mark any transaction with errors as failed */
- pk_backend_set_exit_code (backend, PK_EXIT_ENUM_FAILED);
+ /* some error codes have a different exit code */
+ need_untrusted = pk_error_code_is_need_untrusted (error_code);
+ if (need_untrusted)
+ pk_backend_set_exit_code (backend, PK_EXIT_ENUM_NEED_UNTRUSTED);
+ else
+ pk_backend_set_exit_code (backend, PK_EXIT_ENUM_FAILED);
- egg_debug ("emit error-code %s, %s", pk_error_enum_to_text (code), buffer);
- g_signal_emit (backend, signals [PK_BACKEND_ERROR_CODE], 0, code, buffer);
+ egg_debug ("emit error-code %s, %s", pk_error_enum_to_text (error_code), buffer);
+ g_signal_emit (backend, signals [PK_BACKEND_ERROR_CODE], 0, error_code, buffer);
out:
g_free (buffer);
commit c0a26b4cd895e85dc55eca2a4d75c6805125c1f1
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 14:18:51 2009 +0100
Export pk_error_code_is_need_untrusted() into the public API
diff --git a/client/pk-console.c b/client/pk-console.c
index 790475d..a2464c2 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -1428,29 +1428,6 @@ pk_console_get_update_detail (PkClient *client, const gchar *package, GError **e
}
/**
- * pk_console_is_error_code_retry_trusted:
- *
- * Returns if the error code suggests to try with only_trusted %FALSE
- **/
-static gboolean
-pk_console_is_error_code_retry_trusted (PkErrorCodeEnum error_code)
-{
- gboolean ret = FALSE;
- switch (error_code) {
- case PK_ERROR_ENUM_GPG_FAILURE:
- case PK_ERROR_ENUM_BAD_GPG_SIGNATURE:
- case PK_ERROR_ENUM_MISSING_GPG_SIGNATURE:
- case PK_ERROR_ENUM_CANNOT_INSTALL_REPO_UNSIGNED:
- case PK_ERROR_ENUM_CANNOT_UPDATE_REPO_UNSIGNED:
- ret = TRUE;
- break;
- default:
- break;
- }
- return ret;
-}
-
-/**
* pk_console_error_code_cb:
**/
static void
@@ -1473,7 +1450,7 @@ pk_console_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gc
}
/* do we need to do the untrusted action */
- if (pk_console_is_error_code_retry_trusted (error_code) && only_trusted) {
+ if (pk_error_code_is_need_untrusted (error_code) && only_trusted) {
egg_debug ("need to try again with only_trusted FALSE");
only_trusted = FALSE;
diff --git a/lib/packagekit-glib/pk-common.c b/lib/packagekit-glib/pk-common.c
index 3815be5..abf3580 100644
--- a/lib/packagekit-glib/pk-common.c
+++ b/lib/packagekit-glib/pk-common.c
@@ -510,6 +510,32 @@ pk_va_list_to_argv (const gchar *string_first, va_list *args)
return array;
}
+/**
+ * pk_error_code_is_need_untrusted:
+ * @error_code: the transactions #PkErrorCodeEnum
+ *
+ * Is this error could be handled with retrying with only_trusted %FALSE.
+ *
+ * Return value: if the error code suggests to try with only_trusted %FALSE
+ **/
+gboolean
+pk_error_code_is_need_untrusted (PkErrorCodeEnum error_code)
+{
+ gboolean ret = FALSE;
+ switch (error_code) {
+ case PK_ERROR_ENUM_GPG_FAILURE:
+ case PK_ERROR_ENUM_BAD_GPG_SIGNATURE:
+ case PK_ERROR_ENUM_MISSING_GPG_SIGNATURE:
+ case PK_ERROR_ENUM_CANNOT_INSTALL_REPO_UNSIGNED:
+ case PK_ERROR_ENUM_CANNOT_UPDATE_REPO_UNSIGNED:
+ ret = TRUE;
+ break;
+ default:
+ break;
+ }
+ return ret;
+}
+
/***************************************************************************
*** MAKE CHECK TESTS ***
***************************************************************************/
diff --git a/lib/packagekit-glib/pk-common.h b/lib/packagekit-glib/pk-common.h
index ee67ca3..4555cee 100644
--- a/lib/packagekit-glib/pk-common.h
+++ b/lib/packagekit-glib/pk-common.h
@@ -27,6 +27,7 @@
#define __PK_COMMON_H
#include <glib-object.h>
+#include "pk-enum.h"
G_BEGIN_DECLS
@@ -90,6 +91,7 @@ gchar *pk_iso8601_from_date (const GDate *date);
GDate *pk_iso8601_to_date (const gchar *iso_date);
gchar *pk_get_distro_id (void)
G_GNUC_WARN_UNUSED_RESULT;
+gboolean pk_error_code_is_need_untrusted (PkErrorCodeEnum error_code);
G_END_DECLS
commit b7421d8e3066bc932efe1bf693de870f9ae0cd4a
Author: nippur <nippur at fedoraproject.org>
Date: Wed Jun 17 12:14:22 2009 +0000
Sending translation for Dutch
diff --git a/po/nl.po b/po/nl.po
index fcfbe9d..5846c4b 100644
--- a/po/nl.po
+++ b/po/nl.po
@@ -1,11 +1,11 @@
-# translation of packagekit.master.nl.po to Dutch
+# translation of packagekit.master.po to Dutch
# R.E. van der Luit <nippur at fedoraproject.org>, 2009.
msgid ""
msgstr ""
"Project-Id-Version: packagekit.master.nl\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-04-12 08:05+0000\n"
-"PO-Revision-Date: 2009-04-12 12:21+0200\n"
+"POT-Creation-Date: 2009-06-17 08:13+0000\n"
+"PO-Revision-Date: 2009-06-17 14:16+0200\n"
"Last-Translator: R.E. van der Luit <nippur at fedoraproject.org>\n"
"Language-Team: Dutch <nippur at fedoraproject.org>\n"
"MIME-Version: 1.0\n"
@@ -13,7 +13,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-Language: Dutch\n"
-"X-Generator: Lokalize 0.3\n"
+"X-Generator: KBabel 1.11.4\n"
#. TRANSLATORS: this is an atomic transaction
#: ../client/pk-console.c:234
@@ -495,8 +495,8 @@ msgstr "Subopdrachten:"
#. TRANSLATORS: if we should show debugging data
#: ../client/pk-console.c:1767 ../client/pk-generate-pack.c:185
#: ../client/pk-monitor.c:125
-#: ../contrib/command-not-found/pk-command-not-found.c:518
-#: ../src/pk-main.c:199
+#: ../contrib/command-not-found/pk-command-not-found.c:521
+#: ../src/pk-main.c:211
msgid "Show extra debugging information"
msgstr "Extra debuginformatie tonen"
@@ -558,8 +558,7 @@ msgstr "Een te verwijderen pakketnaam is vereist"
#. TRANSLATORS: the user did not specify anything about what to download or where
#: ../client/pk-console.c:1977
-msgid ""
-"A destination directory and then the package names to download are required"
+msgid "A destination directory and then the package names to download are required"
msgstr "Een doelmap en dan de namen van te downloaden pakketten zijn vereist."
#. TRANSLATORS: the directory does not exist, so we can't continue
@@ -605,8 +604,7 @@ msgstr "Een correcte rol is vereist"
#. TRANSLATORS: we keep a database updated with the time that an action was last executed
#: ../client/pk-console.c:2064
msgid "Failed to get the time since this action was last completed"
-msgstr ""
-"Verkrijgen van de tijd tussen laatste actie en deze actie is niet gelukt"
+msgstr "Verkrijgen van de tijd tussen laatste actie en deze actie is niet gelukt"
#. TRANSLATORS: The user did not provide a package name
#. TRANSLATORS: This is when the user fails to supply the package name
@@ -665,13 +663,11 @@ msgstr "Afhankelijkheden aan het downloaden"
#. TRANSLATORS: we can exclude certain packages (glibc) when we know they'll exist on the target
#: ../client/pk-generate-pack.c:188
msgid "Set the file name of dependencies to be excluded"
-msgstr ""
-"Zet de bestandsnamen van afhankelijkheden die moeten worden uitgesloten"
+msgstr "Zet de bestandsnamen van afhankelijkheden die moeten worden uitgesloten"
#. TRANSLATORS: the output location
#: ../client/pk-generate-pack.c:191
-msgid ""
-"The output file or directory (the current directory is used if ommitted)"
+msgid "The output file or directory (the current directory is used if ommitted)"
msgstr ""
"Het doelbestand of map (huidige map wordt gebruikt als dit niet wordt "
"opgegeven)"
@@ -707,56 +703,62 @@ msgstr "Een doelmap of bestandsnaam is vereist"
msgid "The package manager cannot perform this type of operation."
msgstr "De package manager kan dit type operatie niet uitvoeren."
+#. TRANSLATORS: This is when the distro didn't include libarchive support into PK
+#: ../client/pk-generate-pack.c:280
+msgid ""
+"Service packs cannot be created as PackageKit was not built with libarchive "
+"support."
+msgstr "Service Packs kon niet worden gecreëerd omdat PackageKit niet met libarchive ondersteuning is gebouwd."
+
#. TRANSLATORS: the user specified an absolute path, but didn't get the extension correct
-#: ../client/pk-generate-pack.c:285
+#: ../client/pk-generate-pack.c:291
msgid "If specifying a file, the service pack name must end with"
-msgstr ""
-"Bij het specificeren van een bestand moet de servicepacknaam eindigen met"
+msgstr "Bij het specificeren van een bestand moet de servicepacknaam eindigen met"
#. TRANSLATORS: This is when file already exists
-#: ../client/pk-generate-pack.c:301
+#: ../client/pk-generate-pack.c:307
msgid "A pack with the same name already exists, do you want to overwrite it?"
msgstr "Een pack met dezelfde naam bestaat reeds, wilt u deze overschrijven?"
#. TRANSLATORS: This is when the pack was not overwritten
-#: ../client/pk-generate-pack.c:304
+#: ../client/pk-generate-pack.c:310
msgid "The pack was not overwritten."
msgstr "Het pack werd niet overschreven."
#. TRANSLATORS: This is when the temporary directory cannot be created, the directory name follows
-#: ../client/pk-generate-pack.c:317
+#: ../client/pk-generate-pack.c:323
msgid "Failed to create directory:"
msgstr "Aanmaken map mislukt:"
#. TRANSLATORS: This is when the list of packages from the remote computer cannot be opened
-#: ../client/pk-generate-pack.c:327
+#: ../client/pk-generate-pack.c:333
msgid "Failed to open package list."
msgstr "Pakketlijst openen is niet gelukt."
#. TRANSLATORS: The package name is being matched up to available packages
-#: ../client/pk-generate-pack.c:338
+#: ../client/pk-generate-pack.c:344
msgid "Finding package name."
msgstr "Pakketnaam wordt opgezocht."
#. TRANSLATORS: This is when the package cannot be found in any software source. The detailed error follows
-#: ../client/pk-generate-pack.c:342
+#: ../client/pk-generate-pack.c:348
#, c-format
msgid "Failed to find package '%s': %s"
msgstr "Pakket '%s' niet gevonden: %s"
#. TRANSLATORS: This is telling the user we are in the process of making the pack
-#: ../client/pk-generate-pack.c:359
+#: ../client/pk-generate-pack.c:365
msgid "Creating service pack..."
msgstr "Servicepack wordt aangemaakt...."
#. TRANSLATORS: we succeeded in making the file
-#: ../client/pk-generate-pack.c:366
+#: ../client/pk-generate-pack.c:372
#, c-format
msgid "Service pack created '%s'"
msgstr "Servicepack aangemaakt '%s'"
#. TRANSLATORS: we failed to make te file
-#: ../client/pk-generate-pack.c:371
+#: ../client/pk-generate-pack.c:377
#, c-format
msgid "Failed to create '%s': %s"
msgstr "'%s' aanmaken niet gelukt: %s"
@@ -788,125 +790,125 @@ msgid "Please enter a number from 1 to %i: "
msgstr "Voer een nummer in van 1 tot %i: "
#. TRANSLATORS: we failed to find the package, this shouldn't happen
-#: ../contrib/command-not-found/pk-command-not-found.c:369
+#: ../contrib/command-not-found/pk-command-not-found.c:372
msgid "Failed to search for file"
msgstr "Zoeken naar bestand niet gelukt"
#. TRANSLATORS: we failed to launch the executable, the error follows
-#: ../contrib/command-not-found/pk-command-not-found.c:493
+#: ../contrib/command-not-found/pk-command-not-found.c:496
msgid "Failed to launch:"
msgstr "Starten mislukt:"
#. TRANSLATORS: tool that gets called when the command is not found
-#: ../contrib/command-not-found/pk-command-not-found.c:534
+#: ../contrib/command-not-found/pk-command-not-found.c:537
msgid "PackageKit Command Not Found"
msgstr "PackageKit Command niet gevonden"
#. TRANSLATORS: the prefix of all the output telling the user why it's not executing
-#: ../contrib/command-not-found/pk-command-not-found.c:556
+#: ../contrib/command-not-found/pk-command-not-found.c:560
msgid "Command not found."
msgstr "Commando niet gevonden."
#. TRANSLATORS: tell the user what we think the command is
-#: ../contrib/command-not-found/pk-command-not-found.c:563
+#: ../contrib/command-not-found/pk-command-not-found.c:567
msgid "Similar command is:"
msgstr "Een gelijkend commando is:"
#. TRANSLATORS: Ask the user if we should run the similar command
-#: ../contrib/command-not-found/pk-command-not-found.c:572
+#: ../contrib/command-not-found/pk-command-not-found.c:576
msgid "Run similar command:"
msgstr "Start gelijkend commando:"
#. TRANSLATORS: show the user a list of commands that they could have meant
#. TRANSLATORS: show the user a list of commands we could run
-#: ../contrib/command-not-found/pk-command-not-found.c:584
-#: ../contrib/command-not-found/pk-command-not-found.c:593
+#: ../contrib/command-not-found/pk-command-not-found.c:588
+#: ../contrib/command-not-found/pk-command-not-found.c:597
msgid "Similar commands are:"
msgstr "Gelijkende commando's zijn:"
#. TRANSLATORS: ask the user to choose a file to run
-#: ../contrib/command-not-found/pk-command-not-found.c:600
+#: ../contrib/command-not-found/pk-command-not-found.c:604
msgid "Please choose a command to run"
msgstr "Kies alstublieft een commando om te starten"
#. TRANSLATORS: tell the user what package provides the command
-#: ../contrib/command-not-found/pk-command-not-found.c:615
+#: ../contrib/command-not-found/pk-command-not-found.c:619
msgid "The package providing this file is:"
msgstr "Het pakket dat dit bestand levert is:"
#. TRANSLATORS: as the user if we want to install a package to provide the command
-#: ../contrib/command-not-found/pk-command-not-found.c:620
+#: ../contrib/command-not-found/pk-command-not-found.c:624
#, c-format
msgid "Install package '%s' to provide command '%s'?"
msgstr "Pakket '%s' installeren om commando '%s' te verkrijgen?"
#. TRANSLATORS: Show the user a list of packages that provide this command
-#: ../contrib/command-not-found/pk-command-not-found.c:641
+#: ../contrib/command-not-found/pk-command-not-found.c:645
msgid "Packages providing this file are:"
msgstr "Pakketten die dit bestand leveren zijn:"
#. TRANSLATORS: Show the user a list of packages that they can install to provide this command
-#: ../contrib/command-not-found/pk-command-not-found.c:650
+#: ../contrib/command-not-found/pk-command-not-found.c:654
msgid "Suitable packages are:"
msgstr "Geschikte pakketten zijn:"
#. get selection
#. TRANSLATORS: ask the user to choose a file to install
-#: ../contrib/command-not-found/pk-command-not-found.c:658
+#: ../contrib/command-not-found/pk-command-not-found.c:662
msgid "Please choose a package to install"
msgstr "Kies alstublieft een pakket om te installeren"
#. TRANSLATORS: when we are getting data from the daemon
-#: ../contrib/browser-plugin/src/contents.cpp:298
+#: ../contrib/browser-plugin/src/contents.cpp:299
msgid "Getting package information..."
msgstr "Pakketinformatie verkrijgen......"
#. TRANSLATORS: run an applicaiton
-#: ../contrib/browser-plugin/src/contents.cpp:304
+#: ../contrib/browser-plugin/src/contents.cpp:305
#, c-format
msgid "Run %s"
msgstr "Start %s"
#. TRANSLATORS: show the installed version of a package
-#: ../contrib/browser-plugin/src/contents.cpp:310
+#: ../contrib/browser-plugin/src/contents.cpp:311
msgid "Installed version"
msgstr "Geïnstalleerde versie"
#. TRANSLATORS: run the application now
-#: ../contrib/browser-plugin/src/contents.cpp:318
+#: ../contrib/browser-plugin/src/contents.cpp:319
#, c-format
msgid "Run version %s now"
msgstr "Start versie %s nu"
#. TRANSLATORS: run the application now
-#: ../contrib/browser-plugin/src/contents.cpp:324
+#: ../contrib/browser-plugin/src/contents.cpp:325
msgid "Run now"
msgstr "Start nu"
#. TRANSLATORS: update to a new version of the package
-#: ../contrib/browser-plugin/src/contents.cpp:330
+#: ../contrib/browser-plugin/src/contents.cpp:331
#, c-format
msgid "Update to version %s"
msgstr "Update naar versie %s"
#. TRANSLATORS: To install a package
-#: ../contrib/browser-plugin/src/contents.cpp:336
+#: ../contrib/browser-plugin/src/contents.cpp:337
#, c-format
msgid "Install %s now"
msgstr "Installeer %s nu"
#. TRANSLATORS: the version of the package
-#: ../contrib/browser-plugin/src/contents.cpp:339
+#: ../contrib/browser-plugin/src/contents.cpp:340
msgid "Version"
msgstr "Versie"
#. TRANSLATORS: noting found, so can't install
-#: ../contrib/browser-plugin/src/contents.cpp:344
+#: ../contrib/browser-plugin/src/contents.cpp:345
msgid "No packages found for your system"
msgstr "Geen pakketten voor uw systeem gevonden"
#. TRANSLATORS: package is being installed
-#: ../contrib/browser-plugin/src/contents.cpp:349
+#: ../contrib/browser-plugin/src/contents.cpp:350
msgid "Installing..."
msgstr "Aan het installeren......"
@@ -931,15 +933,12 @@ msgid "Authentication is required to accept a EULA"
msgstr "Authenticatie is vereist om een EULA te accepteren"
#: ../policy/org.freedesktop.packagekit.policy.in.h:3
-msgid ""
-"Authentication is required to cancel a task that was not started by yourself"
-msgstr ""
-"Athenticatie is vereist om een taak af te breken die niet door u is gestart"
+msgid "Authentication is required to cancel a task that was not started by yourself"
+msgstr "Athenticatie is vereist om een taak af te breken die niet door u is gestart"
#: ../policy/org.freedesktop.packagekit.policy.in.h:4
msgid "Authentication is required to change software source parameters"
-msgstr ""
-"Athenticatie is vereist om de parameters van de softwarebronnen te wijzigen"
+msgstr "Athenticatie is vereist om de parameters van de softwarebronnen te wijzigen"
#: ../policy/org.freedesktop.packagekit.policy.in.h:5
msgid ""
@@ -1034,8 +1033,7 @@ msgstr "Dit kan twee redenen hebben:"
#. TRANSLATORS: only allowed to be owned by root
#: ../src/pk-main.c:91
msgid "The correct user is not launching the executable (usually root)"
-msgstr ""
-"Het programma wordt niet door de correcte gebruiker gestart (gewoonlijk root)"
+msgstr "Het programma wordt niet door de correcte gebruiker gestart (gewoonlijk root)"
#. TRANSLATORS: or we are installed in a prefix
#: ../src/pk-main.c:93
@@ -1047,48 +1045,47 @@ msgstr ""
"systeemmap:"
#. TRANSLATORS: a backend is the system package tool, e.g. yum, apt
-#: ../src/pk-main.c:193
+#: ../src/pk-main.c:205
msgid "Packaging backend to use, e.g. dummy"
msgstr "Te gebruiken pakketbeheerder, bijvoorbeeld dummy"
#. TRANSLATORS: if we should run in the background
-#: ../src/pk-main.c:196
+#: ../src/pk-main.c:208
msgid "Daemonize and detach from the terminal"
msgstr "Als service starten en van de terminal loskoppelen"
#. TRANSLATORS: if we should not monitor how long we are inactive for
-#: ../src/pk-main.c:202
+#: ../src/pk-main.c:214
msgid "Disable the idle timer"
msgstr "De idle-timer uitschakelen"
#. TRANSLATORS: show version
-#: ../src/pk-main.c:205
+#: ../src/pk-main.c:217
msgid "Show version and exit"
msgstr "Versie tonen en afsluiten"
#. TRANSLATORS: exit after we've started up, used for user profiling
-#: ../src/pk-main.c:208
+#: ../src/pk-main.c:220
msgid "Exit after a small delay"
msgstr "Afsluiten na een kleine vertraging"
#. TRANSLATORS: exit straight away, used for automatic profiling
-#: ../src/pk-main.c:211
+#: ../src/pk-main.c:223
msgid "Exit after the engine has loaded"
msgstr "Afsluiten nadat de verwerkingseenheid is geladen"
#. TRANSLATORS: describing the service that is running
-#: ../src/pk-main.c:226
+#: ../src/pk-main.c:238
msgid "PackageKit service"
msgstr "PackageKit-service"
#. TRANSLATORS: fatal error, dbus is not running
-#: ../src/pk-main.c:263
+#: ../src/pk-main.c:275
msgid "Cannot connect to the system bus"
msgstr "Er kan geen verbinding worden gelegd met de systeembus"
-#. TRANSLATORS: cannot register on system bus, unknown reason
-#: ../src/pk-main.c:313
-#, c-format
+#. TRANSLATORS: cannot register on system bus, unknown reason -- geeky error follows
+#: ../src/pk-main.c:331
msgid "Error trying to start:"
msgstr "Fout bij het proberen te starten:"
commit 4c79fe08684d234f9061889f691ae6d92d0a756f
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 12:55:26 2009 +0100
Add two more error enums to pk_console_is_error_code_retry_trusted
diff --git a/client/pk-console.c b/client/pk-console.c
index d154b64..790475d 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -1437,6 +1437,8 @@ pk_console_is_error_code_retry_trusted (PkErrorCodeEnum error_code)
{
gboolean ret = FALSE;
switch (error_code) {
+ case PK_ERROR_ENUM_GPG_FAILURE:
+ case PK_ERROR_ENUM_BAD_GPG_SIGNATURE:
case PK_ERROR_ENUM_MISSING_GPG_SIGNATURE:
case PK_ERROR_ENUM_CANNOT_INSTALL_REPO_UNSIGNED:
case PK_ERROR_ENUM_CANNOT_UPDATE_REPO_UNSIGNED:
commit 22736666a70ac8750f3080e623437c2fdbbeb604
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 12:34:25 2009 +0100
yum: support the new error codes, and don't warn for untrusted packages anymore
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 025f906..2906985 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -1365,7 +1365,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
pkg = t.po
signed = self._is_package_repo_signed(pkg)
if not signed:
- self.error(ERROR_MISSING_GPG_SIGNATURE, "The package %s will not be updated from unsigned repo %s" % (pkg.name, pkg.repoid), exit=False)
+ self.error(ERROR_CANNOT_UPDATE_REPO_UNSIGNED, "The package %s will not be updated from unsigned repo %s" % (pkg.name, pkg.repoid), exit=False)
return
try:
self._runYumTransaction(allow_skip_broken=True)
@@ -1488,7 +1488,6 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.percentage(0)
self.status(STATUS_RUNNING)
txmbrs = []
- already_warned = False
# if only_trusted is true, it means that we will only update signed files
if only_trusted:
@@ -1506,23 +1505,10 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
txmbr = self.yumbase.selectGroup(grp.groupid)
except Exception, e:
self.error(ERROR_INTERNAL_ERROR, _format_str(traceback.format_exc()))
- for t in txmbr:
- try:
- repo = self.yumbase.repos.getRepo(t.po.repoid)
- except Exception, e:
- self.error(ERROR_INTERNAL_ERROR, _format_str(traceback.format_exc()))
- if not already_warned and not repo.gpgcheck:
- self.message(MESSAGE_UNTRUSTED_PACKAGE, "The untrusted package %s will be installed from %s." % (t.po.name, repo))
- already_warned = True
-
txmbrs.extend(txmbr)
else:
pkg, inst = self._findPackage(package)
if pkg and not inst:
- repo = self.yumbase.repos.getRepo(pkg.repoid)
- if not already_warned and not repo.gpgcheck:
- self.message(MESSAGE_UNTRUSTED_PACKAGE, "The untrusted package %s will be installed from %s." % (pkg.name, repo))
- already_warned = True
txmbr = self.yumbase.install(po=pkg)
txmbrs.extend(txmbr)
if inst:
@@ -1530,11 +1516,11 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
return
if txmbrs:
if only_trusted:
- for t in txmbr:
+ for t in txmbrs:
pkg = t.po
signed = self._is_package_repo_signed(pkg)
if not signed:
- self.error(ERROR_MISSING_GPG_SIGNATURE, "The package %s will not be installed from unsigned repo %s" % (pkg.name, pkg.repoid), exit=False)
+ self.error(ERROR_CANNOT_INSTALL_REPO_UNSIGNED, "The package %s will not be installed from unsigned repo %s" % (pkg.name, pkg.repoid), exit=False)
return
try:
self._runYumTransaction()
@@ -1827,11 +1813,11 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
else:
if txmbrs:
if only_trusted:
- for t in txmbr:
+ for t in txmbrs:
pkg = t.po
signed = self._is_package_repo_signed(pkg)
if not signed:
- self.error(ERROR_MISSING_GPG_SIGNATURE, "The package %s will not be updated from unsigned repo %s" % (pkg.name, pkg.repoid), exit=False)
+ self.error(ERROR_CANNOT_UPDATE_REPO_UNSIGNED, "The package %s will not be updated from unsigned repo %s" % (pkg.name, pkg.repoid), exit=False)
return
try:
self._runYumTransaction(allow_skip_broken=True)
commit 31cabd146769bbe61514d7cbec142a745c0400bd
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 12:33:48 2009 +0100
pkcon: Add a helper to figure out what error codes should be retried
diff --git a/client/pk-console.c b/client/pk-console.c
index 93a67c6..d154b64 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -1428,6 +1428,27 @@ pk_console_get_update_detail (PkClient *client, const gchar *package, GError **e
}
/**
+ * pk_console_is_error_code_retry_trusted:
+ *
+ * Returns if the error code suggests to try with only_trusted %FALSE
+ **/
+static gboolean
+pk_console_is_error_code_retry_trusted (PkErrorCodeEnum error_code)
+{
+ gboolean ret = FALSE;
+ switch (error_code) {
+ case PK_ERROR_ENUM_MISSING_GPG_SIGNATURE:
+ case PK_ERROR_ENUM_CANNOT_INSTALL_REPO_UNSIGNED:
+ case PK_ERROR_ENUM_CANNOT_UPDATE_REPO_UNSIGNED:
+ ret = TRUE;
+ break;
+ default:
+ break;
+ }
+ return ret;
+}
+
+/**
* pk_console_error_code_cb:
**/
static void
@@ -1450,7 +1471,7 @@ pk_console_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gc
}
/* do we need to do the untrusted action */
- if (error_code == PK_ERROR_ENUM_MISSING_GPG_SIGNATURE && only_trusted) {
+ if (pk_console_is_error_code_retry_trusted (error_code) && only_trusted) {
egg_debug ("need to try again with only_trusted FALSE");
only_trusted = FALSE;
commit aa796ea22759aee1f53ab14625d9b5aa99753ad6
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 12:32:32 2009 +0100
Add two more error enums for the new only_trusted code
diff --git a/lib/packagekit-glib/pk-enum.c b/lib/packagekit-glib/pk-enum.c
index 26fa376..f068de2 100644
--- a/lib/packagekit-glib/pk-enum.c
+++ b/lib/packagekit-glib/pk-enum.c
@@ -174,6 +174,8 @@ static const PkEnumMatch enum_error[] = {
{PK_ERROR_ENUM_MEDIA_CHANGE_REQUIRED, "media-change-required"},
{PK_ERROR_ENUM_NOT_AUTHORIZED, "not-authorized"},
{PK_ERROR_ENUM_UPDATE_NOT_FOUND, "update-not-found"},
+ {PK_ERROR_ENUM_CANNOT_INSTALL_REPO_UNSIGNED, "cannot-install-repo-unsigned"},
+ {PK_ERROR_ENUM_CANNOT_UPDATE_REPO_UNSIGNED, "cannot-update-repo-unsigned"},
{0, NULL}
};
diff --git a/lib/packagekit-glib/pk-enum.h b/lib/packagekit-glib/pk-enum.h
index c32407b..e086341 100644
--- a/lib/packagekit-glib/pk-enum.h
+++ b/lib/packagekit-glib/pk-enum.h
@@ -289,6 +289,8 @@ typedef enum {
PK_ERROR_ENUM_MEDIA_CHANGE_REQUIRED,
PK_ERROR_ENUM_NOT_AUTHORIZED,
PK_ERROR_ENUM_UPDATE_NOT_FOUND,
+ PK_ERROR_ENUM_CANNOT_INSTALL_REPO_UNSIGNED,
+ PK_ERROR_ENUM_CANNOT_UPDATE_REPO_UNSIGNED,
PK_ERROR_ENUM_UNKNOWN
} PkErrorCodeEnum;
commit 2b9a167999783f62cd0a554b3eebb4297ea38e76
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 12:11:50 2009 +0100
Rename the 'trusted' parameter to 'only_trusted' to make the logic clearer
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 5faf719..c97bc9f 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -1184,7 +1184,7 @@ backend_install_files_thread (PkBackend *backend)
* backend_install_files:
*/
static void
-backend_install_files (PkBackend *backend, gboolean trusted, gchar **full_paths)
+backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_paths)
{
pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL);
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
@@ -1201,7 +1201,7 @@ backend_install_packages_thread (PkBackend *backend)
unsigned int iterator;
alpm_list_t *data = NULL;
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
gchar **package_ids = pk_backend_get_strv (backend, "package_ids");
/* create a new transaction */
@@ -1241,7 +1241,7 @@ backend_install_packages_thread (PkBackend *backend)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
@@ -1474,7 +1474,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
diff --git a/backends/apt/aptBackend.py b/backends/apt/aptBackend.py
index 0f528a6..843f22c 100755
--- a/backends/apt/aptBackend.py
+++ b/backends/apt/aptBackend.py
@@ -765,12 +765,12 @@ class PackageKitAptBackend(PackageKitBaseBackend):
pkg.homepage, size)
@unlock_cache_afterwards
- def update_system(self, trusted):
+ def update_system(self, only_trusted):
"""
Implement the {backend}-update-system functionality
"""
- # FIXME: use trusted
+ # FIXME: use only_trusted
pklog.info("Upgrading system")
if not self._lock_cache(): return
@@ -991,12 +991,12 @@ class PackageKitAptBackend(PackageKitBaseBackend):
return
@unlock_cache_afterwards
- def update_packages(self, trusted, ids):
+ def update_packages(self, only_trusted, ids):
"""
Implement the {backend}-update functionality
"""
- # FIXME: use trusted
+ # FIXME: use only_trusted
pklog.info("Updating package with id %s" % ids)
if not self._lock_cache(): return
@@ -1085,12 +1085,12 @@ class PackageKitAptBackend(PackageKitBaseBackend):
self.percentage(100)
@unlock_cache_afterwards
- def install_packages(self, trusted, ids):
+ def install_packages(self, only_trusted, ids):
"""
Implement the {backend}-install functionality
"""
- # FIXME: use trusted
+ # FIXME: use only_trusted
pklog.info("Installing package with id %s" % ids)
if not self._lock_cache(): return
@@ -1128,7 +1128,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
return
@unlock_cache_afterwards
- def install_files(self, trusted, inst_files):
+ def install_files(self, only_trusted, inst_files):
"""
Implement install-files for the apt backend
Install local Debian package files
diff --git a/backends/apt/pk-backend-apt.c b/backends/apt/pk-backend-apt.c
index 0884205..59b6c68 100644
--- a/backends/apt/pk-backend-apt.c
+++ b/backends/apt/pk-backend-apt.c
@@ -210,13 +210,13 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "aptBackend.py", "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "aptBackend.py", "install-packages", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -224,13 +224,13 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
* backend_install_files:
*/
static void
-backend_install_files (PkBackend *backend, gboolean trusted, gchar **full_paths)
+backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_paths)
{
gchar *package_ids_temp;
/* send the complete list as stdin */
package_ids_temp = g_strjoinv (PK_BACKEND_SPAWN_FILENAME_DELIM, full_paths);
- pk_backend_spawn_helper (spawn, "aptBackend.py", "install-files", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "aptBackend.py", "install-files", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -324,13 +324,13 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "aptBackend.py", "update-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "aptBackend.py", "update-packages", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -338,9 +338,9 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
- pk_backend_spawn_helper (spawn, "aptBackend.py", "update-system", pk_backend_bool_to_text (trusted), NULL);
+ pk_backend_spawn_helper (spawn, "aptBackend.py", "update-system", pk_backend_bool_to_text (only_trusted), NULL);
}
/**
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index f67726b..6f21f12 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -192,7 +192,7 @@ backend_get_updates_thread (PkBackend *backend)
static gboolean
backend_update_system_thread (PkBackend *backend)
{
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
@@ -210,7 +210,7 @@ backend_install_packages_thread (PkBackend *backend)
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
package_id = pk_backend_get_string (backend, "package_id");
pi = pk_package_id_new_from_string (package_id);
@@ -235,7 +235,7 @@ backend_update_packages_thread (PkBackend *backend)
gint i;
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
package_ids = pk_backend_get_strv (backend, "package_ids");
for (i = 0; i < g_strv_length (package_ids); i++)
@@ -504,7 +504,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
/* check network state */
if (!pk_backend_is_online (backend)) {
@@ -520,7 +520,7 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
* backend_install_files:
*/
static void
-backend_install_files (PkBackend *backend, gboolean trusted, gchar **files)
+backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **files)
{
pk_backend_thread_create (backend, backend_install_files_thread);
}
@@ -594,7 +594,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
/* check network state */
if (!pk_backend_is_online (backend)) {
@@ -609,7 +609,7 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
* backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
pk_backend_thread_create (backend, backend_update_system_thread);
}
diff --git a/backends/conary/conaryBackend.py b/backends/conary/conaryBackend.py
index 9887600..ec9099b 100755
--- a/backends/conary/conaryBackend.py
+++ b/backends/conary/conaryBackend.py
@@ -539,9 +539,9 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
self.files(package_id, ';'.join(files))
@ExceptionHandler
- def update_system(self, trusted):
+ def update_system(self, only_trusted):
- # FIXME: use trusted
+ # FIXME: use only_trusted
self.allow_cancel(True)
self.status(STATUS_UPDATE)
@@ -569,22 +569,22 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
cache = Cache()
cache.refresh()
- def install_packages(self, trusted, package_ids):
+ def install_packages(self, only_trusted, package_ids):
"""
alias of update_packages
"""
- # FIXME: use trusted
+ # FIXME: use only_trusted
- self.update_packages(trusted, package_ids)
+ self.update_packages(only_trusted, package_ids)
@ExceptionHandler
- def update_packages(self, trusted, package_ids):
+ def update_packages(self, only_trusted, package_ids):
'''
Implement the {backend}-{install, update}-packages functionality
'''
- # FIXME: use trusted
+ # FIXME: use only_trusted
for package_id in package_ids:
name, version, flavor, installed = self._findPackage(package_id)
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index 6dd16e2..628a47c 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -141,7 +141,7 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids)
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -154,7 +154,7 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "conaryBackend.py", "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "conaryBackend.py", "install-packages", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -163,12 +163,12 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
*/
/**
static void
-backend_install_files (PkBackend *backend, gboolean trusted, const gchar *full_paths)
+backend_install_files (PkBackend *backend, gboolean only_trusted, const gchar *full_paths)
{
gchar *package_ids_temp;
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "conaryBackend.py", "install-files", pk_backend_bool_to_text (trusted), full_paths, NULL);
+ pk_backend_spawn_helper (spawn, "conaryBackend.py", "install-files", pk_backend_bool_to_text (only_trusted), full_paths, NULL);
g_free (package_ids_temp);
}
*/
@@ -251,7 +251,7 @@ backend_search_details (PkBackend *backend, PkBitfield filters, const gchar *sea
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -264,7 +264,7 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
egg_debug("Updates Packages");
- pk_backend_spawn_helper (spawn, "conaryBackend.py", "update-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "conaryBackend.py", "update-packages", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -272,9 +272,9 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
- pk_backend_spawn_helper (spawn, "conaryBackend.py", "update-system", pk_backend_bool_to_text (trusted), NULL);
+ pk_backend_spawn_helper (spawn, "conaryBackend.py", "update-system", pk_backend_bool_to_text (only_trusted), NULL);
}
/**
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 996bc07..bbc46db 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -452,13 +452,13 @@ backend_install_timeout (gpointer data)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
const gchar *license_agreement;
const gchar *eula_id;
gboolean has_eula;
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
if (egg_strequal (package_ids[0], "vips-doc;7.12.4-2.fc8;noarch;linva")) {
if (_use_gpg && !_has_signature) {
@@ -555,7 +555,7 @@ backend_install_files_timeout (gpointer data)
* backend_install_files:
*/
static void
-backend_install_files (PkBackend *backend, gboolean trusted, gchar **full_paths)
+backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_paths)
{
pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL);
pk_backend_set_percentage (backend, 101);
@@ -866,13 +866,13 @@ backend_update_packages_download_timeout (gpointer data)
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
const gchar *eula_id;
const gchar *license_agreement;
gboolean has_eula;
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
if (_use_gpg && !_has_signature) {
pk_backend_repo_signature_required (backend, package_ids[0], "updates",
@@ -989,13 +989,13 @@ backend_update_system_timeout (gpointer data)
* backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD);
pk_backend_set_allow_cancel (backend, TRUE);
_progress_percentage = 0;
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
pk_backend_require_restart (backend, PK_RESTART_ENUM_SYSTEM, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed");
_signal_timeout = g_timeout_add (100, backend_update_system_timeout, backend);
diff --git a/backends/opkg/pk-backend-opkg.c b/backends/opkg/pk-backend-opkg.c
index 7844ecc..34a2439 100644
--- a/backends/opkg/pk-backend-opkg.c
+++ b/backends/opkg/pk-backend-opkg.c
@@ -441,7 +441,7 @@ backend_install_packages_thread (PkBackend *backend)
}
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL);
@@ -540,7 +540,7 @@ backend_update_system_thread (PkBackend *backend)
{
gint err;
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
err = opkg_upgrade_all (opkg, pk_opkg_progress_cb, backend);
if (err)
@@ -551,7 +551,7 @@ backend_update_system_thread (PkBackend *backend)
}
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
@@ -569,7 +569,7 @@ backend_update_package_thread (PkBackend *backend)
gint err = 0;
const gchar *package_id;
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
package_id = pk_backend_get_string (backend, "pkgid");
pi = pk_package_id_new_from_string (package_id);
@@ -593,7 +593,7 @@ backend_update_package_thread (PkBackend *backend)
}
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gint i;
diff --git a/backends/pisi/pisiBackend.py b/backends/pisi/pisiBackend.py
index f262882..503d016 100755
--- a/backends/pisi/pisiBackend.py
+++ b/backends/pisi/pisiBackend.py
@@ -245,10 +245,10 @@ class PackageKitPisiBackend(PackageKitBaseBackend, PackagekitPackage):
else:
self.package(id, INFO_NORMAL, pkg.summary)
- def install_files(self, trusted, files):
+ def install_files(self, only_trusted, files):
""" Installs given package into system"""
- # FIXME: use trusted
+ # FIXME: use only_trusted
# FIXME: install progress
self.allow_cancel(False)
@@ -262,13 +262,13 @@ class PackageKitPisiBackend(PackageKitBaseBackend, PackagekitPackage):
# Force needed?
self.error(ERROR_PACKAGE_ALREADY_INSTALLED, e)
- def install_packages(self, trusted, package_ids):
+ def install_packages(self, only_trusted, package_ids):
""" Installs given package into system"""
# FIXME: fetch/install progress
self.allow_cancel(False)
self.percentage(None)
- # FIXME: use trusted
+ # FIXME: use only_trusted
package = self.get_package_from_id(package_ids[0])[0]
@@ -390,10 +390,10 @@ class PackageKitPisiBackend(PackageKitBaseBackend, PackagekitPackage):
for pkg in pisi.api.search_package([package]):
self.__get_package(pkg, filters)
- def update_packages(self, trusted, package_ids):
+ def update_packages(self, only_trusted, package_ids):
""" Updates given package to its latest version """
- # FIXME: use trusted
+ # FIXME: use only_trusted
# FIXME: fetch/install progress
self.allow_cancel(False)
@@ -409,10 +409,10 @@ class PackageKitPisiBackend(PackageKitBaseBackend, PackagekitPackage):
else:
self.error(ERROR_PACKAGE_NOT_INSTALLED, "Package is already installed")
- def update_system(self, trusted):
+ def update_system(self, only_trusted):
""" Updates all available packages """
- # FIXME: use trusted
+ # FIXME: use only_trusted
# FIXME: fetch/install progress
self.allow_cancel(False)
diff --git a/backends/pisi/pk-backend-pisi.c b/backends/pisi/pk-backend-pisi.c
index 146a309..5802838 100644
--- a/backends/pisi/pk-backend-pisi.c
+++ b/backends/pisi/pk-backend-pisi.c
@@ -171,7 +171,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -184,7 +184,7 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "pisiBackend.py", "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "pisiBackend.py", "install-packages", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -192,13 +192,13 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
* backend_install_files:
*/
static void
-backend_install_files (PkBackend *backend, gboolean trusted, gchar **full_paths)
+backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_paths)
{
gchar *package_ids_temp;
/* send the complete list as stdin */
package_ids_temp = g_strjoinv (PK_BACKEND_SPAWN_FILENAME_DELIM, full_paths);
- pk_backend_spawn_helper (spawn, "pisiBackend.py", "install-files", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "pisiBackend.py", "install-files", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -284,7 +284,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -297,7 +297,7 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "pisiBackend.py", "update-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "pisiBackend.py", "update-packages", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -305,9 +305,9 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
- pk_backend_spawn_helper (spawn, "pisiBackend.py", "update-system", pk_backend_bool_to_text (trusted), NULL);
+ pk_backend_spawn_helper (spawn, "pisiBackend.py", "update-system", pk_backend_bool_to_text (only_trusted), NULL);
}
/**
diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index f1a68fe..3dd1551 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -1635,7 +1635,7 @@ update_packages_thread (PkBackend *backend)
GString *cmd;
update_system = pk_backend_get_bool (backend, "update_system");
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
package_ids = pk_backend_get_strv (backend, "package_ids");
/* sth goes wrong. package_ids has to be set in UpdatePackages */
@@ -2745,7 +2745,7 @@ backend_install_packages_thread (PkBackend *backend)
pk_backend_set_uint (backend, "ts_type", TS_TYPE_ENUM_INSTALL);
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
package_ids = pk_backend_get_strv (backend, "package_ids");
setup_vf_progress (&vf_progress, backend);
@@ -2782,7 +2782,7 @@ backend_install_packages_thread (PkBackend *backend)
}
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
if (!pk_backend_is_online (backend)) {
pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot install package when offline!");
@@ -2988,7 +2988,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
if (!pk_backend_is_online (backend)) {
pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot update packages when offline!");
@@ -3008,7 +3008,7 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
* backend_update_system:
**/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
if (!pk_backend_is_online (backend)) {
pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot update system when offline!");
diff --git a/backends/portage/pk-backend-portage.c b/backends/portage/pk-backend-portage.c
index 7315c81..b0514c6 100644
--- a/backends/portage/pk-backend-portage.c
+++ b/backends/portage/pk-backend-portage.c
@@ -196,7 +196,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -209,7 +209,7 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, BACKEND_FILE, "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, BACKEND_FILE, "install-packages", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -316,7 +316,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
egg_debug ("backend: update packages");
pk_backend_finished (backend);
@@ -355,7 +355,7 @@ backend_get_requires (PkBackend *backend, PkBitfield filters, gchar **package_id
* backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
egg_debug ("backend: update system");
pk_backend_finished (backend);
diff --git a/backends/portage/portageBackend.py b/backends/portage/portageBackend.py
index cfa43d6..0bafb1c 100755
--- a/backends/portage/portageBackend.py
+++ b/backends/portage/portageBackend.py
@@ -540,12 +540,12 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
if not self.vardb.cpv_exists(best_cpv):
self.package(best_cpv, INFO_NORMAL)
- def install_packages(self, trusted, pkgs):
+ def install_packages(self, only_trusted, pkgs):
self.status(STATUS_RUNNING)
self.allow_cancel(True) # TODO: sure ?
self.percentage(None)
- # FIXME: use trusted
+ # FIXME: use only_trusted
for pkg in pkgs:
# check for installed is not mandatory as there are a lot of reason
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index 719ebf2..f199c4b 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -241,7 +241,7 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -254,7 +254,7 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, BACKEND("install-packages"), pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, BACKEND("install-packages"), pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -262,13 +262,13 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
* backend_install_files:
*/
static void
-backend_install_files (PkBackend *backend, gboolean trusted, gchar **full_paths)
+backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_paths)
{
gchar *full_paths_temp;
/* send the complete list as stdin */
full_paths_temp = g_strjoinv (PK_BACKEND_SPAWN_FILENAME_DELIM, full_paths);
- pk_backend_spawn_helper (spawn, BACKEND("install-files"), pk_backend_bool_to_text (trusted), full_paths_temp, NULL);
+ pk_backend_spawn_helper (spawn, BACKEND("install-files"), pk_backend_bool_to_text (only_trusted), full_paths_temp, NULL);
g_free (full_paths_temp);
}
@@ -355,7 +355,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -368,7 +368,7 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, BACKEND("update-packages"), pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, BACKEND("update-packages"), pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -376,9 +376,9 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
- pk_backend_spawn_helper (spawn, BACKEND("update-system"), pk_backend_bool_to_text (trusted), NULL);
+ pk_backend_spawn_helper (spawn, BACKEND("update-system"), pk_backend_bool_to_text (only_trusted), NULL);
}
/**
diff --git a/backends/smart/smartBackend.py b/backends/smart/smartBackend.py
index ac51e51..c990243 100755
--- a/backends/smart/smartBackend.py
+++ b/backends/smart/smartBackend.py
@@ -167,9 +167,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self._package_list = []
@needs_cache
- def install_packages(self, trusted, packageids):
+ def install_packages(self, only_trusted, packageids):
- # FIXME: use trusted
+ # FIXME: use only_trusted
packages = []
for packageid in packageids:
@@ -203,7 +203,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.ctrl.commitTransaction(trans, confirm=False)
@needs_cache
- def install_files(self, trusted, paths):
+ def install_files(self, only_trusted, paths):
for path in paths:
self.ctrl.addFileChannel(path)
self.ctrl.reloadChannels()
@@ -262,9 +262,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.ctrl.commitTransaction(trans, confirm=False)
@needs_cache
- def update_packages(self, trusted, packageids):
+ def update_packages(self, only_trusted, packageids):
- # FIXME: use trusted
+ # FIXME: use only_trusted
packages = []
for packageid in packageids:
@@ -313,9 +313,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.files(package, ";".join(files))
@needs_cache
- def update_system(self, trusted):
+ def update_system(self, only_trusted):
- # FIXME: use trusted
+ # FIXME: use only_trusted
self.status(STATUS_INFO)
cache = self.ctrl.getCache()
diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
index 7c38a1b..54d65ab 100644
--- a/backends/test/pk-backend-test-fail.c
+++ b/backends/test/pk-backend-test-fail.c
@@ -137,7 +137,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
pk_backend_finished (backend);
}
@@ -146,7 +146,7 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
* backend_install_files:
*/
static void
-backend_install_files (PkBackend *backend, gboolean trusted, gchar **full_paths)
+backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_paths)
{
pk_backend_finished (backend);
}
@@ -233,7 +233,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
pk_backend_finished (backend);
}
@@ -242,7 +242,7 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
* backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
pk_backend_finished (backend);
}
diff --git a/backends/test/pk-backend-test-succeed.c b/backends/test/pk-backend-test-succeed.c
index 399c6c7..ae5c012 100644
--- a/backends/test/pk-backend-test-succeed.c
+++ b/backends/test/pk-backend-test-succeed.c
@@ -134,7 +134,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
pk_backend_finished (backend);
}
@@ -153,7 +153,7 @@ backend_install_signature (PkBackend *backend, PkSigTypeEnum type,
* backend_install_files:
*/
static void
-backend_install_files (PkBackend *backend, gboolean trusted, gchar **full_paths)
+backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_paths)
{
pk_backend_finished (backend);
}
@@ -248,7 +248,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
pk_backend_finished (backend);
}
@@ -257,7 +257,7 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
* backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
pk_backend_finished (backend);
}
diff --git a/backends/urpmi/helpers/urpmi-dispatched-backend.pl b/backends/urpmi/helpers/urpmi-dispatched-backend.pl
index 451e2e2..8e7941d 100755
--- a/backends/urpmi/helpers/urpmi-dispatched-backend.pl
+++ b/backends/urpmi/helpers/urpmi-dispatched-backend.pl
@@ -373,7 +373,7 @@ sub install_packages {
my ($urpm, $args) = @_;
- # FIXME: use trusted in @{$args}[0]
+ # FIXME: use only_trusted in @{$args}[0]
my @packageidstab = split(/&/, @{$args}[1]);
my @names;
@@ -663,7 +663,7 @@ sub update_packages {
my ($urpm, $args) = @_;
- # FIXME: use trusted in @{$args}[0]
+ # FIXME: use only_trusted in @{$args}[0]
my @packageidstab = split(/&/, @{$args}[1]);
my @names;
@@ -698,7 +698,7 @@ sub update_system {
my ($urpm, $args) = @_;
- # FIXME: use trusted in @{$args}[0]
+ # FIXME: use only_trusted in @{$args}[0]
eval {
perform_installation($urpm, {}, auto_select => 1);
};
diff --git a/backends/urpmi/pk-backend-urpmi.c b/backends/urpmi/pk-backend-urpmi.c
index 460f03d..08008b3 100644
--- a/backends/urpmi/pk-backend-urpmi.c
+++ b/backends/urpmi/pk-backend-urpmi.c
@@ -194,7 +194,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -207,7 +207,7 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "install-packages", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -307,7 +307,7 @@ backend_resolve (PkBackend *backend, PkBitfield filters, gchar **package_ids)
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -321,7 +321,7 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "update-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "update-packages", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -329,9 +329,9 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
- pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "update-system", pk_backend_bool_to_text (trusted), NULL);
+ pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "update-system", pk_backend_bool_to_text (only_trusted), NULL);
}
/**
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 2284225..0a4b678 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -261,13 +261,13 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "yumBackend.py", "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "yumBackend.py", "install-packages", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -275,13 +275,13 @@ backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_
* backend_install_files:
*/
static void
-backend_install_files (PkBackend *backend, gboolean trusted, gchar **full_paths)
+backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_paths)
{
gchar *package_ids_temp;
/* send the complete list as stdin */
package_ids_temp = g_strjoinv (PK_BACKEND_SPAWN_FILENAME_DELIM, full_paths);
- pk_backend_spawn_helper (spawn, "yumBackend.py", "install-files", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "yumBackend.py", "install-files", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -380,13 +380,13 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
gchar *package_ids_temp;
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "yumBackend.py", "update-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "yumBackend.py", "update-packages", pk_backend_bool_to_text (only_trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -394,9 +394,9 @@ backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_i
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
- pk_backend_spawn_helper (spawn, "yumBackend.py", "update-system", pk_backend_bool_to_text (trusted), NULL);
+ pk_backend_spawn_helper (spawn, "yumBackend.py", "update-system", pk_backend_bool_to_text (only_trusted), NULL);
}
/**
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 58f1736..025f906 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -1333,7 +1333,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
repo = self.yumbase.repos.getRepo(pkg.repoid)
return repo.gpgcheck
- def update_system(self, trusted):
+ def update_system(self, only_trusted):
'''
Implement the {backend}-update-system functionality
'''
@@ -1343,8 +1343,8 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.percentage(0)
self.status(STATUS_RUNNING)
- # if trusted is true, it means that we will only update signed files
- if trusted:
+ # if only_trusted is true, it means that we will only update signed files
+ if only_trusted:
self.yumbase.conf.gpgcheck = 1
else:
self.yumbase.conf.gpgcheck = 0
@@ -1360,7 +1360,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
else:
if txmbr:
# check all the packages in the transaction if only-trusted
- if trusted:
+ if only_trusted:
for t in txmbr:
pkg = t.po
signed = self._is_package_repo_signed(pkg)
@@ -1473,7 +1473,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
if show:
self._show_package(pkg, INFO_AVAILABLE)
- def install_packages(self, trusted, package_ids):
+ def install_packages(self, only_trusted, package_ids):
'''
Implement the {backend}-install-packages functionality
This will only work with yum 3.2.4 or higher
@@ -1490,8 +1490,8 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
txmbrs = []
already_warned = False
- # if trusted is true, it means that we will only update signed files
- if trusted:
+ # if only_trusted is true, it means that we will only update signed files
+ if only_trusted:
self.yumbase.conf.gpgcheck = 1
else:
self.yumbase.conf.gpgcheck = 0
@@ -1529,7 +1529,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.error(ERROR_PACKAGE_ALREADY_INSTALLED, "The package %s is already installed" % pkg.name, exit=False)
return
if txmbrs:
- if trusted:
+ if only_trusted:
for t in txmbr:
pkg = t.po
signed = self._is_package_repo_signed(pkg)
@@ -1556,7 +1556,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
if newest.EVR > po.EVR:
self.message(MESSAGE_NEWER_PACKAGE_EXISTS, "A newer version of %s is available online." % po.name)
- def install_files(self, trusted, inst_files):
+ def install_files(self, only_trusted, inst_files):
'''
Implement the {backend}-install-files functionality
Install the package containing the inst_file file
@@ -1662,8 +1662,8 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.error(ERROR_ALL_PACKAGES_ALREADY_INSTALLED,
'All of the specified packages have already been installed')
- # If trusted is true, it means that we will only install trusted files
- if trusted:
+ # If only_trusted is true, it means that we will only install trusted files
+ if only_trusted:
# disregard the default
self.yumbase.conf.gpgcheck = 1
@@ -1783,7 +1783,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
return True
- def update_packages(self, trusted, package_ids):
+ def update_packages(self, only_trusted, package_ids):
'''
Implement the {backend}-install functionality
This will only work with yum 3.2.4 or higher
@@ -1798,8 +1798,8 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.percentage(0)
self.status(STATUS_RUNNING)
- # if trusted is true, it means that we will only update signed files
- if trusted:
+ # if only_trusted is true, it means that we will only update signed files
+ if only_trusted:
self.yumbase.conf.gpgcheck = 1
else:
self.yumbase.conf.gpgcheck = 0
@@ -1826,7 +1826,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.error(ERROR_INTERNAL_ERROR, _format_str(traceback.format_exc()))
else:
if txmbrs:
- if trusted:
+ if only_trusted:
for t in txmbr:
pkg = t.po
signed = self._is_package_repo_signed(pkg)
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 13a6c38..3070555 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -859,7 +859,7 @@ backend_install_files_thread (PkBackend *backend)
* backend_install_files
*/
static void
-backend_install_files (PkBackend *backend, gboolean trusted, gchar **full_paths)
+backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_paths)
{
pk_backend_thread_create (backend, backend_install_files_thread);
}
@@ -963,7 +963,7 @@ backend_update_system_thread (PkBackend *backend)
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_set_percentage (backend, 0);
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
zypp::ResPool pool = zypp_build_pool (TRUE);
pk_backend_set_percentage (backend, 40);
PkRestartEnum restart = PK_RESTART_ENUM_NONE;
@@ -1019,7 +1019,7 @@ backend_update_system_thread (PkBackend *backend)
* backend_update_system
*/
static void
-backend_update_system (PkBackend *backend, gboolean trusted)
+backend_update_system (PkBackend *backend, gboolean only_trusted)
{
pk_backend_thread_create (backend, backend_update_system_thread);
}
@@ -1036,7 +1036,7 @@ backend_install_packages_thread (PkBackend *backend)
zypp = get_zypp ();
package_ids = pk_backend_get_strv (backend, "package_ids");
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
try
{
@@ -1116,7 +1116,7 @@ backend_install_packages_thread (PkBackend *backend)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
// For now, don't let the user cancel the install once it's started
pk_backend_set_allow_cancel (backend, FALSE);
@@ -1611,7 +1611,7 @@ backend_update_packages_thread (PkBackend *backend)
{
gboolean retval;
gchar **package_ids;
- /* FIXME: support trusted */
+ /* FIXME: support only_trusted */
package_ids = pk_backend_get_strv (backend, "package_ids");
PkRestartEnum restart = PK_RESTART_ENUM_NONE;
@@ -1643,7 +1643,7 @@ backend_update_packages_thread (PkBackend *backend)
*backend_update_packages
*/
static void
-backend_update_packages(PkBackend *backend, gboolean trusted, gchar **package_ids)
+backend_update_packages(PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
pk_backend_thread_create(backend, backend_update_packages_thread);
}
diff --git a/client/pk-console.c b/client/pk-console.c
index d072f9a..93a67c6 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -49,7 +49,7 @@ static gboolean has_output_bar = FALSE;
static gboolean need_requeue = FALSE;
static gboolean nowait = FALSE;
static gboolean awaiting_space = FALSE;
-static gboolean trusted = TRUE;
+static gboolean only_trusted = TRUE;
static guint timer_id = 0;
static guint percentage_last = 0;
static gchar **untrusted_strv_cache = NULL;
@@ -746,7 +746,7 @@ pk_console_install_stuff (PkClient *client, gchar **packages, GError **error)
goto out;
}
- ret = pk_client_install_packages (client, trusted, package_ids, &error_local);
+ ret = pk_client_install_packages (client, only_trusted, package_ids, &error_local);
if (!ret) {
/* TRANSLATORS: There was an error installing the packages. The detailed error follows */
*error = g_error_new (1, 0, _("This tool could not install the packages: %s"), error_local->message);
@@ -773,7 +773,7 @@ pk_console_install_stuff (PkClient *client, gchar **packages, GError **error)
goto out;
}
- ret = pk_client_install_files (client, trusted, files, &error_local);
+ ret = pk_client_install_files (client, only_trusted, files, &error_local);
if (!ret) {
/* TRANSLATORS: There was an error installing the files. The detailed error follows */
*error = g_error_new (1, 0, _("This tool could not install the files: %s"), error_local->message);
@@ -1450,18 +1450,18 @@ pk_console_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gc
}
/* do we need to do the untrusted action */
- if (error_code == PK_ERROR_ENUM_MISSING_GPG_SIGNATURE && trusted) {
- egg_debug ("need to try again with trusted FALSE");
- trusted = FALSE;
+ if (error_code == PK_ERROR_ENUM_MISSING_GPG_SIGNATURE && only_trusted) {
+ egg_debug ("need to try again with only_trusted FALSE");
+ only_trusted = FALSE;
if (role == PK_ROLE_ENUM_INSTALL_FILES)
- ret = pk_client_install_files (client_trusted, trusted, untrusted_strv_cache, &error);
+ ret = pk_client_install_files (client_trusted, only_trusted, untrusted_strv_cache, &error);
else if (role == PK_ROLE_ENUM_INSTALL_PACKAGES)
- ret = pk_client_install_packages (client_trusted, trusted, untrusted_strv_cache, &error);
+ ret = pk_client_install_packages (client_trusted, only_trusted, untrusted_strv_cache, &error);
else if (role == PK_ROLE_ENUM_UPDATE_PACKAGES)
- ret = pk_client_update_packages (client_trusted, trusted, untrusted_strv_cache, &error);
+ ret = pk_client_update_packages (client_trusted, only_trusted, untrusted_strv_cache, &error);
else if (role == PK_ROLE_ENUM_UPDATE_SYSTEM)
- ret = pk_client_update_system (client_trusted, trusted, &error);
+ ret = pk_client_update_system (client_trusted, only_trusted, &error);
/* we succeeded, so wait for the requeue */
if (!ret) {
diff --git a/docs/api/spec/pk-concepts.xml b/docs/api/spec/pk-concepts.xml
index e0266e2..482357a 100644
--- a/docs/api/spec/pk-concepts.xml
+++ b/docs/api/spec/pk-concepts.xml
@@ -732,7 +732,7 @@
</mediaobject>
<para>
In this non-trivial example, a local file install is being attempted.
- First the <literal>InstallFile</literal> is called with the <literal>trusted</literal>
+ First the <literal>InstallFile</literal> is called with the <literal>only_trusted</literal>
flag set.
This will fail if the package does not have a valid GPG key, and ordinarily the transaction
would fail. What the client can do, e.g. using <literal>libpackagekit</literal>, is
@@ -740,11 +740,11 @@
This will use a different PolicyKit authentication, and allow the file to succeed.
</para>
<para>
- So why do we bother calling <literal>trusted</literal> in the first place?
- Well, the trusted PolicyKit role can be saved in the gnome-keyring, or could be
- set to the users password as the GPG key is already trusted by the user.
+ So why do we bother calling <literal>only_trusted</literal> in the first place?
+ Well, the only_trusted PolicyKit role can be saved in the gnome-keyring, or could be
+ set to the users password as the GPG key is already only_trusted by the user.
The <literal>non-trusted</literal> action would likely ask for the administrator password,
- and not allowed to be saved. This gives the user the benifit of installing trusted local
+ and not allowed to be saved. This gives the user the benifit of installing only_trusted local
files without a password (common case) but requiring something stronger for untrusted or
unsigned files.
</para>
diff --git a/lib/packagekit-glib/pk-client.c b/lib/packagekit-glib/pk-client.c
index b3e55c9..01f3935 100644
--- a/lib/packagekit-glib/pk-client.c
+++ b/lib/packagekit-glib/pk-client.c
@@ -93,7 +93,7 @@ struct _PkClientPrivate
gboolean cached_force;
gboolean cached_allow_deps;
gboolean cached_autoremove;
- gboolean cached_trusted;
+ gboolean cached_only_trusted;
gchar *cached_package_id;
gchar **cached_package_ids;
gchar *cached_transaction_id;
@@ -1455,7 +1455,7 @@ out:
/**
* pk_client_update_system:
* @client: a valid #PkClient instance
- * @trusted: if untrused actions should be allowed
+ * @only_trusted: only trusted packages should be installed
* @error: a %GError to put the error code and message in, or %NULL
*
* Update all the packages on the system with the highest versions found in all
@@ -1468,7 +1468,7 @@ out:
* Return value: %TRUE if we told the daemon to update the system
**/
gboolean
-pk_client_update_system (PkClient *client, gboolean trusted, GError **error)
+pk_client_update_system (PkClient *client, gboolean only_trusted, GError **error)
{
gboolean ret = FALSE;
GError *error_local = NULL; /* we can't use the same error as we might be NULL */
@@ -1490,7 +1490,7 @@ pk_client_update_system (PkClient *client, gboolean trusted, GError **error)
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_UPDATE_SYSTEM;
- client->priv->cached_trusted = trusted;
+ client->priv->cached_only_trusted = only_trusted;
/* check to see if we have a valid proxy */
if (client->priv->proxy == NULL) {
@@ -1502,7 +1502,7 @@ pk_client_update_system (PkClient *client, gboolean trusted, GError **error)
/* do the method */
ret = dbus_g_proxy_call (client->priv->proxy, "UpdateSystem", &error_local,
- G_TYPE_BOOLEAN, trusted,
+ G_TYPE_BOOLEAN, only_trusted,
G_TYPE_INVALID, G_TYPE_INVALID);
/* we failed one of these, return the error to the user */
@@ -2894,7 +2894,7 @@ out:
/**
* pk_client_install_packages:
* @client: a valid #PkClient instance
- * @trusted: if untrused actions should be allowed
+ * @only_trusted: only trusted packages should be installed
* @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
* @error: a %GError to put the error code and message in, or %NULL
*
@@ -2903,7 +2903,7 @@ out:
* Return value: %TRUE if the daemon queued the transaction
**/
gboolean
-pk_client_install_packages (PkClient *client, gboolean trusted, gchar **package_ids, GError **error)
+pk_client_install_packages (PkClient *client, gboolean only_trusted, gchar **package_ids, GError **error)
{
gboolean ret = FALSE;
gchar *package_ids_temp;
@@ -2937,7 +2937,7 @@ pk_client_install_packages (PkClient *client, gboolean trusted, gchar **package_
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_INSTALL_PACKAGES;
- client->priv->cached_trusted = trusted;
+ client->priv->cached_only_trusted = only_trusted;
client->priv->cached_package_ids = g_strdupv (package_ids);
/* check to see if we have a valid proxy */
@@ -2948,7 +2948,7 @@ pk_client_install_packages (PkClient *client, gboolean trusted, gchar **package_
/* do the method */
ret = dbus_g_proxy_call (client->priv->proxy, "InstallPackages", &error_local,
- G_TYPE_BOOLEAN, trusted,
+ G_TYPE_BOOLEAN, only_trusted,
G_TYPE_STRV, package_ids,
G_TYPE_INVALID, G_TYPE_INVALID);
@@ -3052,7 +3052,7 @@ out:
/**
* pk_client_update_packages:
* @client: a valid #PkClient instance
- * @trusted: if untrused actions should be allowed
+ * @only_trusted: only trusted packages should be installed
* @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
* @error: a %GError to put the error code and message in, or %NULL
*
@@ -3061,7 +3061,7 @@ out:
* Return value: %TRUE if the daemon queued the transaction
**/
gboolean
-pk_client_update_packages (PkClient *client, gboolean trusted, gchar **package_ids, GError **error)
+pk_client_update_packages (PkClient *client, gboolean only_trusted, gchar **package_ids, GError **error)
{
gboolean ret = FALSE;
gchar *package_ids_temp;
@@ -3095,7 +3095,7 @@ pk_client_update_packages (PkClient *client, gboolean trusted, gchar **package_i
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_UPDATE_PACKAGES;
- client->priv->cached_trusted = trusted;
+ client->priv->cached_only_trusted = only_trusted;
/* only copy if we are not requeing */
if (client->priv->cached_package_ids != package_ids) {
@@ -3110,7 +3110,7 @@ pk_client_update_packages (PkClient *client, gboolean trusted, gchar **package_i
/* do the method */
ret = dbus_g_proxy_call (client->priv->proxy, "UpdatePackages", &error_local,
- G_TYPE_BOOLEAN, trusted,
+ G_TYPE_BOOLEAN, only_trusted,
G_TYPE_STRV, package_ids,
G_TYPE_INVALID, G_TYPE_INVALID);
@@ -3165,7 +3165,7 @@ pk_resolve_local_path (const gchar *rel_path)
/**
* pk_client_install_files:
* @client: a valid #PkClient instance
- * @trusted: if untrused actions should be allowed
+ * @only_trusted: only trusted packages should be installed
* @files_rel: a file such as "/home/hughsie/Desktop/hal-devel-0.10.0.rpm"
* @error: a %GError to put the error code and message in, or %NULL
*
@@ -3175,7 +3175,7 @@ pk_resolve_local_path (const gchar *rel_path)
* Return value: %TRUE if the daemon queued the transaction
**/
gboolean
-pk_client_install_files (PkClient *client, gboolean trusted, gchar **files_rel, GError **error)
+pk_client_install_files (PkClient *client, gboolean only_trusted, gchar **files_rel, GError **error)
{
guint i;
guint length;
@@ -3217,7 +3217,7 @@ pk_client_install_files (PkClient *client, gboolean trusted, gchar **files_rel,
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_INSTALL_FILES;
- client->priv->cached_trusted = trusted;
+ client->priv->cached_only_trusted = only_trusted;
client->priv->cached_full_paths = g_strdupv (files);
/* check to see if we have a valid proxy */
@@ -3228,7 +3228,7 @@ pk_client_install_files (PkClient *client, gboolean trusted, gchar **files_rel,
/* do the method */
ret = dbus_g_proxy_call (client->priv->proxy, "InstallFiles", &error_local,
- G_TYPE_BOOLEAN, trusted,
+ G_TYPE_BOOLEAN, only_trusted,
G_TYPE_STRV, files,
G_TYPE_INVALID, G_TYPE_INVALID);
@@ -3717,9 +3717,9 @@ pk_client_requeue (PkClient *client, GError **error)
else if (priv->role == PK_ROLE_ENUM_SEARCH_NAME)
ret = pk_client_search_name (client, priv->cached_filters, priv->cached_search, error);
else if (priv->role == PK_ROLE_ENUM_INSTALL_PACKAGES)
- ret = pk_client_install_packages (client, priv->cached_trusted, priv->cached_package_ids, error);
+ ret = pk_client_install_packages (client, priv->cached_only_trusted, priv->cached_package_ids, error);
else if (priv->role == PK_ROLE_ENUM_INSTALL_FILES)
- ret = pk_client_install_files (client, priv->cached_trusted, priv->cached_full_paths, error);
+ ret = pk_client_install_files (client, priv->cached_only_trusted, priv->cached_full_paths, error);
else if (priv->role == PK_ROLE_ENUM_INSTALL_SIGNATURE)
ret = pk_client_install_signature (client, PK_SIGTYPE_ENUM_GPG, priv->cached_key_id, priv->cached_package_id, error);
else if (priv->role == PK_ROLE_ENUM_REFRESH_CACHE)
@@ -3727,9 +3727,9 @@ pk_client_requeue (PkClient *client, GError **error)
else if (priv->role == PK_ROLE_ENUM_REMOVE_PACKAGES)
ret = pk_client_remove_packages (client, priv->cached_package_ids, priv->cached_allow_deps, priv->cached_autoremove, error);
else if (priv->role == PK_ROLE_ENUM_UPDATE_PACKAGES)
- ret = pk_client_update_packages (client, priv->cached_trusted, priv->cached_package_ids, error);
+ ret = pk_client_update_packages (client, priv->cached_only_trusted, priv->cached_package_ids, error);
else if (priv->role == PK_ROLE_ENUM_UPDATE_SYSTEM)
- ret = pk_client_update_system (client, priv->cached_trusted, error);
+ ret = pk_client_update_system (client, priv->cached_only_trusted, error);
else if (priv->role == PK_ROLE_ENUM_GET_REPO_LIST)
ret = pk_client_get_repo_list (client, priv->cached_filters, error);
else if (priv->role == PK_ROLE_ENUM_GET_CATEGORIES)
diff --git a/lib/packagekit-glib/pk-client.h b/lib/packagekit-glib/pk-client.h
index d260aaa..0d7b264 100644
--- a/lib/packagekit-glib/pk-client.h
+++ b/lib/packagekit-glib/pk-client.h
@@ -218,7 +218,7 @@ gboolean pk_client_get_updates (PkClient *client,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_client_update_system (PkClient *client,
- gboolean trusted,
+ gboolean only_trusted,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_client_search_name (PkClient *client,
@@ -289,7 +289,7 @@ gboolean pk_client_refresh_cache (PkClient *client,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_client_install_packages (PkClient *client,
- gboolean trusted,
+ gboolean only_trusted,
gchar **package_ids,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
@@ -300,17 +300,17 @@ gboolean pk_client_install_signature (PkClient *client,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_client_update_packages (PkClient *client,
- gboolean trusted,
+ gboolean only_trusted,
gchar **package_ids,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_client_install_files (PkClient *client,
- gboolean trusted,
+ gboolean only_trusted,
gchar **files_rel,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_client_install_file (PkClient *client,
- gboolean trusted,
+ gboolean only_trusted,
const gchar *file_rel,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
diff --git a/lib/packagekit-qt/src/client.cpp b/lib/packagekit-qt/src/client.cpp
index ffcd200..2d65355 100644
--- a/lib/packagekit-qt/src/client.cpp
+++ b/lib/packagekit-qt/src/client.cpp
@@ -377,9 +377,9 @@ Transaction* Client::getDistroUpgrades()
return t;
}
-Transaction* Client::installFiles(const QStringList& files, bool trusted)
+Transaction* Client::installFiles(const QStringList& files, bool only_trusted)
{
- QString polkitAction = trusted ? AUTH_PACKAGE_INSTALL : AUTH_PACKAGE_INSTALL_UNTRUSTED;
+ QString polkitAction = only_trusted ? AUTH_PACKAGE_INSTALL : AUTH_PACKAGE_INSTALL_UNTRUSTED;
#if 0
if(!PolkitClient::instance()->getAuth(polkitAction)) {
emit authError(polkitAction);
@@ -393,14 +393,14 @@ Transaction* Client::installFiles(const QStringList& files, bool trusted)
return NULL;
}
- t->d->p->InstallFiles(trusted, files);
+ t->d->p->InstallFiles(only_trusted, files);
return t;
}
-Transaction* Client::installFile(const QString& file, bool trusted)
+Transaction* Client::installFile(const QString& file, bool only_trusted)
{
- return installFiles(QStringList() << file, trusted);
+ return installFiles(QStringList() << file, only_trusted);
}
Transaction* Client::installPackages(const QList<Package*>& packages)
diff --git a/lib/packagekit-qt/src/client.h b/lib/packagekit-qt/src/client.h
index 36e46b2..cd1bd09 100644
--- a/lib/packagekit-qt/src/client.h
+++ b/lib/packagekit-qt/src/client.h
@@ -581,10 +581,10 @@ public:
/**
* \brief Installs the local packages \p files
*
- * \p trusted indicate if the packages are signed by a trusted authority
+ * \p only_trusted indicate if the packages are signed by a trusted authority
*/
- Transaction* installFiles(const QStringList& files, bool trusted);
- Transaction* installFile(const QString& file, bool trusted);
+ Transaction* installFiles(const QStringList& files, bool only_trusted);
+ Transaction* installFile(const QString& file, bool only_trusted);
/**
* Install the given \p packages
diff --git a/lib/packagekit-qt/src/transactionproxy.h b/lib/packagekit-qt/src/transactionproxy.h
index 3ac00da..df0fd24 100644
--- a/lib/packagekit-qt/src/transactionproxy.h
+++ b/lib/packagekit-qt/src/transactionproxy.h
@@ -173,10 +173,10 @@ public Q_SLOTS: // METHODS
return callWithArgumentList(QDBus::Block, QLatin1String("GetUpdates"), argumentList);
}
- inline QDBusReply<void> InstallFiles(bool trusted, const QStringList &full_paths)
+ inline QDBusReply<void> InstallFiles(bool only_trusted, const QStringList &full_paths)
{
QList<QVariant> argumentList;
- argumentList << qVariantFromValue(trusted) << qVariantFromValue(full_paths);
+ argumentList << qVariantFromValue(only_trusted) << qVariantFromValue(full_paths);
return callWithArgumentList(QDBus::Block, QLatin1String("InstallFiles"), argumentList);
}
diff --git a/lib/packagekit-sharp/packagekit-api.raw b/lib/packagekit-sharp/packagekit-api.raw
index 4fae5c9..49977b3 100644
--- a/lib/packagekit-sharp/packagekit-api.raw
+++ b/lib/packagekit-sharp/packagekit-api.raw
@@ -812,7 +812,7 @@
<method name="InstallFile" cname="pk_client_install_file">
<return-type type="gboolean" />
<parameters>
- <parameter type="gboolean" name="trusted" />
+ <parameter type="gboolean" name="only_trusted" />
<parameter type="const-gchar*" name="file_rel" />
<parameter type="GError**" name="error" />
</parameters>
@@ -820,7 +820,7 @@
<method name="InstallFiles" cname="pk_client_install_files">
<return-type type="gboolean" />
<parameters>
- <parameter type="gboolean" name="trusted" />
+ <parameter type="gboolean" name="only_trusted" />
<parameter type="gchar**" name="files_rel" />
<parameter type="GError**" name="error" />
</parameters>
diff --git a/lib/packagekit-sharp/packagekit-api.xml b/lib/packagekit-sharp/packagekit-api.xml
index f497292..1919159 100644
--- a/lib/packagekit-sharp/packagekit-api.xml
+++ b/lib/packagekit-sharp/packagekit-api.xml
@@ -812,7 +812,7 @@
<method name="InstallFile" cname="pk_client_install_file">
<return-type type="gboolean" />
<parameters>
- <parameter type="gboolean" name="trusted" />
+ <parameter type="gboolean" name="only_trusted" />
<parameter type="const-gchar*" name="file_rel" />
<parameter type="GError**" name="error" />
</parameters>
@@ -820,7 +820,7 @@
<method name="InstallFiles" cname="pk_client_install_files">
<return-type type="gboolean" />
<parameters>
- <parameter type="gboolean" name="trusted" />
+ <parameter type="gboolean" name="only_trusted" />
<parameter type="gchar**" name="files_rel" null_term_array="1" />
<parameter type="GError**" name="error" />
</parameters>
diff --git a/lib/python/packagekit/backend.py b/lib/python/packagekit/backend.py
index ab86fce..f98ca05 100644
--- a/lib/python/packagekit/backend.py
+++ b/lib/python/packagekit/backend.py
@@ -345,7 +345,7 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend", exit=False)
- def update_system(self, trusted):
+ def update_system(self, only_trusted):
'''
Implement the {backend}-update-system functionality
Needed to be implemented in a sub class
@@ -359,7 +359,7 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend", exit=False)
- def install_packages(self, trusted, package_ids):
+ def install_packages(self, only_trusted, package_ids):
'''
Implement the {backend}-install functionality
Needed to be implemented in a sub class
@@ -373,7 +373,7 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend", exit=False)
- def install_files (self, trusted, inst_files):
+ def install_files (self, only_trusted, inst_files):
'''
Implement the {backend}-install_files functionality
Install the package containing the inst_file file
@@ -395,7 +395,7 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend", exit=False)
- def update_packages(self, trusted, package_ids):
+ def update_packages(self, only_trusted, package_ids):
'''
Implement the {backend}-update functionality
Needed to be implemented in a sub class
@@ -545,14 +545,14 @@ class PackageKitBaseBackend:
self.get_updates(filters)
self.finished()
elif cmd == 'install-files':
- trusted = _text_to_bool(args[0])
+ only_trusted = _text_to_bool(args[0])
files_to_inst = args[1].split(FILENAME_DELIM)
- self.install_files(trusted, files_to_inst)
+ self.install_files(only_trusted, files_to_inst)
self.finished()
elif cmd == 'install-packages':
- trusted = _text_to_bool(args[0])
+ only_trusted = _text_to_bool(args[0])
package_ids = args[1].split(PACKAGE_IDS_DELIM)
- self.install_packages(trusted, package_ids)
+ self.install_packages(only_trusted, package_ids)
self.finished()
elif cmd == 'install-signature':
sigtype = args[0]
@@ -609,13 +609,13 @@ class PackageKitBaseBackend:
self.repo_signature_install(package)
self.finished()
elif cmd == 'update-packages':
- trusted = _text_to_bool(args[0])
+ only_trusted = _text_to_bool(args[0])
package_ids = args[1].split(PACKAGE_IDS_DELIM)
- self.update_packages(trusted, package_ids)
+ self.update_packages(only_trusted, package_ids)
self.finished()
elif cmd == 'update-system':
- trusted = _text_to_bool(args[0])
- self.update_system(trusted)
+ only_trusted = _text_to_bool(args[0])
+ self.update_system(only_trusted)
self.finished()
elif cmd == 'what-provides':
filters = args[0]
diff --git a/lib/python/packagekit/client.py b/lib/python/packagekit/client.py
index ddaada0..b3dd2d1 100644
--- a/lib/python/packagekit/client.py
+++ b/lib/python/packagekit/client.py
@@ -358,9 +358,9 @@ class PackageKitClient:
return self._run_transaction("GetDistroUpgrades", [],
exit_handler)
- def install_files(self, trusted, files, exit_handler=None):
+ def install_files(self, only_trusted, files, exit_handler=None):
'''Install the given local packages'''
- return self._run_transaction("InstallFiles", [trusted, files],
+ return self._run_transaction("InstallFiles", [only_trusted, files],
exit_handler)
def install_signature(self, sig_type, key_id, package_id,
diff --git a/src/org.freedesktop.PackageKit.Transaction.xml b/src/org.freedesktop.PackageKit.Transaction.xml
index aa851ec..961e231 100644
--- a/src/org.freedesktop.PackageKit.Transaction.xml
+++ b/src/org.freedesktop.PackageKit.Transaction.xml
@@ -616,7 +616,7 @@
</doc:description>
<doc:permission>Callers need the org.freedesktop.packagekit.localinstall-untrusted</doc:permission>
</doc:doc>
- <arg type="b" name="trusted" direction="in">
+ <arg type="b" name="only_trusted" direction="in">
<doc:doc>
<doc:summary>
<doc:para>
@@ -626,7 +626,7 @@
<doc:para>
If this method is can only install trusted files, and the files are unsigned, then
the backend will send a <doc:tt>ErrorCode(missing-gpg-signature)</doc:tt>.
- On recieving this error, the client may choose to retry with trusted <doc:tt>FALSE</doc:tt>
+ On recieving this error, the client may choose to retry with only_trusted <doc:tt>FALSE</doc:tt>
after gaining further authentication.
</doc:para>
</doc:summary>
@@ -673,7 +673,7 @@
</doc:description>
<doc:permission>Callers need the org.freedesktop.packagekit.install-untrusted</doc:permission>
</doc:doc>
- <arg type="b" name="trusted" direction="in">
+ <arg type="b" name="only_trusted" direction="in">
<doc:doc>
<doc:summary>
<doc:para>
@@ -683,7 +683,7 @@
<doc:para>
If this method is can only install trusted packages, and the packages are unsigned, then
the backend will send a <doc:tt>ErrorCode(missing-gpg-signature)</doc:tt>.
- On recieving this error, the client may choose to retry with trusted <doc:tt>FALSE</doc:tt>
+ On recieving this error, the client may choose to retry with only_trusted <doc:tt>FALSE</doc:tt>
after gaining further authentication.
</doc:para>
</doc:summary>
@@ -1218,7 +1218,7 @@
</doc:description>
<doc:permission>Callers need the org.freedesktop.packagekit.update-package</doc:permission>
</doc:doc>
- <arg type="b" name="trusted" direction="in">
+ <arg type="b" name="only_trusted" direction="in">
<doc:doc>
<doc:summary>
<doc:para>
@@ -1228,7 +1228,7 @@
<doc:para>
If this method is can only update trusted packages, and the packages are unsigned, then
the backend will send a <doc:tt>ErrorCode(missing-gpg-signature)</doc:tt>.
- On recieving this error, the client may choose to retry with trusted <doc:tt>FALSE</doc:tt>
+ On recieving this error, the client may choose to retry with only_trusted <doc:tt>FALSE</doc:tt>
after gaining further authentication.
</doc:para>
</doc:summary>
@@ -1275,7 +1275,7 @@
</doc:para>
<doc:permission>Callers need the org.freedesktop.packagekit.update-system</doc:permission>
</doc:doc>
- <arg type="b" name="trusted" direction="in">
+ <arg type="b" name="only_trusted" direction="in">
<doc:doc>
<doc:summary>
<doc:para>
@@ -1285,7 +1285,7 @@
<doc:para>
If this method is can only update trusted packages, and the packages are unsigned, then
the backend will send a <doc:tt>ErrorCode(missing-gpg-signature)</doc:tt>.
- On recieving this error, the client may choose to retry with trusted <doc:tt>FALSE</doc:tt>
+ On recieving this error, the client may choose to retry with only_trusted <doc:tt>FALSE</doc:tt>
after gaining further authentication.
</doc:para>
</doc:summary>
diff --git a/src/pk-backend.h b/src/pk-backend.h
index 0ed23a9..a151796 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -241,10 +241,10 @@ typedef struct {
void (*get_updates) (PkBackend *backend,
PkBitfield filters);
void (*install_files) (PkBackend *backend,
- gboolean trusted,
+ gboolean only_trusted,
gchar **full_paths);
void (*install_packages) (PkBackend *backend,
- gboolean trusted,
+ gboolean only_trusted,
gchar **package_ids);
void (*install_signature) (PkBackend *backend,
PkSigTypeEnum type,
@@ -281,10 +281,10 @@ typedef struct {
PkBitfield filters,
const gchar *search);
void (*update_packages) (PkBackend *backend,
- gboolean trusted,
+ gboolean only_trusted,
gchar **package_ids);
void (*update_system) (PkBackend *backend,
- gboolean trusted);
+ gboolean only_trusted);
void (*what_provides) (PkBackend *backend,
PkBitfield filters,
PkProvidesEnum provides,
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 6a70367..25505e7 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -123,7 +123,7 @@ struct PkTransactionPrivate
gboolean cached_allow_deps;
gboolean cached_autoremove;
gboolean cached_enabled;
- gboolean cached_trusted;
+ gboolean cached_only_trusted;
gchar *cached_package_id;
gchar **cached_package_ids;
gchar *cached_transaction_id;
@@ -1128,7 +1128,7 @@ pk_transaction_set_running (PkTransaction *transaction)
pk_store_set_bool (store, "allow_deps", priv->cached_allow_deps);
pk_store_set_bool (store, "autoremove", priv->cached_autoremove);
pk_store_set_bool (store, "enabled", priv->cached_enabled);
- pk_store_set_bool (store, "trusted", priv->cached_trusted);
+ pk_store_set_bool (store, "only_trusted", priv->cached_only_trusted);
pk_store_set_uint (store, "filters", priv->cached_filters);
pk_store_set_uint (store, "provides", priv->cached_provides);
pk_store_set_strv (store, "package_ids", priv->cached_package_ids);
@@ -1180,9 +1180,9 @@ pk_transaction_set_running (PkTransaction *transaction)
else if (priv->role == PK_ROLE_ENUM_SEARCH_NAME)
desc->search_name (priv->backend,priv->cached_filters,priv->cached_search);
else if (priv->role == PK_ROLE_ENUM_INSTALL_PACKAGES)
- desc->install_packages (priv->backend, priv->cached_trusted, priv->cached_package_ids);
+ desc->install_packages (priv->backend, priv->cached_only_trusted, priv->cached_package_ids);
else if (priv->role == PK_ROLE_ENUM_INSTALL_FILES)
- desc->install_files (priv->backend, priv->cached_trusted, priv->cached_full_paths);
+ desc->install_files (priv->backend, priv->cached_only_trusted, priv->cached_full_paths);
else if (priv->role == PK_ROLE_ENUM_INSTALL_SIGNATURE)
desc->install_signature (priv->backend, PK_SIGTYPE_ENUM_GPG, priv->cached_key_id, priv->cached_package_id);
else if (priv->role == PK_ROLE_ENUM_REFRESH_CACHE)
@@ -1190,9 +1190,9 @@ pk_transaction_set_running (PkTransaction *transaction)
else if (priv->role == PK_ROLE_ENUM_REMOVE_PACKAGES)
desc->remove_packages (priv->backend, priv->cached_package_ids, priv->cached_allow_deps, priv->cached_autoremove);
else if (priv->role == PK_ROLE_ENUM_UPDATE_PACKAGES)
- desc->update_packages (priv->backend, priv->cached_trusted, priv->cached_package_ids);
+ desc->update_packages (priv->backend, priv->cached_only_trusted, priv->cached_package_ids);
else if (priv->role == PK_ROLE_ENUM_UPDATE_SYSTEM)
- desc->update_system (priv->backend, priv->cached_trusted);
+ desc->update_system (priv->backend, priv->cached_only_trusted);
else if (priv->role == PK_ROLE_ENUM_GET_CATEGORIES)
desc->get_categories (priv->backend);
else if (priv->role == PK_ROLE_ENUM_GET_REPO_LIST)
@@ -1594,10 +1594,10 @@ out:
}
/**
- * pk_transaction_role_to_action_trusted:
+ * pk_transaction_role_to_action:
**/
static const gchar *
-pk_transaction_role_to_action_trusted (PkRoleEnum role)
+pk_transaction_role_to_action (PkRoleEnum role)
{
const gchar *policy = NULL;
@@ -1671,7 +1671,7 @@ pk_transaction_role_to_action_untrusted (PkRoleEnum role)
* transaction list when authorised, and not before.
**/
static gboolean
-pk_transaction_obtain_authorization (PkTransaction *transaction, gboolean trusted, PkRoleEnum role, GError **error)
+pk_transaction_obtain_authorization (PkTransaction *transaction, gboolean only_trusted, PkRoleEnum role, GError **error)
{
const gchar *action_id;
gboolean ret = FALSE;
@@ -1686,8 +1686,8 @@ pk_transaction_obtain_authorization (PkTransaction *transaction, gboolean truste
}
/* map the roles to policykit rules */
- if (trusted)
- action_id = pk_transaction_role_to_action_trusted (role);
+ if (only_trusted)
+ action_id = pk_transaction_role_to_action (role);
else
action_id = pk_transaction_role_to_action_untrusted (role);
if (action_id == NULL) {
@@ -1696,7 +1696,7 @@ pk_transaction_obtain_authorization (PkTransaction *transaction, gboolean truste
}
/* log */
- pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_AUTH, "uid %i is trying to obtain %s auth (trusted:%i)", transaction->priv->uid, action_id, trusted);
+ pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_AUTH, "uid %i is trying to obtain %s auth (only_trusted:%i)", transaction->priv->uid, action_id, only_trusted);
/* check subject */
transaction->priv->waiting_for_auth = TRUE;
@@ -1719,7 +1719,7 @@ out:
* pk_transaction_obtain_authorization:
**/
static gboolean
-pk_transaction_obtain_authorization (PkTransaction *transaction, gboolean trusted, PkRoleEnum role, GError **error)
+pk_transaction_obtain_authorization (PkTransaction *transaction, gboolean only_trusted, PkRoleEnum role, GError **error)
{
gboolean ret;
@@ -2871,7 +2871,7 @@ pk_transaction_is_supported_content_type (PkTransaction *transaction, const gcha
* pk_transaction_install_files:
**/
void
-pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
+pk_transaction_install_files (PkTransaction *transaction, gboolean only_trusted,
gchar **full_paths, DBusGMethodInvocation *context)
{
gchar *full_paths_temp;
@@ -2887,7 +2887,7 @@ pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
g_return_if_fail (transaction->priv->tid != NULL);
full_paths_temp = pk_package_ids_to_text (full_paths);
- egg_debug ("InstallFiles method called: %s (trusted %i)", full_paths_temp, trusted);
+ egg_debug ("InstallFiles method called: %s (only_trusted %i)", full_paths_temp, only_trusted);
g_free (full_paths_temp);
/* not implemented yet */
@@ -2959,7 +2959,7 @@ pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
}
/* try to get authorization */
- ret = pk_transaction_obtain_authorization (transaction, trusted, PK_ROLE_ENUM_INSTALL_FILES, &error);
+ ret = pk_transaction_obtain_authorization (transaction, only_trusted, PK_ROLE_ENUM_INSTALL_FILES, &error);
if (!ret) {
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
@@ -2967,7 +2967,7 @@ pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
}
/* save so we can run later */
- transaction->priv->cached_trusted = trusted;
+ transaction->priv->cached_only_trusted = only_trusted;
transaction->priv->cached_full_paths = g_strdupv (full_paths);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_INSTALL_FILES);
@@ -2980,7 +2980,7 @@ pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
* pk_transaction_install_packages:
**/
void
-pk_transaction_install_packages (PkTransaction *transaction, gboolean trusted,
+pk_transaction_install_packages (PkTransaction *transaction, gboolean only_trusted,
gchar **package_ids, DBusGMethodInvocation *context)
{
gboolean ret;
@@ -3024,12 +3024,12 @@ pk_transaction_install_packages (PkTransaction *transaction, gboolean trusted,
}
/* save so we can run later */
- transaction->priv->cached_trusted = trusted;
+ transaction->priv->cached_only_trusted = only_trusted;
transaction->priv->cached_package_ids = g_strdupv (package_ids);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_INSTALL_PACKAGES);
/* try to get authorization */
- ret = pk_transaction_obtain_authorization (transaction, trusted, PK_ROLE_ENUM_INSTALL_PACKAGES, &error);
+ ret = pk_transaction_obtain_authorization (transaction, only_trusted, PK_ROLE_ENUM_INSTALL_PACKAGES, &error);
if (!ret) {
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
@@ -3803,7 +3803,7 @@ pk_transaction_set_locale (PkTransaction *transaction, const gchar *code, DBusGM
* pk_transaction_update_packages:
**/
void
-pk_transaction_update_packages (PkTransaction *transaction, gboolean trusted, gchar **package_ids, DBusGMethodInvocation *context)
+pk_transaction_update_packages (PkTransaction *transaction, gboolean only_trusted, gchar **package_ids, DBusGMethodInvocation *context)
{
gboolean ret;
GError *error;
@@ -3846,12 +3846,12 @@ pk_transaction_update_packages (PkTransaction *transaction, gboolean trusted, gc
}
/* save so we can run later */
- transaction->priv->cached_trusted = trusted;
+ transaction->priv->cached_only_trusted = only_trusted;
transaction->priv->cached_package_ids = g_strdupv (package_ids);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_UPDATE_PACKAGES);
/* try to get authorization */
- ret = pk_transaction_obtain_authorization (transaction, trusted, PK_ROLE_ENUM_UPDATE_PACKAGES, &error);
+ ret = pk_transaction_obtain_authorization (transaction, only_trusted, PK_ROLE_ENUM_UPDATE_PACKAGES, &error);
if (!ret) {
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
@@ -3866,7 +3866,7 @@ pk_transaction_update_packages (PkTransaction *transaction, gboolean trusted, gc
* pk_transaction_update_system:
**/
void
-pk_transaction_update_system (PkTransaction *transaction, gboolean trusted, DBusGMethodInvocation *context)
+pk_transaction_update_system (PkTransaction *transaction, gboolean only_trusted, DBusGMethodInvocation *context)
{
gboolean ret;
GError *error;
@@ -3902,11 +3902,11 @@ pk_transaction_update_system (PkTransaction *transaction, gboolean trusted, DBus
return;
}
- transaction->priv->cached_trusted = trusted;
+ transaction->priv->cached_only_trusted = only_trusted;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_UPDATE_SYSTEM);
/* try to get authorization */
- ret = pk_transaction_obtain_authorization (transaction, trusted, PK_ROLE_ENUM_UPDATE_SYSTEM, &error);
+ ret = pk_transaction_obtain_authorization (transaction, only_trusted, PK_ROLE_ENUM_UPDATE_SYSTEM, &error);
if (!ret) {
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
@@ -4326,7 +4326,7 @@ egg_test_transaction (EggTest *test)
************************************************************/
#ifdef USE_SECURITY_POLKIT
egg_test_title (test, "map valid role to action");
- action = pk_transaction_role_to_action_trusted (PK_ROLE_ENUM_UPDATE_PACKAGES);
+ action = pk_transaction_role_to_action (PK_ROLE_ENUM_UPDATE_PACKAGES);
if (egg_strequal (action, "org.freedesktop.packagekit.system-update"))
egg_test_success (test, NULL);
else
@@ -4334,7 +4334,7 @@ egg_test_transaction (EggTest *test)
/************************************************************/
egg_test_title (test, "map invalid role to action");
- action = pk_transaction_role_to_action_trusted (PK_ROLE_ENUM_SEARCH_NAME);
+ action = pk_transaction_role_to_action (PK_ROLE_ENUM_SEARCH_NAME);
if (action == NULL)
egg_test_success (test, NULL);
else
diff --git a/src/pk-transaction.h b/src/pk-transaction.h
index 2dfe895..8ac5a69 100644
--- a/src/pk-transaction.h
+++ b/src/pk-transaction.h
@@ -159,11 +159,11 @@ void pk_transaction_get_updates (PkTransaction *transaction,
const gchar *filter,
DBusGMethodInvocation *context);
void pk_transaction_install_files (PkTransaction *transaction,
- gboolean trusted,
+ gboolean only_trusted,
gchar **full_paths,
DBusGMethodInvocation *context);
void pk_transaction_install_packages (PkTransaction *transaction,
- gboolean trusted,
+ gboolean only_trusted,
gchar **package_ids,
DBusGMethodInvocation *context);
void pk_transaction_install_signature (PkTransaction *transaction,
@@ -218,11 +218,11 @@ void pk_transaction_set_locale (PkTransaction *transaction,
const gchar *code,
DBusGMethodInvocation *context);
void pk_transaction_update_packages (PkTransaction *transaction,
- gboolean trusted,
+ gboolean only_trusted,
gchar **package_ids,
DBusGMethodInvocation *context);
void pk_transaction_update_system (PkTransaction *transaction,
- gboolean trusted,
+ gboolean only_trusted,
DBusGMethodInvocation *context);
void pk_transaction_what_provides (PkTransaction *transaction,
const gchar *filter,
commit e4d2d6cf3a767b657e12fabb125e963f8d4bc877
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 11:40:17 2009 +0100
yum: repect trusted for InstallPackages, UpdatePackages and UpdateSystem
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 6fd08ff..58f1736 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -1326,6 +1326,13 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self._show_package_list(package_list)
self.percentage(100)
+ def _is_package_repo_signed(self, pkg):
+ '''
+ Finds out if the repo that contains the package is signed
+ '''
+ repo = self.yumbase.repos.getRepo(pkg.repoid)
+ return repo.gpgcheck
+
def update_system(self, trusted):
'''
Implement the {backend}-update-system functionality
@@ -1336,9 +1343,12 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.percentage(0)
self.status(STATUS_RUNNING)
- # FIXME: use trusted
+ # if trusted is true, it means that we will only update signed files
+ if trusted:
+ self.yumbase.conf.gpgcheck = 1
+ else:
+ self.yumbase.conf.gpgcheck = 0
- old_throttle = self.yumbase.conf.throttle
self.yumbase.conf.throttle = "60%" # Set bandwidth throttle to 60%
# to avoid taking all the system's bandwidth.
try:
@@ -1349,14 +1359,21 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.error(ERROR_INTERNAL_ERROR, _format_str(traceback.format_exc()))
else:
if txmbr:
+ # check all the packages in the transaction if only-trusted
+ if trusted:
+ for t in txmbr:
+ pkg = t.po
+ signed = self._is_package_repo_signed(pkg)
+ if not signed:
+ self.error(ERROR_MISSING_GPG_SIGNATURE, "The package %s will not be updated from unsigned repo %s" % (pkg.name, pkg.repoid), exit=False)
+ return
try:
self._runYumTransaction(allow_skip_broken=True)
except PkError, e:
self.error(e.code, e.details, exit=False)
else:
- self.error(ERROR_NO_PACKAGES_TO_UPDATE, "Nothing to do")
-
- self.yumbase.conf.throttle = old_throttle
+ self.error(ERROR_NO_PACKAGES_TO_UPDATE, "Nothing to do", exit=False)
+ return
def refresh_cache(self):
'''
@@ -1473,7 +1490,11 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
txmbrs = []
already_warned = False
- # FIXME: use trusted
+ # if trusted is true, it means that we will only update signed files
+ if trusted:
+ self.yumbase.conf.gpgcheck = 1
+ else:
+ self.yumbase.conf.gpgcheck = 0
for package in package_ids:
grp = self._is_meta_package(package)
@@ -1508,6 +1529,13 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.error(ERROR_PACKAGE_ALREADY_INSTALLED, "The package %s is already installed" % pkg.name, exit=False)
return
if txmbrs:
+ if trusted:
+ for t in txmbr:
+ pkg = t.po
+ signed = self._is_package_repo_signed(pkg)
+ if not signed:
+ self.error(ERROR_MISSING_GPG_SIGNATURE, "The package %s will not be installed from unsigned repo %s" % (pkg.name, pkg.repoid), exit=False)
+ return
try:
self._runYumTransaction()
except PkError, e:
@@ -1635,7 +1663,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
'All of the specified packages have already been installed')
# If trusted is true, it means that we will only install trusted files
- if trusted == 'yes':
+ if trusted:
# disregard the default
self.yumbase.conf.gpgcheck = 1
@@ -1770,7 +1798,11 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.percentage(0)
self.status(STATUS_RUNNING)
- # FIXME: use trusted
+ # if trusted is true, it means that we will only update signed files
+ if trusted:
+ self.yumbase.conf.gpgcheck = 1
+ else:
+ self.yumbase.conf.gpgcheck = 0
txmbrs = []
try:
@@ -1794,6 +1826,13 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.error(ERROR_INTERNAL_ERROR, _format_str(traceback.format_exc()))
else:
if txmbrs:
+ if trusted:
+ for t in txmbr:
+ pkg = t.po
+ signed = self._is_package_repo_signed(pkg)
+ if not signed:
+ self.error(ERROR_MISSING_GPG_SIGNATURE, "The package %s will not be updated from unsigned repo %s" % (pkg.name, pkg.repoid), exit=False)
+ return
try:
self._runYumTransaction(allow_skip_broken=True)
except PkError, e:
@@ -2515,6 +2554,9 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
except Exception, e:
raise PkError(ERROR_INTERNAL_ERROR, _format_str(traceback.format_exc()))
+ # default to 100% unless method overrides
+ self.yumbase.conf.throttle = "90%"
+
def _refresh_yum_cache(self):
self.status(STATUS_REFRESH_CACHE)
old_cache_setting = self.yumbase.conf.cache
@@ -2548,8 +2590,6 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
except Exception, e:
raise PkError(ERROR_INTERNAL_ERROR, _format_str(traceback.format_exc()))
- # set bandwidth throttle to 90%
- self.yumbase.conf.throttle = "90%"
self.yumbase.rpmdb.auto_close = True
self.dnlCallback = DownloadCallback(self, showNames=True)
self.yumbase.repos.setProgressBar(self.dnlCallback)
commit ac2cd73e3652f3a9661928cc45fe5dd5aa2e1eca
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 11:26:45 2009 +0100
Add the SLES logo to the repo, we've been approved to use it
diff --git a/docs/html/img/users-sles.png b/docs/html/img/users-sles.png
new file mode 100644
index 0000000..865be76
Binary files /dev/null and b/docs/html/img/users-sles.png differ
commit 9502099c003d6bdba0ab95584c3f5fdc39b6c912
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 11:24:19 2009 +0100
Use proper booleans in the python backends rather than 'true' and 'false'
diff --git a/backends/apt.deprecated/aptBackend.py b/backends/apt.deprecated/aptBackend.py
index e5f78ca..525d79e 100644
--- a/backends/apt.deprecated/aptBackend.py
+++ b/backends/apt.deprecated/aptBackend.py
@@ -317,7 +317,6 @@ class PackageKitAptBackend(PackageKitBaseBackend):
'''
self.allow_cancel(True)
self.status(STATUS_INFO)
- recursive = (recursive == "True")
name, version, arch, data = self.get_package_from_id(package)
pkg = Package(self,self._apt_cache[name],version=[(version,"=")],data=data)
pkg.setVersion(version)
@@ -352,7 +351,6 @@ class PackageKitAptBackend(PackageKitBaseBackend):
'''
self.allow_cancel(True)
self.status(STATUS_INFO)
- recursive = (recursive == "True")
name, version, arch, data = self.get_package_from_id(package)
pkg = Package(self,self._apt_cache[name], version=[(version,"=")], data=data)
@@ -412,7 +410,6 @@ class PackageKitAptBackend(PackageKitBaseBackend):
'''
Implement the {backend}-repo-enable functionality
'''
- enable = (enable == "True")
repo = self._build_repo_list()
if not repo.has_key(repoid):
self.error(ERROR_REPO_NOT_FOUND,"Couldn't find repo '%s'"%repoid)
diff --git a/backends/apt/aptBackend.py b/backends/apt/aptBackend.py
index dd96ad1..0f528a6 100755
--- a/backends/apt/aptBackend.py
+++ b/backends/apt/aptBackend.py
@@ -1243,7 +1243,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
"Package name %s could not be resolved" % name)
return
- def get_depends(self, filter, ids, recursive_text):
+ def get_depends(self, filter, ids, recursive):
"""
Implement the apt2-get-depends functionality
@@ -1257,7 +1257,6 @@ class PackageKitAptBackend(PackageKitBaseBackend):
to python-apt.
"""
pklog.info("Get depends (%s,%s,%s)" % (filter, ids, recursive_text))
- recursive = text_to_bool(recursive_text)
#FIXME: recursive is not yet implemented
if recursive == True:
pklog.warn("Recursive dependencies are not implemented")
@@ -1303,12 +1302,11 @@ class PackageKitAptBackend(PackageKitBaseBackend):
# Clean up
self._cache.clear()
- def get_requires(self, filter, ids, recursive_text):
+ def get_requires(self, filter, ids, recursive):
"""
Implement the apt2-get-requires functionality
"""
pklog.info("Get requires (%s,%s,%s)" % (filter, ids, recursive_text))
- recursive = text_to_bool(rescursive_text)
#FIXME: recursive is not yet implemented
if recursive == True:
pklog.warn("Recursive dependencies are not implemented")
diff --git a/backends/conary/conaryBackend.py b/backends/conary/conaryBackend.py
index af1cc66..9887600 100755
--- a/backends/conary/conaryBackend.py
+++ b/backends/conary/conaryBackend.py
@@ -936,7 +936,7 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
for repo in labels:
repo_name = repo.split("@")[0]
repo_branch = repo.split("@")[1]
- self.repo_detail(repo,repo,"true")
+ self.repo_detail(repo,repo,True)
def repo_enable(self, repoid, enable):
'''
diff --git a/backends/pisi/pisiBackend.py b/backends/pisi/pisiBackend.py
index faf331a..f262882 100755
--- a/backends/pisi/pisiBackend.py
+++ b/backends/pisi/pisiBackend.py
@@ -212,7 +212,7 @@ class PackageKitPisiBackend(PackageKitBaseBackend, PackagekitPackage):
for repo in pisi.api.list_repos():
# Internal FIXME: What an ugly way to get repo uri
# FIXME: Use repository enabled/disabled state
- self.repo_detail(repo, self.repodb.get_repo(repo).indexuri.get_uri(), "true")
+ self.repo_detail(repo, self.repodb.get_repo(repo).indexuri.get_uri(), True)
def get_requires(self, filters, package_ids, recursive):
""" Prints a list of requires for a given package """
diff --git a/backends/portage/portageBackend.py b/backends/portage/portageBackend.py
index a4e672f..cfa43d6 100755
--- a/backends/portage/portageBackend.py
+++ b/backends/portage/portageBackend.py
@@ -304,8 +304,6 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
self.allow_cancel(True)
self.percentage(None)
- recursive = text_to_bool(recursive)
-
for pkgid in pkgids:
cpv = id_to_cpv(pkgid)
@@ -423,8 +421,6 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
self.allow_cancel(True)
self.percentage(None)
- recursive = text_to_bool(recursive)
-
myopts = {}
spinner = ""
favorites = []
diff --git a/backends/smart/smartBackend.py b/backends/smart/smartBackend.py
index 03036d9..ac51e51 100755
--- a/backends/smart/smartBackend.py
+++ b/backends/smart/smartBackend.py
@@ -812,13 +812,6 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.files(packageid, ";".join(paths))
- def _text_to_boolean(self, text):
- if text == 'true' or text == 'TRUE':
- return True
- elif text == 'yes' or text == 'YES':
- return True
- return False
-
def _best_package_from_list(self, package_list):
for installed in (True, False):
best = None
@@ -830,8 +823,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
return None
@needs_cache
- def get_depends(self, filters, packageids, recursive_text):
- recursive = self._text_to_boolean(recursive_text)
+ def get_depends(self, filters, packageids, recursive):
self.status(STATUS_INFO)
self.allow_cancel(True)
for packageid in packageids:
@@ -865,8 +857,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self._show_package_list()
@needs_cache
- def get_requires(self, filters, packageids, recursive_text):
- recursive = self._text_to_boolean(recursive_text)
+ def get_requires(self, filters, packageids, recursive):
self.status(STATUS_INFO)
self.allow_cancel(True)
for packageid in packageids:
@@ -907,9 +898,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
channel = smart.sysconf.get(("channels", alias))
name = channel.get("name", alias)
parsed = smart.channel.parseChannelData(channel)
- enabled = 'true'
+ enabled = True
if channel.has_key('disabled') and channel['disabled'] == 'yes':
- enabled = 'false'
+ enabled = False
channel['alias'] = alias
if self._channel_passes_filters(channel, filters):
self.repo_detail(alias, name, enabled)
@@ -918,7 +909,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.status(STATUS_INFO)
self.allow_cancel(True)
if smart.sysconf.has(("channels", repoid)):
- if enable == "true":
+ if enable:
smart.sysconf.remove(("channels", repoid, "disabled"))
else:
smart.sysconf.set(("channels", repoid, "disabled"), "yes")
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 9e7157b..6fd08ff 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -143,20 +143,6 @@ def _getEVR(idver):
release = '0'
return epoch, version, release
-def _text_to_boolean(text):
- '''
- Parses true and false
- '''
- if text == 'true':
- return True
- if text == 'TRUE':
- return True
- if text == 'yes':
- return True
- if text == 'YES':
- return True
- return False
-
def _truncate(text, length, etc='...'):
if len(text) < length:
return text
@@ -964,7 +950,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
# nothing found
return None, False
- def get_requires(self, filters, package_ids, recursive_text):
+ def get_requires(self, filters, package_ids, recursive):
'''
Print a list of requires for a given package
'''
@@ -978,7 +964,6 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
bump = 100 / len(package_ids)
deps_list = []
resolve_list = []
- recursive = _text_to_boolean(recursive_text)
for package in package_ids:
self.percentage(percentage)
@@ -1272,7 +1257,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
return deps_list
- def get_depends(self, filters, package_ids, recursive_text):
+ def get_depends(self, filters, package_ids, recursive):
'''
Print a list of depends for a given package
'''
@@ -1283,7 +1268,6 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.status(STATUS_INFO)
fltlist = filters.split(';')
pkgfilter = YumFilter(fltlist)
- recursive = _text_to_boolean(recursive_text)
# before we do an install we do ~installed + recursive true,
# which we can emulate quicker by doing a transaction, but not
@@ -2245,7 +2229,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.status(STATUS_INFO)
try:
repo = self.yumbase.repos.getRepo(repoid)
- if enable == 'false':
+ if enable:
if repo.isEnabled():
repo.disablePersistent()
else:
@@ -2281,10 +2265,8 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
return
for repo in repos:
if filters != FILTER_NOT_DEVELOPMENT or not _is_development_repo(repo.id):
- if repo.isEnabled():
- self.repo_detail(repo.id, repo.name, 'true')
- else:
- self.repo_detail(repo.id, repo.name, 'false')
+ enabled = repo.isEnabled()
+ self.repo_detail(repo.id, repo.name, enabled)
def _get_obsoleted(self, name):
try:
diff --git a/lib/python/packagekit/backend.py b/lib/python/packagekit/backend.py
index 0ece924..ab86fce 100644
--- a/lib/python/packagekit/backend.py
+++ b/lib/python/packagekit/backend.py
@@ -143,8 +143,7 @@ class PackageKitBaseBackend:
@param id: the localised label of the media
@param text: the localised text describing the media
'''
- print >> sys.stdout, "media-change-required\t%s\t%s\t%s" % (mtype, id,
- text)
+ print >> sys.stdout, "media-change-required\t%s\t%s\t%s" % (mtype, id, text)
sys.stdout.flush()
def distro_upgrade(self, dtype, name, summary):
@@ -171,7 +170,7 @@ class PackageKitBaseBackend:
@param repoid: The repo id tag
@param state: false is repo is disabled else true.
'''
- print >> sys.stdout, "repo-detail\t%s\t%s\t%s" % (repoid, name, state)
+ print >> sys.stdout, "repo-detail\t%s\t%s\t%s" % (repoid, name, _bool_to_text(state))
sys.stdout.flush()
def data(self, data):
@@ -509,7 +508,7 @@ class PackageKitBaseBackend:
elif cmd == 'get-depends':
filters = args[0]
package_ids = args[1].split(PACKAGE_IDS_DELIM)
- recursive = args[2]
+ recursive = _text_to_bool(args[2])
self.get_depends(filters, package_ids, recursive)
self.finished()
elif cmd == 'get-details':
@@ -531,7 +530,7 @@ class PackageKitBaseBackend:
elif cmd == 'get-requires':
filters = args[0]
package_ids = args[1].split(PACKAGE_IDS_DELIM)
- recursive = args[2]
+ recursive = _text_to_bool(args[2])
self.get_requires(filters, package_ids, recursive)
self.finished()
elif cmd == 'get-update-detail':
@@ -546,12 +545,12 @@ class PackageKitBaseBackend:
self.get_updates(filters)
self.finished()
elif cmd == 'install-files':
- trusted = args[0]
+ trusted = _text_to_bool(args[0])
files_to_inst = args[1].split(FILENAME_DELIM)
self.install_files(trusted, files_to_inst)
self.finished()
elif cmd == 'install-packages':
- trusted = args[0]
+ trusted = _text_to_bool(args[0])
package_ids = args[1].split(PACKAGE_IDS_DELIM)
self.install_packages(trusted, package_ids)
self.finished()
@@ -571,7 +570,7 @@ class PackageKitBaseBackend:
self.finished()
elif cmd == 'repo-enable':
repoid = args[0]
- state = args[1]
+ state = _text_to_bool(args[1])
self.repo_enable(repoid, state)
self.finished()
elif cmd == 'repo-set-data':
@@ -610,12 +609,12 @@ class PackageKitBaseBackend:
self.repo_signature_install(package)
self.finished()
elif cmd == 'update-packages':
- trusted = args[0]
+ trusted = _text_to_bool(args[0])
package_ids = args[1].split(PACKAGE_IDS_DELIM)
self.update_packages(trusted, package_ids)
self.finished()
elif cmd == 'update-system':
- trusted = args[0]
+ trusted = _text_to_bool(args[0])
self.update_system(trusted)
self.finished()
elif cmd == 'what-provides':
@@ -665,12 +664,17 @@ def format_string(text, encoding='utf-8'):
txt = unicode(text, encoding, errors='replace')
return text.replace("\n", ";")
-def text_to_bool(text):
+def _text_to_bool(text):
'''Convert a string to a boolean value.'''
if text.lower() in ["yes", "true"]:
return True
return False
+def _bool_to_text(value):
+ if value:
+ return "true"
+ return "false"
+
def get_package_id(name, version, arch, data):
"""Returns a package id."""
return ";".join((name, version, arch, data))
commit 0e7278a7dff00b4c300419ab621b952754eb0010
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 10:23:40 2009 +0100
Break the API by adding a trusted parameter to InstallPackages, UpdatePackage and UpdateSystem
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 4f4bd6e..5faf719 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -1201,6 +1201,7 @@ backend_install_packages_thread (PkBackend *backend)
unsigned int iterator;
alpm_list_t *data = NULL;
+ /* FIXME: support trusted */
gchar **package_ids = pk_backend_get_strv (backend, "package_ids");
/* create a new transaction */
@@ -1240,7 +1241,7 @@ backend_install_packages_thread (PkBackend *backend)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
@@ -1473,7 +1474,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
diff --git a/backends/apt/aptBackend.py b/backends/apt/aptBackend.py
index e41b675..dd96ad1 100755
--- a/backends/apt/aptBackend.py
+++ b/backends/apt/aptBackend.py
@@ -765,10 +765,13 @@ class PackageKitAptBackend(PackageKitBaseBackend):
pkg.homepage, size)
@unlock_cache_afterwards
- def update_system(self):
+ def update_system(self, trusted):
"""
Implement the {backend}-update-system functionality
"""
+
+ # FIXME: use trusted
+
pklog.info("Upgrading system")
if not self._lock_cache(): return
self.status(STATUS_UPDATE)
@@ -988,10 +991,13 @@ class PackageKitAptBackend(PackageKitBaseBackend):
return
@unlock_cache_afterwards
- def update_packages(self, ids):
+ def update_packages(self, trusted, ids):
"""
Implement the {backend}-update functionality
"""
+
+ # FIXME: use trusted
+
pklog.info("Updating package with id %s" % ids)
if not self._lock_cache(): return
self.status(STATUS_UPDATE)
@@ -1079,10 +1085,13 @@ class PackageKitAptBackend(PackageKitBaseBackend):
self.percentage(100)
@unlock_cache_afterwards
- def install_packages(self, ids):
+ def install_packages(self, trusted, ids):
"""
Implement the {backend}-install functionality
"""
+
+ # FIXME: use trusted
+
pklog.info("Installing package with id %s" % ids)
if not self._lock_cache(): return
self.status(STATUS_INSTALL)
diff --git a/backends/apt/pk-backend-apt.c b/backends/apt/pk-backend-apt.c
index b487c80..0884205 100644
--- a/backends/apt/pk-backend-apt.c
+++ b/backends/apt/pk-backend-apt.c
@@ -210,13 +210,13 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "aptBackend.py", "install-packages", package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "aptBackend.py", "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -324,13 +324,13 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "aptBackend.py", "update-packages", package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "aptBackend.py", "update-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -338,9 +338,9 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
- pk_backend_spawn_helper (spawn, "aptBackend.py", "update-system", NULL);
+ pk_backend_spawn_helper (spawn, "aptBackend.py", "update-system", pk_backend_bool_to_text (trusted), NULL);
}
/**
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 4848e01..f67726b 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -192,6 +192,8 @@ backend_get_updates_thread (PkBackend *backend)
static gboolean
backend_update_system_thread (PkBackend *backend)
{
+ /* FIXME: support trusted */
+
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
box_upgrade_dist(ROOT_DIRECTORY, common_progress, backend);
@@ -208,6 +210,8 @@ backend_install_packages_thread (PkBackend *backend)
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ /* FIXME: support trusted */
+
package_id = pk_backend_get_string (backend, "package_id");
pi = pk_package_id_new_from_string (package_id);
if (pi == NULL) {
@@ -231,6 +235,7 @@ backend_update_packages_thread (PkBackend *backend)
gint i;
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+ /* FIXME: support trusted */
package_ids = pk_backend_get_strv (backend, "package_ids");
for (i = 0; i < g_strv_length (package_ids); i++)
@@ -499,7 +504,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
/* check network state */
if (!pk_backend_is_online (backend)) {
@@ -589,7 +594,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
/* check network state */
if (!pk_backend_is_online (backend)) {
@@ -604,7 +609,7 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
* backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
pk_backend_thread_create (backend, backend_update_system_thread);
}
diff --git a/backends/conary/conaryBackend.py b/backends/conary/conaryBackend.py
index edc79cd..af1cc66 100755
--- a/backends/conary/conaryBackend.py
+++ b/backends/conary/conaryBackend.py
@@ -539,7 +539,10 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
self.files(package_id, ';'.join(files))
@ExceptionHandler
- def update_system(self):
+ def update_system(self, trusted):
+
+ # FIXME: use trusted
+
self.allow_cancel(True)
self.status(STATUS_UPDATE)
self.client.setUpdateCallback( UpdateSystemCallback(self, self.cfg) )
@@ -566,18 +569,23 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
cache = Cache()
cache.refresh()
- def install_packages(self, package_ids):
+ def install_packages(self, trusted, package_ids):
"""
alias of update_packages
"""
- self.update_packages(package_ids)
+
+ # FIXME: use trusted
+
+ self.update_packages(trusted, package_ids)
@ExceptionHandler
- def update_packages(self, package_ids):
+ def update_packages(self, trusted, package_ids):
'''
Implement the {backend}-{install, update}-packages functionality
'''
+ # FIXME: use trusted
+
for package_id in package_ids:
name, version, flavor, installed = self._findPackage(package_id)
log.info((name, version, flavor, installed ))
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index 88612a4..6dd16e2 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -141,7 +141,7 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids)
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -154,7 +154,7 @@ backend_install_packages (PkBackend *backend, gchar **package_ids)
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "conaryBackend.py", "install-packages", package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "conaryBackend.py", "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -251,7 +251,7 @@ backend_search_details (PkBackend *backend, PkBitfield filters, const gchar *sea
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -264,7 +264,7 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
egg_debug("Updates Packages");
- pk_backend_spawn_helper (spawn, "conaryBackend.py", "update-packages", package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "conaryBackend.py", "update-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -272,9 +272,9 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
- pk_backend_spawn_helper (spawn, "conaryBackend.py", "update-system", NULL);
+ pk_backend_spawn_helper (spawn, "conaryBackend.py", "update-system", pk_backend_bool_to_text (trusted), NULL);
}
/**
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index f723844..996bc07 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -452,12 +452,14 @@ backend_install_timeout (gpointer data)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
const gchar *license_agreement;
const gchar *eula_id;
gboolean has_eula;
+ /* FIXME: support trusted */
+
if (egg_strequal (package_ids[0], "vips-doc;7.12.4-2.fc8;noarch;linva")) {
if (_use_gpg && !_has_signature) {
pk_backend_repo_signature_required (backend, package_ids[0], "updates",
@@ -864,11 +866,14 @@ backend_update_packages_download_timeout (gpointer data)
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
const gchar *eula_id;
const gchar *license_agreement;
gboolean has_eula;
+
+ /* FIXME: support trusted */
+
if (_use_gpg && !_has_signature) {
pk_backend_repo_signature_required (backend, package_ids[0], "updates",
"http://example.com/gpgkey",
@@ -984,11 +989,14 @@ backend_update_system_timeout (gpointer data)
* backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD);
pk_backend_set_allow_cancel (backend, TRUE);
_progress_percentage = 0;
+
+ /* FIXME: support trusted */
+
pk_backend_require_restart (backend, PK_RESTART_ENUM_SYSTEM, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed");
_signal_timeout = g_timeout_add (100, backend_update_system_timeout, backend);
}
diff --git a/backends/opkg/pk-backend-opkg.c b/backends/opkg/pk-backend-opkg.c
index 9733aac..7844ecc 100644
--- a/backends/opkg/pk-backend-opkg.c
+++ b/backends/opkg/pk-backend-opkg.c
@@ -441,7 +441,7 @@ backend_install_packages_thread (PkBackend *backend)
}
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL);
@@ -540,6 +540,7 @@ backend_update_system_thread (PkBackend *backend)
{
gint err;
+ /* FIXME: support trusted */
err = opkg_upgrade_all (opkg, pk_opkg_progress_cb, backend);
if (err)
@@ -550,7 +551,7 @@ backend_update_system_thread (PkBackend *backend)
}
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
@@ -568,6 +569,7 @@ backend_update_package_thread (PkBackend *backend)
gint err = 0;
const gchar *package_id;
+ /* FIXME: support trusted */
package_id = pk_backend_get_string (backend, "pkgid");
pi = pk_package_id_new_from_string (package_id);
@@ -591,7 +593,7 @@ backend_update_package_thread (PkBackend *backend)
}
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gint i;
diff --git a/backends/pisi/pisiBackend.py b/backends/pisi/pisiBackend.py
index 73ae300..faf331a 100755
--- a/backends/pisi/pisiBackend.py
+++ b/backends/pisi/pisiBackend.py
@@ -247,6 +247,9 @@ class PackageKitPisiBackend(PackageKitBaseBackend, PackagekitPackage):
def install_files(self, trusted, files):
""" Installs given package into system"""
+
+ # FIXME: use trusted
+
# FIXME: install progress
self.allow_cancel(False)
self.percentage(None)
@@ -259,12 +262,14 @@ class PackageKitPisiBackend(PackageKitBaseBackend, PackagekitPackage):
# Force needed?
self.error(ERROR_PACKAGE_ALREADY_INSTALLED, e)
- def install_packages(self, package_ids):
+ def install_packages(self, trusted, package_ids):
""" Installs given package into system"""
# FIXME: fetch/install progress
self.allow_cancel(False)
self.percentage(None)
+ # FIXME: use trusted
+
package = self.get_package_from_id(package_ids[0])[0]
if self.packagedb.has_package(package):
@@ -385,8 +390,11 @@ class PackageKitPisiBackend(PackageKitBaseBackend, PackagekitPackage):
for pkg in pisi.api.search_package([package]):
self.__get_package(pkg, filters)
- def update_packages(self, package_ids):
+ def update_packages(self, trusted, package_ids):
""" Updates given package to its latest version """
+
+ # FIXME: use trusted
+
# FIXME: fetch/install progress
self.allow_cancel(False)
self.percentage(None)
@@ -401,8 +409,11 @@ class PackageKitPisiBackend(PackageKitBaseBackend, PackagekitPackage):
else:
self.error(ERROR_PACKAGE_NOT_INSTALLED, "Package is already installed")
- def update_system(self):
+ def update_system(self, trusted):
""" Updates all available packages """
+
+ # FIXME: use trusted
+
# FIXME: fetch/install progress
self.allow_cancel(False)
self.percentage(None)
diff --git a/backends/pisi/pk-backend-pisi.c b/backends/pisi/pk-backend-pisi.c
index 06bfef1..146a309 100644
--- a/backends/pisi/pk-backend-pisi.c
+++ b/backends/pisi/pk-backend-pisi.c
@@ -171,7 +171,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -184,7 +184,7 @@ backend_install_packages (PkBackend *backend, gchar **package_ids)
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "pisiBackend.py", "install-packages", package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "pisiBackend.py", "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -284,7 +284,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -297,7 +297,7 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "pisiBackend.py", "update-packages", package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "pisiBackend.py", "update-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -305,9 +305,9 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
- pk_backend_spawn_helper (spawn, "pisiBackend.py", "update-system", NULL);
+ pk_backend_spawn_helper (spawn, "pisiBackend.py", "update-system", pk_backend_bool_to_text (trusted), NULL);
}
/**
diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index 7c255c1..f1a68fe 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -1635,6 +1635,7 @@ update_packages_thread (PkBackend *backend)
GString *cmd;
update_system = pk_backend_get_bool (backend, "update_system");
+ /* FIXME: support trusted */
package_ids = pk_backend_get_strv (backend, "package_ids");
/* sth goes wrong. package_ids has to be set in UpdatePackages */
@@ -2743,6 +2744,8 @@ backend_install_packages_thread (PkBackend *backend)
size_t i;
pk_backend_set_uint (backend, "ts_type", TS_TYPE_ENUM_INSTALL);
+
+ /* FIXME: support trusted */
package_ids = pk_backend_get_strv (backend, "package_ids");
setup_vf_progress (&vf_progress, backend);
@@ -2779,7 +2782,7 @@ backend_install_packages_thread (PkBackend *backend)
}
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
if (!pk_backend_is_online (backend)) {
pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot install package when offline!");
@@ -2985,7 +2988,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
if (!pk_backend_is_online (backend)) {
pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot update packages when offline!");
@@ -3005,7 +3008,7 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
* backend_update_system:
**/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
if (!pk_backend_is_online (backend)) {
pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot update system when offline!");
diff --git a/backends/portage/pk-backend-portage.c b/backends/portage/pk-backend-portage.c
index fde9b0c..7315c81 100644
--- a/backends/portage/pk-backend-portage.c
+++ b/backends/portage/pk-backend-portage.c
@@ -196,7 +196,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -209,7 +209,7 @@ backend_install_packages (PkBackend *backend, gchar **package_ids)
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, BACKEND_FILE, "install-packages", package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, BACKEND_FILE, "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -316,7 +316,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
egg_debug ("backend: update packages");
pk_backend_finished (backend);
@@ -355,7 +355,7 @@ backend_get_requires (PkBackend *backend, PkBitfield filters, gchar **package_id
* backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
egg_debug ("backend: update system");
pk_backend_finished (backend);
diff --git a/backends/portage/portageBackend.py b/backends/portage/portageBackend.py
index 64acbfb..a4e672f 100755
--- a/backends/portage/portageBackend.py
+++ b/backends/portage/portageBackend.py
@@ -544,11 +544,13 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
if not self.vardb.cpv_exists(best_cpv):
self.package(best_cpv, INFO_NORMAL)
- def install_packages(self, pkgs):
+ def install_packages(self, trusted, pkgs):
self.status(STATUS_RUNNING)
self.allow_cancel(True) # TODO: sure ?
self.percentage(None)
+ # FIXME: use trusted
+
for pkg in pkgs:
# check for installed is not mandatory as there are a lot of reason
# to re-install a package (USE/{LD,C}FLAGS change for example) (or live)
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index ac99a72..719ebf2 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -241,7 +241,7 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -254,7 +254,7 @@ backend_install_packages (PkBackend *backend, gchar **package_ids)
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, BACKEND("install-packages"), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, BACKEND("install-packages"), pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -355,7 +355,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -368,7 +368,7 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, BACKEND("update-packages"), package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, BACKEND("update-packages"), pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -376,9 +376,9 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
- pk_backend_spawn_helper (spawn, BACKEND("update-system"), NULL);
+ pk_backend_spawn_helper (spawn, BACKEND("update-system"), pk_backend_bool_to_text (trusted), NULL);
}
/**
diff --git a/backends/smart/smartBackend.py b/backends/smart/smartBackend.py
index 980cf6a..03036d9 100755
--- a/backends/smart/smartBackend.py
+++ b/backends/smart/smartBackend.py
@@ -167,7 +167,10 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self._package_list = []
@needs_cache
- def install_packages(self, packageids):
+ def install_packages(self, trusted, packageids):
+
+ # FIXME: use trusted
+
packages = []
for packageid in packageids:
ratio, results, suggestions = self._search_packageid(packageid)
@@ -259,7 +262,10 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.ctrl.commitTransaction(trans, confirm=False)
@needs_cache
- def update_packages(self, packageids):
+ def update_packages(self, trusted, packageids):
+
+ # FIXME: use trusted
+
packages = []
for packageid in packageids:
ratio, results, suggestions = self._search_packageid(packageid)
@@ -307,7 +313,10 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.files(package, ";".join(files))
@needs_cache
- def update_system(self):
+ def update_system(self, trusted):
+
+ # FIXME: use trusted
+
self.status(STATUS_INFO)
cache = self.ctrl.getCache()
diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
index b1e4286..7c38a1b 100644
--- a/backends/test/pk-backend-test-fail.c
+++ b/backends/test/pk-backend-test-fail.c
@@ -137,7 +137,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_id)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
pk_backend_finished (backend);
}
@@ -233,7 +233,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
pk_backend_finished (backend);
}
@@ -242,7 +242,7 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
* backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
pk_backend_finished (backend);
}
diff --git a/backends/test/pk-backend-test-succeed.c b/backends/test/pk-backend-test-succeed.c
index 220f02a..399c6c7 100644
--- a/backends/test/pk-backend-test-succeed.c
+++ b/backends/test/pk-backend-test-succeed.c
@@ -134,7 +134,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
pk_backend_finished (backend);
}
@@ -248,7 +248,7 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
pk_backend_finished (backend);
}
@@ -257,7 +257,7 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
* backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
pk_backend_finished (backend);
}
diff --git a/backends/urpmi/helpers/urpmi-dispatched-backend.pl b/backends/urpmi/helpers/urpmi-dispatched-backend.pl
index cad4f33..451e2e2 100755
--- a/backends/urpmi/helpers/urpmi-dispatched-backend.pl
+++ b/backends/urpmi/helpers/urpmi-dispatched-backend.pl
@@ -133,7 +133,7 @@ sub dispatch_command {
urpm::media::configure($urpm);
}
elsif($command eq "update-system") {
- update_system($urpm);
+ update_system($urpm, $args);
urpm::media::configure($urpm);
}
elsif($command eq "exit") {
@@ -373,7 +373,8 @@ sub install_packages {
my ($urpm, $args) = @_;
- my @packageidstab = split(/&/, @{$args}[0]);
+ # FIXME: use trusted in @{$args}[0]
+ my @packageidstab = split(/&/, @{$args}[1]);
my @names;
foreach(@packageidstab) {
@@ -662,7 +663,8 @@ sub update_packages {
my ($urpm, $args) = @_;
- my @packageidstab = split(/&/, @{$args}[0]);
+ # FIXME: use trusted in @{$args}[0]
+ my @packageidstab = split(/&/, @{$args}[1]);
my @names;
foreach(@packageidstab) {
@@ -694,7 +696,9 @@ sub update_packages {
sub update_system {
- my ($urpm) = @_;
+ my ($urpm, $args) = @_;
+
+ # FIXME: use trusted in @{$args}[0]
eval {
perform_installation($urpm, {}, auto_select => 1);
};
diff --git a/backends/urpmi/pk-backend-urpmi.c b/backends/urpmi/pk-backend-urpmi.c
index 5d3d058..460f03d 100644
--- a/backends/urpmi/pk-backend-urpmi.c
+++ b/backends/urpmi/pk-backend-urpmi.c
@@ -194,7 +194,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -207,7 +207,7 @@ backend_install_packages (PkBackend *backend, gchar **package_ids)
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "install-packages", package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -307,7 +307,7 @@ backend_resolve (PkBackend *backend, PkBitfield filters, gchar **package_ids)
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
@@ -321,7 +321,7 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "update-packages", package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "update-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -329,9 +329,9 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
- pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "update-system", NULL);
+ pk_backend_spawn_helper (spawn, "urpmi-dispatched-backend.pl", "update-system", pk_backend_bool_to_text (trusted), NULL);
}
/**
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 7dabed7..2284225 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -261,13 +261,13 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "yumBackend.py", "install-packages", package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "yumBackend.py", "install-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -380,13 +380,13 @@ backend_search_name (PkBackend *backend, PkBitfield filters, const gchar *search
* pk_backend_update_packages:
*/
static void
-backend_update_packages (PkBackend *backend, gchar **package_ids)
+backend_update_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
gchar *package_ids_temp;
/* send the complete list as stdin */
package_ids_temp = pk_package_ids_to_text (package_ids);
- pk_backend_spawn_helper (spawn, "yumBackend.py", "update-packages", package_ids_temp, NULL);
+ pk_backend_spawn_helper (spawn, "yumBackend.py", "update-packages", pk_backend_bool_to_text (trusted), package_ids_temp, NULL);
g_free (package_ids_temp);
}
@@ -394,9 +394,9 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
* pk_backend_update_system:
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
- pk_backend_spawn_helper (spawn, "yumBackend.py", "update-system", NULL);
+ pk_backend_spawn_helper (spawn, "yumBackend.py", "update-system", pk_backend_bool_to_text (trusted), NULL);
}
/**
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 4d84d47..9e7157b 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -1342,7 +1342,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self._show_package_list(package_list)
self.percentage(100)
- def update_system(self):
+ def update_system(self, trusted):
'''
Implement the {backend}-update-system functionality
'''
@@ -1352,6 +1352,8 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.percentage(0)
self.status(STATUS_RUNNING)
+ # FIXME: use trusted
+
old_throttle = self.yumbase.conf.throttle
self.yumbase.conf.throttle = "60%" # Set bandwidth throttle to 60%
# to avoid taking all the system's bandwidth.
@@ -1470,7 +1472,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
if show:
self._show_package(pkg, INFO_AVAILABLE)
- def install_packages(self, package_ids):
+ def install_packages(self, trusted, package_ids):
'''
Implement the {backend}-install-packages functionality
This will only work with yum 3.2.4 or higher
@@ -1486,6 +1488,9 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.status(STATUS_RUNNING)
txmbrs = []
already_warned = False
+
+ # FIXME: use trusted
+
for package in package_ids:
grp = self._is_meta_package(package)
if grp:
@@ -1766,7 +1771,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
return True
- def update_packages(self, package_ids):
+ def update_packages(self, trusted, package_ids):
'''
Implement the {backend}-install functionality
This will only work with yum 3.2.4 or higher
@@ -1781,6 +1786,8 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
self.percentage(0)
self.status(STATUS_RUNNING)
+ # FIXME: use trusted
+
txmbrs = []
try:
for package_id in package_ids:
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index deafb5f..13a6c38 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -963,6 +963,7 @@ backend_update_system_thread (PkBackend *backend)
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_set_percentage (backend, 0);
+ /* FIXME: support trusted */
zypp::ResPool pool = zypp_build_pool (TRUE);
pk_backend_set_percentage (backend, 40);
PkRestartEnum restart = PK_RESTART_ENUM_NONE;
@@ -1018,7 +1019,7 @@ backend_update_system_thread (PkBackend *backend)
* backend_update_system
*/
static void
-backend_update_system (PkBackend *backend)
+backend_update_system (PkBackend *backend, gboolean trusted)
{
pk_backend_thread_create (backend, backend_update_system_thread);
}
@@ -1035,6 +1036,7 @@ backend_install_packages_thread (PkBackend *backend)
zypp = get_zypp ();
package_ids = pk_backend_get_strv (backend, "package_ids");
+ /* FIXME: support trusted */
try
{
@@ -1114,7 +1116,7 @@ backend_install_packages_thread (PkBackend *backend)
* backend_install_packages:
*/
static void
-backend_install_packages (PkBackend *backend, gchar **package_ids)
+backend_install_packages (PkBackend *backend, gboolean trusted, gchar **package_ids)
{
// For now, don't let the user cancel the install once it's started
pk_backend_set_allow_cancel (backend, FALSE);
@@ -1609,6 +1611,7 @@ backend_update_packages_thread (PkBackend *backend)
{
gboolean retval;
gchar **package_ids;
+ /* FIXME: support trusted */
package_ids = pk_backend_get_strv (backend, "package_ids");
PkRestartEnum restart = PK_RESTART_ENUM_NONE;
@@ -1640,7 +1643,7 @@ backend_update_packages_thread (PkBackend *backend)
*backend_update_packages
*/
static void
-backend_update_packages(PkBackend *backend, gchar **package_ids)
+backend_update_packages(PkBackend *backend, gboolean trusted, gchar **package_ids)
{
pk_backend_thread_create(backend, backend_update_packages_thread);
}
diff --git a/client/pk-console.c b/client/pk-console.c
index 2c8fa22..d072f9a 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -52,11 +52,11 @@ static gboolean awaiting_space = FALSE;
static gboolean trusted = TRUE;
static guint timer_id = 0;
static guint percentage_last = 0;
-static gchar **files_cache = NULL;
+static gchar **untrusted_strv_cache = NULL;
static PkControl *control = NULL;
static PkClient *client_async = NULL;
static PkClient *client_task = NULL;
-static PkClient *client_install_files = NULL;
+static PkClient *client_trusted = NULL;
static PkClient *client_signature = NULL;
typedef struct {
@@ -594,7 +594,7 @@ pk_console_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime, g
g_print ("%s\n", _("Please restart the application as it is being used."));
}
- if (role == PK_ROLE_ENUM_INSTALL_FILES &&
+ if ((role == PK_ROLE_ENUM_INSTALL_FILES || role == PK_ROLE_ENUM_INSTALL_PACKAGES) &&
exit_enum == PK_EXIT_ENUM_FAILED && need_requeue) {
egg_warning ("waiting for second install file to finish");
return;
@@ -733,6 +733,10 @@ pk_console_install_stuff (PkClient *client, gchar **packages, GError **error)
/* convert to strv */
package_ids = pk_ptr_array_to_strv (array_packages);
+ /* save for untrusted callback */
+ g_strfreev (untrusted_strv_cache);
+ untrusted_strv_cache = g_strdupv (files);
+
/* reset */
ret = pk_client_reset (client, &error_local);
if (!ret) {
@@ -742,7 +746,7 @@ pk_console_install_stuff (PkClient *client, gchar **packages, GError **error)
goto out;
}
- ret = pk_client_install_packages (client, package_ids, &error_local);
+ ret = pk_client_install_packages (client, trusted, package_ids, &error_local);
if (!ret) {
/* TRANSLATORS: There was an error installing the packages. The detailed error follows */
*error = g_error_new (1, 0, _("This tool could not install the packages: %s"), error_local->message);
@@ -757,8 +761,8 @@ pk_console_install_stuff (PkClient *client, gchar **packages, GError **error)
files = pk_ptr_array_to_strv (array_files);
/* save for untrusted callback */
- g_strfreev (files_cache);
- files_cache = g_strdupv (files);
+ g_strfreev (untrusted_strv_cache);
+ untrusted_strv_cache = g_strdupv (files);
/* reset */
ret = pk_client_reset (client, &error_local);
@@ -1018,7 +1022,12 @@ pk_console_update_package (PkClient *client, const gchar *package, GError **erro
}
package_ids = pk_package_ids_from_id (package_id);
- ret = pk_client_update_packages (client, package_ids, error);
+
+ /* save for untrusted callback */
+ g_strfreev (untrusted_strv_cache);
+ untrusted_strv_cache = g_strdupv (package_ids);
+
+ ret = pk_client_update_packages (client, TRUE, package_ids, error);
if (!ret) {
/* TRANSLATORS: There was an error getting the list of files for the package. The detailed error follows */
*error = g_error_new (1, 0, _("This tool could not update %s: %s"), package, error_local->message);
@@ -1370,7 +1379,7 @@ pk_console_list_install (PkClient *client, const gchar *file, GError **error)
/* install packages */
package_ids = pk_package_ids_from_array (array);
- ret = pk_client_install_packages (client, package_ids, &error_local);
+ ret = pk_client_install_packages (client, FALSE, package_ids, &error_local);
if (!ret) {
/* TRANSLATORS: There was an error installing the packages. The detailed error follows */
*error = g_error_new (1, 0, _("This tool could not install the packages: %s"), error_local->message);
@@ -1424,7 +1433,7 @@ pk_console_get_update_detail (PkClient *client, const gchar *package, GError **e
static void
pk_console_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gchar *details, gpointer data)
{
- gboolean ret;
+ gboolean ret = TRUE;
PkRoleEnum role;
GError *error = NULL;
@@ -1441,18 +1450,27 @@ pk_console_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gc
}
/* do we need to do the untrusted action */
- if (role == PK_ROLE_ENUM_INSTALL_FILES &&
- error_code == PK_ERROR_ENUM_MISSING_GPG_SIGNATURE && trusted) {
+ if (error_code == PK_ERROR_ENUM_MISSING_GPG_SIGNATURE && trusted) {
egg_debug ("need to try again with trusted FALSE");
trusted = FALSE;
- ret = pk_client_install_files (client_install_files, trusted, files_cache, &error);
+
+ if (role == PK_ROLE_ENUM_INSTALL_FILES)
+ ret = pk_client_install_files (client_trusted, trusted, untrusted_strv_cache, &error);
+ else if (role == PK_ROLE_ENUM_INSTALL_PACKAGES)
+ ret = pk_client_install_packages (client_trusted, trusted, untrusted_strv_cache, &error);
+ else if (role == PK_ROLE_ENUM_UPDATE_PACKAGES)
+ ret = pk_client_update_packages (client_trusted, trusted, untrusted_strv_cache, &error);
+ else if (role == PK_ROLE_ENUM_UPDATE_SYSTEM)
+ ret = pk_client_update_system (client_trusted, trusted, &error);
+
/* we succeeded, so wait for the requeue */
if (!ret) {
- egg_warning ("failed to install file second time: %s", error->message);
+ egg_warning ("failed to install package second time: %s", error->message);
g_error_free (error);
}
need_requeue = ret;
}
+
if (awaiting_space)
g_print ("\n");
/* TRANSLATORS: This was an unhandled error, and we don't have _any_ context */
@@ -1896,10 +1914,10 @@ main (int argc, char *argv[])
g_signal_connect (client_task, "destroy",
G_CALLBACK (pk_console_destroy_cb), NULL);
- client_install_files = pk_client_new ();
- g_signal_connect (client_install_files, "finished",
+ client_trusted = pk_client_new ();
+ g_signal_connect (client_trusted, "finished",
G_CALLBACK (pk_console_install_files_finished_cb), NULL);
- g_signal_connect (client_install_files, "error-code",
+ g_signal_connect (client_trusted, "error-code",
G_CALLBACK (pk_console_error_code_cb), NULL);
client_signature = pk_client_new ();
@@ -2024,7 +2042,7 @@ main (int argc, char *argv[])
} else if (strcmp (mode, "update") == 0) {
if (value == NULL) {
/* do the system update */
- ret = pk_client_update_system (client_async, &error);
+ ret = pk_client_update_system (client_async, TRUE, &error);
} else {
ret = pk_console_update_package (client_async, value, &error);
}
@@ -2236,11 +2254,11 @@ out:
g_free (options_help);
g_free (filter);
g_free (summary);
- g_strfreev (files_cache);
+ g_strfreev (untrusted_strv_cache);
g_object_unref (control);
g_object_unref (client_async);
g_object_unref (client_task);
- g_object_unref (client_install_files);
+ g_object_unref (client_trusted);
g_object_unref (client_signature);
return 0;
diff --git a/lib/packagekit-glib/pk-client.c b/lib/packagekit-glib/pk-client.c
index 982f875..b3e55c9 100644
--- a/lib/packagekit-glib/pk-client.c
+++ b/lib/packagekit-glib/pk-client.c
@@ -1455,6 +1455,7 @@ out:
/**
* pk_client_update_system:
* @client: a valid #PkClient instance
+ * @trusted: if untrused actions should be allowed
* @error: a %GError to put the error code and message in, or %NULL
*
* Update all the packages on the system with the highest versions found in all
@@ -1467,7 +1468,7 @@ out:
* Return value: %TRUE if we told the daemon to update the system
**/
gboolean
-pk_client_update_system (PkClient *client, GError **error)
+pk_client_update_system (PkClient *client, gboolean trusted, GError **error)
{
gboolean ret = FALSE;
GError *error_local = NULL; /* we can't use the same error as we might be NULL */
@@ -1489,6 +1490,7 @@ pk_client_update_system (PkClient *client, GError **error)
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_UPDATE_SYSTEM;
+ client->priv->cached_trusted = trusted;
/* check to see if we have a valid proxy */
if (client->priv->proxy == NULL) {
@@ -1500,6 +1502,7 @@ pk_client_update_system (PkClient *client, GError **error)
/* do the method */
ret = dbus_g_proxy_call (client->priv->proxy, "UpdateSystem", &error_local,
+ G_TYPE_BOOLEAN, trusted,
G_TYPE_INVALID, G_TYPE_INVALID);
/* we failed one of these, return the error to the user */
@@ -2891,6 +2894,7 @@ out:
/**
* pk_client_install_packages:
* @client: a valid #PkClient instance
+ * @trusted: if untrused actions should be allowed
* @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
* @error: a %GError to put the error code and message in, or %NULL
*
@@ -2899,7 +2903,7 @@ out:
* Return value: %TRUE if the daemon queued the transaction
**/
gboolean
-pk_client_install_packages (PkClient *client, gchar **package_ids, GError **error)
+pk_client_install_packages (PkClient *client, gboolean trusted, gchar **package_ids, GError **error)
{
gboolean ret = FALSE;
gchar *package_ids_temp;
@@ -2933,6 +2937,7 @@ pk_client_install_packages (PkClient *client, gchar **package_ids, GError **erro
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_INSTALL_PACKAGES;
+ client->priv->cached_trusted = trusted;
client->priv->cached_package_ids = g_strdupv (package_ids);
/* check to see if we have a valid proxy */
@@ -2943,6 +2948,7 @@ pk_client_install_packages (PkClient *client, gchar **package_ids, GError **erro
/* do the method */
ret = dbus_g_proxy_call (client->priv->proxy, "InstallPackages", &error_local,
+ G_TYPE_BOOLEAN, trusted,
G_TYPE_STRV, package_ids,
G_TYPE_INVALID, G_TYPE_INVALID);
@@ -3046,6 +3052,7 @@ out:
/**
* pk_client_update_packages:
* @client: a valid #PkClient instance
+ * @trusted: if untrused actions should be allowed
* @package_ids: a null terminated array of package_id structures such as "hal;0.0.1;i386;fedora"
* @error: a %GError to put the error code and message in, or %NULL
*
@@ -3054,7 +3061,7 @@ out:
* Return value: %TRUE if the daemon queued the transaction
**/
gboolean
-pk_client_update_packages (PkClient *client, gchar **package_ids, GError **error)
+pk_client_update_packages (PkClient *client, gboolean trusted, gchar **package_ids, GError **error)
{
gboolean ret = FALSE;
gchar *package_ids_temp;
@@ -3088,6 +3095,7 @@ pk_client_update_packages (PkClient *client, gchar **package_ids, GError **error
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_UPDATE_PACKAGES;
+ client->priv->cached_trusted = trusted;
/* only copy if we are not requeing */
if (client->priv->cached_package_ids != package_ids) {
@@ -3102,6 +3110,7 @@ pk_client_update_packages (PkClient *client, gchar **package_ids, GError **error
/* do the method */
ret = dbus_g_proxy_call (client->priv->proxy, "UpdatePackages", &error_local,
+ G_TYPE_BOOLEAN, trusted,
G_TYPE_STRV, package_ids,
G_TYPE_INVALID, G_TYPE_INVALID);
@@ -3708,7 +3717,7 @@ pk_client_requeue (PkClient *client, GError **error)
else if (priv->role == PK_ROLE_ENUM_SEARCH_NAME)
ret = pk_client_search_name (client, priv->cached_filters, priv->cached_search, error);
else if (priv->role == PK_ROLE_ENUM_INSTALL_PACKAGES)
- ret = pk_client_install_packages (client, priv->cached_package_ids, error);
+ ret = pk_client_install_packages (client, priv->cached_trusted, priv->cached_package_ids, error);
else if (priv->role == PK_ROLE_ENUM_INSTALL_FILES)
ret = pk_client_install_files (client, priv->cached_trusted, priv->cached_full_paths, error);
else if (priv->role == PK_ROLE_ENUM_INSTALL_SIGNATURE)
@@ -3718,9 +3727,9 @@ pk_client_requeue (PkClient *client, GError **error)
else if (priv->role == PK_ROLE_ENUM_REMOVE_PACKAGES)
ret = pk_client_remove_packages (client, priv->cached_package_ids, priv->cached_allow_deps, priv->cached_autoremove, error);
else if (priv->role == PK_ROLE_ENUM_UPDATE_PACKAGES)
- ret = pk_client_update_packages (client, priv->cached_package_ids, error);
+ ret = pk_client_update_packages (client, priv->cached_trusted, priv->cached_package_ids, error);
else if (priv->role == PK_ROLE_ENUM_UPDATE_SYSTEM)
- ret = pk_client_update_system (client, error);
+ ret = pk_client_update_system (client, priv->cached_trusted, error);
else if (priv->role == PK_ROLE_ENUM_GET_REPO_LIST)
ret = pk_client_get_repo_list (client, priv->cached_filters, error);
else if (priv->role == PK_ROLE_ENUM_GET_CATEGORIES)
diff --git a/lib/packagekit-glib/pk-client.h b/lib/packagekit-glib/pk-client.h
index 447d2ab..d260aaa 100644
--- a/lib/packagekit-glib/pk-client.h
+++ b/lib/packagekit-glib/pk-client.h
@@ -218,6 +218,7 @@ gboolean pk_client_get_updates (PkClient *client,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_client_update_system (PkClient *client,
+ gboolean trusted,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_client_search_name (PkClient *client,
@@ -288,6 +289,7 @@ gboolean pk_client_refresh_cache (PkClient *client,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_client_install_packages (PkClient *client,
+ gboolean trusted,
gchar **package_ids,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
@@ -298,6 +300,7 @@ gboolean pk_client_install_signature (PkClient *client,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_client_update_packages (PkClient *client,
+ gboolean trusted,
gchar **package_ids,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
diff --git a/lib/python/packagekit/backend.py b/lib/python/packagekit/backend.py
index 0f877da..0ece924 100644
--- a/lib/python/packagekit/backend.py
+++ b/lib/python/packagekit/backend.py
@@ -346,7 +346,7 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend", exit=False)
- def update_system(self):
+ def update_system(self, trusted):
'''
Implement the {backend}-update-system functionality
Needed to be implemented in a sub class
@@ -360,7 +360,7 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend", exit=False)
- def install_packages(self, package_ids):
+ def install_packages(self, trusted, package_ids):
'''
Implement the {backend}-install functionality
Needed to be implemented in a sub class
@@ -396,7 +396,7 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend", exit=False)
- def update_packages(self, package_ids):
+ def update_packages(self, trusted, package_ids):
'''
Implement the {backend}-update functionality
Needed to be implemented in a sub class
@@ -551,8 +551,9 @@ class PackageKitBaseBackend:
self.install_files(trusted, files_to_inst)
self.finished()
elif cmd == 'install-packages':
- package_ids = args[0].split(PACKAGE_IDS_DELIM)
- self.install_packages(package_ids)
+ trusted = args[0]
+ package_ids = args[1].split(PACKAGE_IDS_DELIM)
+ self.install_packages(trusted, package_ids)
self.finished()
elif cmd == 'install-signature':
sigtype = args[0]
@@ -609,11 +610,13 @@ class PackageKitBaseBackend:
self.repo_signature_install(package)
self.finished()
elif cmd == 'update-packages':
- package_ids = args[0].split(PACKAGE_IDS_DELIM)
- self.update_packages(package_ids)
+ trusted = args[0]
+ package_ids = args[1].split(PACKAGE_IDS_DELIM)
+ self.update_packages(trusted, package_ids)
self.finished()
elif cmd == 'update-system':
- self.update_system()
+ trusted = args[0]
+ self.update_system(trusted)
self.finished()
elif cmd == 'what-provides':
filters = args[0]
diff --git a/src/org.freedesktop.PackageKit.Transaction.xml b/src/org.freedesktop.PackageKit.Transaction.xml
index ca75d42..aa851ec 100644
--- a/src/org.freedesktop.PackageKit.Transaction.xml
+++ b/src/org.freedesktop.PackageKit.Transaction.xml
@@ -620,7 +620,14 @@
<doc:doc>
<doc:summary>
<doc:para>
- If the package is trusted, i.e. if it has a pre-trusted security signature.
+ If the transaction is only allowed to install trusted files.
+ Unsigned files should not be installed if this parameter is <doc:tt>TRUE</doc:tt>.
+ </doc:para>
+ <doc:para>
+ If this method is can only install trusted files, and the files are unsigned, then
+ the backend will send a <doc:tt>ErrorCode(missing-gpg-signature)</doc:tt>.
+ On recieving this error, the client may choose to retry with trusted <doc:tt>FALSE</doc:tt>
+ after gaining further authentication.
</doc:para>
</doc:summary>
</doc:doc>
@@ -664,8 +671,24 @@
<doc:tt>removing</doc:tt>.
</doc:para>
</doc:description>
- <doc:permission>Callers need the org.freedesktop.packagekit.install</doc:permission>
+ <doc:permission>Callers need the org.freedesktop.packagekit.install-untrusted</doc:permission>
</doc:doc>
+ <arg type="b" name="trusted" direction="in">
+ <doc:doc>
+ <doc:summary>
+ <doc:para>
+ If the transaction is only allowed to install trusted packages.
+ Unsigned packages should not be installed if this parameter is <doc:tt>TRUE</doc:tt>.
+ </doc:para>
+ <doc:para>
+ If this method is can only install trusted packages, and the packages are unsigned, then
+ the backend will send a <doc:tt>ErrorCode(missing-gpg-signature)</doc:tt>.
+ On recieving this error, the client may choose to retry with trusted <doc:tt>FALSE</doc:tt>
+ after gaining further authentication.
+ </doc:para>
+ </doc:summary>
+ </doc:doc>
+ </arg>
<arg type="as" name="package_ids" direction="in">
<doc:doc>
<doc:summary>
@@ -1195,6 +1218,22 @@
</doc:description>
<doc:permission>Callers need the org.freedesktop.packagekit.update-package</doc:permission>
</doc:doc>
+ <arg type="b" name="trusted" direction="in">
+ <doc:doc>
+ <doc:summary>
+ <doc:para>
+ If the transaction is only allowed to update to trusted packages.
+ Unsigned packages should not be installed if this parameter is <doc:tt>TRUE</doc:tt>.
+ </doc:para>
+ <doc:para>
+ If this method is can only update trusted packages, and the packages are unsigned, then
+ the backend will send a <doc:tt>ErrorCode(missing-gpg-signature)</doc:tt>.
+ On recieving this error, the client may choose to retry with trusted <doc:tt>FALSE</doc:tt>
+ after gaining further authentication.
+ </doc:para>
+ </doc:summary>
+ </doc:doc>
+ </arg>
<arg type="as" name="package_ids" direction="in">
<doc:doc>
<doc:summary>
@@ -1236,6 +1275,22 @@
</doc:para>
<doc:permission>Callers need the org.freedesktop.packagekit.update-system</doc:permission>
</doc:doc>
+ <arg type="b" name="trusted" direction="in">
+ <doc:doc>
+ <doc:summary>
+ <doc:para>
+ If the transaction is only allowed to update to trusted packages.
+ Unsigned packages should not be installed if this parameter is <doc:tt>TRUE</doc:tt>.
+ </doc:para>
+ <doc:para>
+ If this method is can only update trusted packages, and the packages are unsigned, then
+ the backend will send a <doc:tt>ErrorCode(missing-gpg-signature)</doc:tt>.
+ On recieving this error, the client may choose to retry with trusted <doc:tt>FALSE</doc:tt>
+ after gaining further authentication.
+ </doc:para>
+ </doc:summary>
+ </doc:doc>
+ </arg>
</method>
<!--*****************************************************************************************-->
diff --git a/src/pk-backend.h b/src/pk-backend.h
index dbf04c9..0ed23a9 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -244,6 +244,7 @@ typedef struct {
gboolean trusted,
gchar **full_paths);
void (*install_packages) (PkBackend *backend,
+ gboolean trusted,
gchar **package_ids);
void (*install_signature) (PkBackend *backend,
PkSigTypeEnum type,
@@ -280,8 +281,10 @@ typedef struct {
PkBitfield filters,
const gchar *search);
void (*update_packages) (PkBackend *backend,
+ gboolean trusted,
gchar **package_ids);
- void (*update_system) (PkBackend *backend);
+ void (*update_system) (PkBackend *backend,
+ gboolean trusted);
void (*what_provides) (PkBackend *backend,
PkBitfield filters,
PkProvidesEnum provides,
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 0897694..6a70367 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -1180,7 +1180,7 @@ pk_transaction_set_running (PkTransaction *transaction)
else if (priv->role == PK_ROLE_ENUM_SEARCH_NAME)
desc->search_name (priv->backend,priv->cached_filters,priv->cached_search);
else if (priv->role == PK_ROLE_ENUM_INSTALL_PACKAGES)
- desc->install_packages (priv->backend, priv->cached_package_ids);
+ desc->install_packages (priv->backend, priv->cached_trusted, priv->cached_package_ids);
else if (priv->role == PK_ROLE_ENUM_INSTALL_FILES)
desc->install_files (priv->backend, priv->cached_trusted, priv->cached_full_paths);
else if (priv->role == PK_ROLE_ENUM_INSTALL_SIGNATURE)
@@ -1190,9 +1190,9 @@ pk_transaction_set_running (PkTransaction *transaction)
else if (priv->role == PK_ROLE_ENUM_REMOVE_PACKAGES)
desc->remove_packages (priv->backend, priv->cached_package_ids, priv->cached_allow_deps, priv->cached_autoremove);
else if (priv->role == PK_ROLE_ENUM_UPDATE_PACKAGES)
- desc->update_packages (priv->backend, priv->cached_package_ids);
+ desc->update_packages (priv->backend, priv->cached_trusted, priv->cached_package_ids);
else if (priv->role == PK_ROLE_ENUM_UPDATE_SYSTEM)
- desc->update_system (priv->backend);
+ desc->update_system (priv->backend, priv->cached_trusted);
else if (priv->role == PK_ROLE_ENUM_GET_CATEGORIES)
desc->get_categories (priv->backend);
else if (priv->role == PK_ROLE_ENUM_GET_REPO_LIST)
@@ -1594,37 +1594,68 @@ out:
}
/**
- * pk_transaction_role_to_action:
+ * pk_transaction_role_to_action_trusted:
**/
static const gchar *
-pk_transaction_role_to_action (gboolean trusted, PkRoleEnum role)
+pk_transaction_role_to_action_trusted (PkRoleEnum role)
{
const gchar *policy = NULL;
- if (role == PK_ROLE_ENUM_UPDATE_PACKAGES ||
- role == PK_ROLE_ENUM_UPDATE_SYSTEM) {
- policy = "org.freedesktop.packagekit.system-update";
- } else if (role == PK_ROLE_ENUM_INSTALL_SIGNATURE) {
- policy = "org.freedesktop.packagekit.system-trust-signing-key";
- } else if (role == PK_ROLE_ENUM_ROLLBACK) {
- policy = "org.freedesktop.packagekit.system-rollback";
- } else if (role == PK_ROLE_ENUM_REPO_ENABLE ||
- role == PK_ROLE_ENUM_REPO_SET_DATA) {
- policy = "org.freedesktop.packagekit.system-sources-configure";
- } else if (role == PK_ROLE_ENUM_REFRESH_CACHE) {
- policy = "org.freedesktop.packagekit.system-sources-refresh";
- } else if (role == PK_ROLE_ENUM_REMOVE_PACKAGES) {
- policy = "org.freedesktop.packagekit.package-remove";
- } else if (role == PK_ROLE_ENUM_INSTALL_PACKAGES) {
- policy = "org.freedesktop.packagekit.package-install";
- } else if (role == PK_ROLE_ENUM_INSTALL_FILES && trusted) {
- policy = "org.freedesktop.packagekit.package-install";
- } else if (role == PK_ROLE_ENUM_INSTALL_FILES && !trusted) {
- 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";
+ switch (role) {
+ case PK_ROLE_ENUM_UPDATE_PACKAGES:
+ case PK_ROLE_ENUM_UPDATE_SYSTEM:
+ policy = "org.freedesktop.packagekit.system-update";
+ break;
+ case PK_ROLE_ENUM_INSTALL_SIGNATURE:
+ policy = "org.freedesktop.packagekit.system-trust-signing-key";
+ break;
+ case PK_ROLE_ENUM_ROLLBACK:
+ policy = "org.freedesktop.packagekit.system-rollback";
+ break;
+ case PK_ROLE_ENUM_REPO_ENABLE:
+ case PK_ROLE_ENUM_REPO_SET_DATA:
+ policy = "org.freedesktop.packagekit.system-sources-configure";
+ break;
+ case PK_ROLE_ENUM_REFRESH_CACHE:
+ policy = "org.freedesktop.packagekit.system-sources-refresh";
+ break;
+ case PK_ROLE_ENUM_REMOVE_PACKAGES:
+ policy = "org.freedesktop.packagekit.package-remove";
+ break;
+ case PK_ROLE_ENUM_INSTALL_PACKAGES:
+ policy = "org.freedesktop.packagekit.package-install";
+ break;
+ case PK_ROLE_ENUM_INSTALL_FILES:
+ policy = "org.freedesktop.packagekit.package-install";
+ break;
+ case PK_ROLE_ENUM_ACCEPT_EULA:
+ policy = "org.freedesktop.packagekit.package-eula-accept";
+ break;
+ case PK_ROLE_ENUM_CANCEL:
+ policy = "org.freedesktop.packagekit.cancel-foreign";
+ break;
+ default:
+ break;
+ }
+ return policy;
+}
+
+/**
+ * pk_transaction_role_to_action_untrusted:
+ **/
+static const gchar *
+pk_transaction_role_to_action_untrusted (PkRoleEnum role)
+{
+ const gchar *policy = NULL;
+
+ switch (role) {
+ case PK_ROLE_ENUM_UPDATE_PACKAGES:
+ case PK_ROLE_ENUM_UPDATE_SYSTEM:
+ case PK_ROLE_ENUM_INSTALL_FILES:
+ policy = "org.freedesktop.packagekit.install-untrusted";
+ break;
+ default:
+ break;
}
return policy;
}
@@ -1655,7 +1686,10 @@ pk_transaction_obtain_authorization (PkTransaction *transaction, gboolean truste
}
/* map the roles to policykit rules */
- action_id = pk_transaction_role_to_action (trusted, role);
+ if (trusted)
+ action_id = pk_transaction_role_to_action_trusted (role);
+ else
+ action_id = pk_transaction_role_to_action_untrusted (role);
if (action_id == NULL) {
*error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_REFUSED_BY_POLICY, "policykit type required for '%s'", pk_role_enum_to_text (role));
goto out;
@@ -2946,8 +2980,8 @@ pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
* pk_transaction_install_packages:
**/
void
-pk_transaction_install_packages (PkTransaction *transaction, gchar **package_ids,
- DBusGMethodInvocation *context)
+pk_transaction_install_packages (PkTransaction *transaction, gboolean trusted,
+ gchar **package_ids, DBusGMethodInvocation *context)
{
gboolean ret;
GError *error;
@@ -2990,11 +3024,12 @@ pk_transaction_install_packages (PkTransaction *transaction, gchar **package_ids
}
/* save so we can run later */
+ transaction->priv->cached_trusted = trusted;
transaction->priv->cached_package_ids = g_strdupv (package_ids);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_INSTALL_PACKAGES);
/* try to get authorization */
- ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_INSTALL_PACKAGES, &error);
+ ret = pk_transaction_obtain_authorization (transaction, trusted, PK_ROLE_ENUM_INSTALL_PACKAGES, &error);
if (!ret) {
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
@@ -3768,7 +3803,7 @@ pk_transaction_set_locale (PkTransaction *transaction, const gchar *code, DBusGM
* pk_transaction_update_packages:
**/
void
-pk_transaction_update_packages (PkTransaction *transaction, gchar **package_ids, DBusGMethodInvocation *context)
+pk_transaction_update_packages (PkTransaction *transaction, gboolean trusted, gchar **package_ids, DBusGMethodInvocation *context)
{
gboolean ret;
GError *error;
@@ -3811,11 +3846,12 @@ pk_transaction_update_packages (PkTransaction *transaction, gchar **package_ids,
}
/* save so we can run later */
+ transaction->priv->cached_trusted = trusted;
transaction->priv->cached_package_ids = g_strdupv (package_ids);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_UPDATE_PACKAGES);
/* try to get authorization */
- ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_UPDATE_PACKAGES, &error);
+ ret = pk_transaction_obtain_authorization (transaction, trusted, PK_ROLE_ENUM_UPDATE_PACKAGES, &error);
if (!ret) {
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
@@ -3830,7 +3866,7 @@ pk_transaction_update_packages (PkTransaction *transaction, gchar **package_ids,
* pk_transaction_update_system:
**/
void
-pk_transaction_update_system (PkTransaction *transaction, DBusGMethodInvocation *context)
+pk_transaction_update_system (PkTransaction *transaction, gboolean trusted, DBusGMethodInvocation *context)
{
gboolean ret;
GError *error;
@@ -3866,10 +3902,11 @@ pk_transaction_update_system (PkTransaction *transaction, DBusGMethodInvocation
return;
}
+ transaction->priv->cached_trusted = trusted;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_UPDATE_SYSTEM);
/* try to get authorization */
- ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_UPDATE_SYSTEM, &error);
+ ret = pk_transaction_obtain_authorization (transaction, trusted, PK_ROLE_ENUM_UPDATE_SYSTEM, &error);
if (!ret) {
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
@@ -4289,7 +4326,7 @@ egg_test_transaction (EggTest *test)
************************************************************/
#ifdef USE_SECURITY_POLKIT
egg_test_title (test, "map valid role to action");
- action = pk_transaction_role_to_action (FALSE, PK_ROLE_ENUM_UPDATE_PACKAGES);
+ action = pk_transaction_role_to_action_trusted (PK_ROLE_ENUM_UPDATE_PACKAGES);
if (egg_strequal (action, "org.freedesktop.packagekit.system-update"))
egg_test_success (test, NULL);
else
@@ -4297,7 +4334,7 @@ egg_test_transaction (EggTest *test)
/************************************************************/
egg_test_title (test, "map invalid role to action");
- action = pk_transaction_role_to_action (FALSE, PK_ROLE_ENUM_SEARCH_NAME);
+ action = pk_transaction_role_to_action_trusted (PK_ROLE_ENUM_SEARCH_NAME);
if (action == NULL)
egg_test_success (test, NULL);
else
diff --git a/src/pk-transaction.h b/src/pk-transaction.h
index e6ad1e6..2dfe895 100644
--- a/src/pk-transaction.h
+++ b/src/pk-transaction.h
@@ -163,6 +163,7 @@ void pk_transaction_install_files (PkTransaction *transaction,
gchar **full_paths,
DBusGMethodInvocation *context);
void pk_transaction_install_packages (PkTransaction *transaction,
+ gboolean trusted,
gchar **package_ids,
DBusGMethodInvocation *context);
void pk_transaction_install_signature (PkTransaction *transaction,
@@ -217,9 +218,11 @@ void pk_transaction_set_locale (PkTransaction *transaction,
const gchar *code,
DBusGMethodInvocation *context);
void pk_transaction_update_packages (PkTransaction *transaction,
+ gboolean trusted,
gchar **package_ids,
DBusGMethodInvocation *context);
void pk_transaction_update_system (PkTransaction *transaction,
+ gboolean trusted,
DBusGMethodInvocation *context);
void pk_transaction_what_provides (PkTransaction *transaction,
const gchar *filter,
commit 69ca864f4de510e49585fd8631f494e1814d00e7
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 10:14:10 2009 +0100
Update fedora spec file to use polkit rather than PolicyKit
diff --git a/contrib/PackageKit.spec.in b/contrib/PackageKit.spec.in
index c8eec52..e3491b4 100644
--- a/contrib/PackageKit.spec.in
+++ b/contrib/PackageKit.spec.in
@@ -1,7 +1,7 @@
%define glib2_version 2.16.1
%define dbus_version 0.90
%define dbus_glib_version 0.70
-%define policykit_version 0.8
+%define polkit_version 0.92
%define libnm_glib_version 0.6.4
%define alphatag #ALPHATAG#
@@ -26,6 +26,7 @@ Requires: PackageKit-yum = %{version}-%{release}
Requires: shared-mime-info
Requires: comps-extras
Requires: preupgrade
+BuildRequires: polkit >= %{polkit_version}
BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: dbus-devel >= %{dbus_version}
@@ -35,7 +36,7 @@ BuildRequires: libX11-devel
BuildRequires: xmlto
BuildRequires: sqlite-devel
BuildRequires: NetworkManager-glib-devel >= %{libnm_glib_version}
-BuildRequires: PolicyKit-devel >= %{policykit_version}
+BuildRequires: polkit-devel >= %{polkit_version}
BuildRequires: libtool
BuildRequires: docbook-utils
BuildRequires: gnome-doc-utils
@@ -290,7 +291,7 @@ update-mime-database %{_datadir}/mime &> /dev/null || :
%dir %{_datadir}/PackageKit/icons
%{_datadir}/PackageKit/helpers/test_spawn/*
%{_datadir}/man/man1/*.1.gz
-%{_datadir}/PolicyKit/policy/*.policy
+%{_datadir}/polkit-1/actions/*.policy
%{_datadir}/mime/packages/packagekit-*.xml
%{_datadir}/PackageKit/pk-upgrade-distro.sh
%{_sbindir}/packagekitd
commit c47d4390783aeb871fa90c46cfc2ab7ee39bca56
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 09:42:00 2009 +0100
pkcon: Quit the synchronous loop if we get destroyed, to avoid hanging forever
diff --git a/client/pk-console.c b/client/pk-console.c
index 1d8df81..2c8fa22 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -537,6 +537,22 @@ pk_console_require_restart_cb (PkClient *client, PkRestartEnum restart, const Pk
}
/**
+ * pk_console_destroy_cb:
+ **/
+static void
+pk_console_destroy_cb (PkClient *client, gpointer data)
+{
+ gboolean ret;
+
+ /* exit our private loop if it's running */
+ ret = g_main_loop_is_running (loop);
+ if (ret) {
+ egg_warning ("quitting loop due to transaction being destroyed");
+ g_main_loop_quit (loop);
+ }
+}
+
+/**
* pk_console_finished_cb:
**/
static void
@@ -1861,6 +1877,8 @@ main (int argc, char *argv[])
G_CALLBACK (pk_console_progress_changed_cb), NULL);
g_signal_connect (client_async, "finished",
G_CALLBACK (pk_console_finished_cb), NULL);
+ g_signal_connect (client_async, "destroy",
+ G_CALLBACK (pk_console_destroy_cb), NULL);
g_signal_connect (client_async, "require-restart",
G_CALLBACK (pk_console_require_restart_cb), NULL);
g_signal_connect (client_async, "error-code",
@@ -1875,6 +1893,8 @@ main (int argc, char *argv[])
G_CALLBACK (pk_console_finished_cb), NULL);
g_signal_connect (client_task, "message",
G_CALLBACK (pk_watch_message_cb), NULL);
+ g_signal_connect (client_task, "destroy",
+ G_CALLBACK (pk_console_destroy_cb), NULL);
client_install_files = pk_client_new ();
g_signal_connect (client_install_files, "finished",
commit 2a44b3620105e2411c64a0e324ec83688f4f201a
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jun 17 09:41:40 2009 +0100
glib: Quit the synchronous loop if we get destroyed, to avoid hanging forever
diff --git a/lib/packagekit-glib/pk-client.c b/lib/packagekit-glib/pk-client.c
index 1461451..982f875 100644
--- a/lib/packagekit-glib/pk-client.c
+++ b/lib/packagekit-glib/pk-client.c
@@ -436,7 +436,16 @@ pk_client_get_cached_objects (PkClient *client)
static void
pk_client_destroy_cb (DBusGProxy *proxy, PkClient *client)
{
+ gboolean ret;
g_return_if_fail (PK_IS_CLIENT (client));
+
+ /* exit our private loop if it's running */
+ ret = g_main_loop_is_running (client->priv->loop);
+ if (ret && client->priv->synchronous) {
+ egg_warning ("quitting loop due to transaction being destroyed");
+ g_main_loop_quit (client->priv->loop);
+ }
+
egg_debug ("emit destroy %s", client->priv->tid);
g_signal_emit (client, signals [PK_CLIENT_DESTROY], 0);
}
commit a12a9be5bd6c6607d56bf021fd61308ad2ac73fd
Author: Mounir Lamouri (volkmar) <mounir.lamouri at gmail.com>
Date: Wed Jun 17 00:03:43 2009 +0200
portage: add get-updates function
diff --git a/backends/portage/pk-backend-portage.c b/backends/portage/pk-backend-portage.c
index d5bf58e..fde9b0c 100644
--- a/backends/portage/pk-backend-portage.c
+++ b/backends/portage/pk-backend-portage.c
@@ -185,8 +185,11 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids)
static void
backend_get_updates (PkBackend *backend, PkBitfield filters)
{
- egg_debug ("backend: updates");
- pk_backend_finished (backend);
+ gchar *filters_text;
+
+ filters_text = pk_filter_bitfield_to_text (filters);
+ pk_backend_spawn_helper (spawn, BACKEND_FILE, "get-updates", filters_text, NULL);
+ g_free (filters_text);
}
/**
@@ -377,7 +380,7 @@ PK_BACKEND_OPTIONS (
NULL, // TODO /* get_repo_list */
backend_get_requires, /* get_requires */
backend_get_update_detail, // TODO /* get_update_detail */
- backend_get_updates, // TODO /* get_updates */
+ backend_get_updates, /* get_updates */
NULL, /* install_files */
backend_install_packages, /* install_packages */
NULL, // TODO: choose /* install_signature */
diff --git a/backends/portage/portageBackend.py b/backends/portage/portageBackend.py
index fabe5dd..64acbfb 100755
--- a/backends/portage/portageBackend.py
+++ b/backends/portage/portageBackend.py
@@ -288,12 +288,13 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
return get_package_id(package, version, ' '.join(keywords), repo)
- def package(self, cpv):
+ def package(self, cpv, info=None):
desc = portage.portdb.aux_get(cpv, ["DESCRIPTION"])
- if self.is_installed(cpv):
- info = INFO_INSTALLED
- else:
- info = INFO_AVAILABLE
+ if not info:
+ if self.is_installed(cpv):
+ info = INFO_INSTALLED
+ else:
+ info = INFO_AVAILABLE
PackageKitBaseBackend.package(self, self.cpv_to_id(cpv), info, desc[0])
def get_depends(self, filters, pkgids, recursive):
@@ -512,6 +513,37 @@ class PackageKitPortageBackend(PackageKitBaseBackend, PackagekitPackage):
self.percentage(100)
+ def get_updates(self, filters):
+ # NOTES:
+ # portage prefer not to update _ALL_ packages so we will only list updated
+ # packages in world or system
+
+ # TODO: filters ?
+ # TODO: INFO
+ self.status(STATUS_INFO)
+ self.allow_cancel(True)
+ self.percentage(None)
+
+ # best way to get that ?
+ settings, trees, mtimedb = _emerge.load_emerge_config()
+ rootconfig = _emerge.RootConfig(self.portage_settings, trees["/"],
+ portage._sets.load_default_config(self.portage_settings, trees["/"]))
+
+ cp_to_check = []
+
+ # get system and world sets
+ for s in ("system", "world"):
+ set = portage._sets.base.InternalPackageSet(
+ initial_atoms=rootconfig.setconfig.getSetAtoms(s))
+ for cp in set:
+ cp_to_check.append(cp)
+
+ # check if bestmatch is installed
+ for cp in cp_to_check:
+ best_cpv = portage.portdb.xmatch("bestmatch-visible", cp)
+ if not self.vardb.cpv_exists(best_cpv):
+ self.package(best_cpv, INFO_NORMAL)
+
def install_packages(self, pkgs):
self.status(STATUS_RUNNING)
self.allow_cancel(True) # TODO: sure ?
commit 1f136db0d0dab937c449ead795802ab84e731d34
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Jun 16 17:36:23 2009 +0100
Port to polkit1, and remove a lot of the complexity from the old PolicyKit code
diff --git a/configure.ac b/configure.ac
index 92cfb42..eaafc64 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,8 +130,7 @@ GIO_REQUIRED=2.16.1
DBUS_REQUIRED=1.1.1
DBUS_GLIB_REQUIRED=0.74
LIBNM_GLIB_REQUIRED=0.6.4
-POLKIT_DBUS_REQUIRED=0.8
-POLKIT_GRANT_REQUIRED=0.8
+POLKIT_GOBJECT_REQUIRED=0.91
QTCORE_REQUIRED=4.4.0
QTDBUS_REQUIRED=4.4.0
QTGUI_REQUIRED=4.4.0
@@ -549,15 +548,9 @@ AC_SUBST(security_framework, "$with_security_framework")
if test x$with_security_framework = xpolkit; then
PKG_CHECK_MODULES(POLKIT, \
- polkit-dbus >= $POLKIT_DBUS_REQUIRED \
- polkit-grant >= $POLKIT_GRANT_REQUIRED)
+ polkit-gobject-1 >= $POLKIT_GOBJECT_REQUIRED)
AC_SUBST(POLKIT_CFLAGS)
AC_SUBST(POLKIT_LIBS)
- AC_CHECK_PROG([POLKIT_POLICY_FILE_VALIDATE],
- [polkit-policy-file-validate], [polkit-policy-file-validate])
- if test -z "$POLKIT_POLICY_FILE_VALIDATE"; then
- AC_MSG_ERROR([polkit-policy-file-validate not found])
- fi
AC_DEFINE(USE_SECURITY_POLKIT, 1, [if we should use PolicyKit])
elif test x$with_security_framework = xdummy; then
AC_DEFINE(USE_SECURITY_DUMMY, 1, [if we should use a dummy security framework])
diff --git a/lib/packagekit-glib/pk-client.c b/lib/packagekit-glib/pk-client.c
index c9200e9..1461451 100644
--- a/lib/packagekit-glib/pk-client.c
+++ b/lib/packagekit-glib/pk-client.c
@@ -42,10 +42,6 @@
#include <glib/gprintf.h>
#include <dbus/dbus-glib.h>
-#ifdef USE_SECURITY_POLKIT
-#include <polkit-dbus/polkit-dbus.h>
-#endif
-
#include <packagekit-glib/pk-enum.h>
#include <packagekit-glib/pk-bitfield.h>
#include <packagekit-glib/pk-client.h>
@@ -190,131 +186,53 @@ pk_client_error_get_type (void)
* pk_client_error_fixup:
* @error: a %GError
**/
-static gboolean
-pk_client_error_fixup (GError **error)
+static GError *
+pk_client_error_fixup (GError *error_local)
{
+ GError *error;
const gchar *name;
- guint code;
- if (error != NULL && *error != NULL) {
- /* get some proper debugging */
- if ((*error)->domain == DBUS_GERROR &&
- (*error)->code == DBUS_GERROR_REMOTE_EXCEPTION) {
- /* use one of our local codes */
- name = dbus_g_error_get_name (*error);
- code = PK_CLIENT_ERROR_FAILED;
-
- /* trim common prefix */
- if (g_str_has_prefix (name, "org.freedesktop.PackageKit.Transaction."))
- name = &name[39];
-
- /* try to get a better error */
- if (g_str_has_prefix (name, "PermissionDenied") ||
- g_str_has_prefix (name, "RefusedByPolicy"))
- code = PK_CLIENT_ERROR_FAILED_AUTH;
- else if (g_str_has_prefix (name, "PackageIdInvalid") ||
- g_str_has_prefix (name, "SearchInvalid") ||
- g_str_has_prefix (name, "FilterInvalid") ||
- g_str_has_prefix (name, "InvalidProvide") ||
- g_str_has_prefix (name, "InputInvalid"))
- code = PK_CLIENT_ERROR_INVALID_INPUT;
- else if (g_str_has_prefix (name, "PackInvalid") ||
- g_str_has_prefix (name, "NoSuchFile") ||
- g_str_has_prefix (name, "NoSuchDirectory"))
- code = PK_CLIENT_ERROR_INVALID_FILE;
- else if (g_str_has_prefix (name, "NotSupported"))
- code = PK_CLIENT_ERROR_NOT_SUPPORTED;
-
- egg_debug ("fixing up code from %s to %i", name, code);
- (*error)->code = code;
- }
- if (g_str_has_prefix ((*error)->message, "org.freedesktop.packagekit.")) {
- egg_debug ("fixing up code for Policykit auth failure");
- g_error_free (*error);
- *error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED_AUTH, "PolicyKit authorization failure");
- }
- return TRUE;
- }
- return FALSE;
-}
-
-/**
- * pk_client_error_refused_by_policy:
- * @error: a valid #GError
- *
- * Return value: %TRUE if the error is the PolicyKit "RefusedByPolicy"
- **/
-static gboolean
-pk_client_error_refused_by_policy (GError *error)
-{
- const gchar *error_name;
-
- /* if not set */
- if (error == NULL)
- return FALSE;
-
- /* not a dbus error */
- if (error->code != DBUS_GERROR_REMOTE_EXCEPTION) {
- egg_warning ("not a remote exception: %s", error->message);
- return FALSE;
- }
-
- /* check for specific error */
- error_name = dbus_g_error_get_name (error);
- egg_debug ("ERROR: %s: %s", error_name, error->message);
- if (egg_strequal (error_name, "org.freedesktop.PackageKit.RefusedByPolicy"))
- return TRUE;
- if (egg_strequal (error_name, "org.freedesktop.PackageKit.Transaction.RefusedByPolicy"))
- return TRUE;
- return FALSE;
-}
-
-/**
- * pk_client_error_auth_obtain:
- * @error: the GError with the failure
- *
- * This function is indented to be passed failure messages from dbus methods
- * so that extra auth can be requested.
- *
- * Return value: if we gained the privilege we asked for
- **/
-static gboolean
-pk_client_error_auth_obtain (GError *error)
-{
- gboolean ret = FALSE;
-#ifdef USE_SECURITY_POLKIT
- PolKitAction *action = NULL;
- PolKitResult result;
- gchar *action_id = NULL; /* we don't free this */
- DBusError error2;
- dbus_error_init (&error2);
- g_return_val_if_fail (error != NULL, FALSE);
+ g_return_val_if_fail (error_local != NULL, NULL);
- /* get PolKitAction */
- ret = polkit_dbus_error_parse_from_strings ("org.freedesktop.PolicyKit.Error.NotAuthorized", error->message, &action, &result);
- if (!ret) {
- egg_warning ("Not a polkit auth failure: %s", error->message);
- return FALSE;
+ /* PolicyKit failure */
+ if (g_str_has_prefix (error_local->message, "org.freedesktop.packagekit.")) {
+ egg_debug ("fixing up code for Policykit auth failure");
+ error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED_AUTH, "PolicyKit authorization failure");
+ goto out;
}
- /* get action_id from PolKitAction */
- ret = polkit_action_get_action_id (action, &action_id);
- if (!ret) {
- egg_warning ("Unable to get an action ID");
- return FALSE;
+ /* new default error with correct domain and code */
+ error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "%s", error_local->message);
+
+ /* get some proper debugging */
+ if (error_local->domain == DBUS_GERROR &&
+ error_local->code == DBUS_GERROR_REMOTE_EXCEPTION) {
+ /* use one of our local codes */
+ name = dbus_g_error_get_name (error_local);
+
+ /* trim common prefix */
+ if (g_str_has_prefix (name, "org.freedesktop.PackageKit.Transaction."))
+ name = &name[39];
+
+ /* try to get a better error */
+ if (g_str_has_prefix (name, "PermissionDenied") ||
+ g_str_has_prefix (name, "RefusedByPolicy"))
+ error->code = PK_CLIENT_ERROR_FAILED_AUTH;
+ else if (g_str_has_prefix (name, "PackageIdInvalid") ||
+ g_str_has_prefix (name, "SearchInvalid") ||
+ g_str_has_prefix (name, "FilterInvalid") ||
+ g_str_has_prefix (name, "InvalidProvide") ||
+ g_str_has_prefix (name, "InputInvalid"))
+ error->code = PK_CLIENT_ERROR_INVALID_INPUT;
+ else if (g_str_has_prefix (name, "PackInvalid") ||
+ g_str_has_prefix (name, "NoSuchFile") ||
+ g_str_has_prefix (name, "NoSuchDirectory"))
+ error->code = PK_CLIENT_ERROR_INVALID_FILE;
+ else if (g_str_has_prefix (name, "NotSupported"))
+ error->code = PK_CLIENT_ERROR_NOT_SUPPORTED;
}
-
- /* this blocks - use polkit_gnome_auth_obtain for non blocking version */
- ret = polkit_auth_obtain (action_id, 0, getpid (), &error2);
- if (dbus_error_is_set (&error2))
- egg_warning ("Failed to obtain auth: %s", error2.message);
- dbus_error_free (&error2);
-
- egg_debug ("gained %s privilege = %d", action_id, ret);
-
- polkit_action_unref (action);
-#endif
- return ret;
+out:
+ return error;
}
/**
@@ -944,7 +862,8 @@ pk_client_allow_cancel_cb (DBusGProxy *proxy, gboolean allow_cancel, PkClient *c
gboolean
pk_client_get_allow_cancel (PkClient *client, gboolean *allow_cancel, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (client->priv->tid != NULL, FALSE);
@@ -954,13 +873,21 @@ pk_client_get_allow_cancel (PkClient *client, gboolean *allow_cancel, GError **e
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "GetAllowCancel", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetAllowCancel", &error_local,
G_TYPE_INVALID,
G_TYPE_BOOLEAN, allow_cancel,
G_TYPE_INVALID);
- pk_client_error_fixup (error);
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+out:
return ret;
}
@@ -1033,8 +960,9 @@ pk_client_message_cb (DBusGProxy *proxy, const gchar *message_text, const gchar
gboolean
pk_client_get_status (PkClient *client, PkStatusEnum *status, GError **error)
{
- gboolean ret;
- gchar *status_text;
+ gboolean ret = FALSE;
+ gchar *status_text = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (status != NULL, FALSE);
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
@@ -1045,17 +973,23 @@ pk_client_get_status (PkClient *client, PkStatusEnum *status, GError **error)
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "GetStatus", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetStatus", &error_local,
G_TYPE_INVALID,
G_TYPE_STRING, &status_text,
G_TYPE_INVALID);
- pk_client_error_fixup (error);
- if (ret) {
- *status = pk_status_enum_from_text (status_text);
- g_free (status_text);
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
+ *status = pk_status_enum_from_text (status_text);
+out:
+ g_free (status_text);
return ret;
}
@@ -1073,7 +1007,8 @@ pk_client_get_status (PkClient *client, PkStatusEnum *status, GError **error)
gboolean
pk_client_get_package (PkClient *client, gchar **package, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (package != NULL, FALSE);
@@ -1084,13 +1019,21 @@ pk_client_get_package (PkClient *client, gchar **package, GError **error)
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "GetPackageLast", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetPackageLast", &error_local,
G_TYPE_INVALID,
G_TYPE_STRING, package,
G_TYPE_INVALID);
- pk_client_error_fixup (error);
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+out:
return ret;
}
@@ -1114,7 +1057,8 @@ gboolean
pk_client_get_progress (PkClient *client, guint *percentage, guint *subpercentage,
guint *elapsed, guint *remaining, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (client->priv->tid != NULL, FALSE);
@@ -1124,16 +1068,24 @@ pk_client_get_progress (PkClient *client, guint *percentage, guint *subpercentag
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "GetProgress", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetProgress", &error_local,
G_TYPE_INVALID,
G_TYPE_UINT, percentage,
G_TYPE_UINT, subpercentage,
G_TYPE_UINT, elapsed,
G_TYPE_UINT, remaining,
G_TYPE_INVALID);
- pk_client_error_fixup (error);
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+out:
return ret;
}
@@ -1152,9 +1104,10 @@ pk_client_get_progress (PkClient *client, guint *percentage, guint *subpercentag
gboolean
pk_client_get_role (PkClient *client, PkRoleEnum *role, gchar **text, GError **error)
{
- gboolean ret;
- gchar *role_text;
+ gboolean ret = FALSE;
+ gchar *role_text = NULL;
gchar *text_temp;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (role != NULL, FALSE);
@@ -1164,7 +1117,7 @@ pk_client_get_role (PkClient *client, PkRoleEnum *role, gchar **text, GError **e
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ goto out;
}
/* we can avoid a trip to the daemon */
@@ -1173,41 +1126,25 @@ pk_client_get_role (PkClient *client, PkRoleEnum *role, gchar **text, GError **e
return TRUE;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "GetRole", error,
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetRole", &error_local,
G_TYPE_INVALID,
G_TYPE_STRING, &role_text,
G_TYPE_STRING, &text_temp,
G_TYPE_INVALID);
- if (ret) {
- *role = pk_role_enum_from_text (role_text);
- g_free (role_text);
- if (text != NULL)
- *text = text_temp;
- else
- g_free (text_temp);
- }
- pk_client_error_fixup (error);
- return ret;
-}
-
-/**
- * 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;
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "Cancel", error,
- G_TYPE_INVALID, G_TYPE_INVALID);
+ *role = pk_role_enum_from_text (role_text);
+ if (text != NULL)
+ *text = text_temp;
+ else
+ g_free (text_temp);
+out:
+ g_free (role_text);
return ret;
}
@@ -1227,38 +1164,35 @@ pk_client_cancel_action (PkClient *client, GError **error)
gboolean
pk_client_cancel (PkClient *client, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* we don't need to cancel, so return TRUE */
- if (client->priv->proxy == NULL)
- return TRUE;
+ if (client->priv->proxy == NULL) {
+ ret = TRUE;
+ goto out;
+ }
/* we cannot cancel a client in ::Finished() */
if (client->priv->is_finishing) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "unable to cancel client in finished handler");
- return FALSE;
+ goto out;
}
- /* 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);
- }
+ /* 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");
+ goto out;
}
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "Cancel", &error_local,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
/* no error to process */
if (ret)
goto out;
@@ -1272,8 +1206,9 @@ pk_client_cancel (PkClient *client, GError **error)
}
/* we failed one of these, return the error to the user */
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
out:
return ret;
}
@@ -1316,8 +1251,8 @@ pk_client_transaction_timeout_cb (PkClient *client)
static gboolean
pk_client_allocate_transaction_id (PkClient *client, GError **error)
{
- gboolean ret;
- gchar *tid;
+ gboolean ret = FALSE;
+ gchar *tid = NULL;
GError *error_local = NULL;
const gchar **list;
guint len;
@@ -1332,7 +1267,7 @@ pk_client_allocate_transaction_id (PkClient *client, GError **error)
if (len > 0) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "will not queue as timeout 0");
- return FALSE;
+ goto out;
}
}
@@ -1346,7 +1281,7 @@ pk_client_allocate_transaction_id (PkClient *client, GError **error)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "failed to get a TID: %s (%i)", error_local->message, error_local->code);
}
g_error_free (error_local);
- return FALSE;
+ goto out;
}
/* free any old tid */
@@ -1355,19 +1290,19 @@ pk_client_allocate_transaction_id (PkClient *client, GError **error)
/* set that new ID to this GObject */
ret = pk_client_set_tid (client, tid, &error_local);
- g_free (tid);
if (!ret) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "failed to set TID: %s", error_local->message);
g_error_free (error_local);
- return FALSE;
+ goto out;
}
/* set a timeout */
if (client->priv->timeout > 0)
client->priv->timeout_id = g_timeout_add (client->priv->timeout, (GSourceFunc) pk_client_transaction_timeout_cb, client);
-
- return TRUE;
+out:
+ g_free (tid);
+ return ret;
}
/**
@@ -1383,8 +1318,9 @@ pk_client_allocate_transaction_id (PkClient *client, GError **error)
gboolean
pk_client_get_updates (PkClient *client, PkBitfield filters, GError **error)
{
- gboolean ret;
- gchar *filter_text;
+ gboolean ret = FALSE;
+ gchar *filter_text = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -1393,13 +1329,13 @@ pk_client_get_updates (PkClient *client, PkBitfield filters, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_GET_UPDATES;
@@ -1409,14 +1345,24 @@ pk_client_get_updates (PkClient *client, PkBitfield filters, GError **error)
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
filter_text = pk_filter_bitfield_to_text (filters);
- ret = dbus_g_proxy_call (client->priv->proxy, "GetUpdates", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetUpdates", &error_local,
G_TYPE_STRING, filter_text,
G_TYPE_INVALID, G_TYPE_INVALID);
- g_free (filter_text);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -1424,7 +1370,8 @@ pk_client_get_updates (PkClient *client, PkBitfield filters, GError **error)
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
+ g_free (filter_text);
return ret;
}
@@ -1440,7 +1387,8 @@ pk_client_get_updates (PkClient *client, PkBitfield filters, GError **error)
gboolean
pk_client_get_categories (PkClient *client, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -1449,13 +1397,13 @@ pk_client_get_categories (PkClient *client, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_GET_CATEGORIES;
@@ -1468,11 +1416,22 @@ pk_client_get_categories (PkClient *client, GError **error)
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "GetCategories", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetCategories", &error_local,
G_TYPE_INVALID, G_TYPE_INVALID);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -1480,30 +1439,7 @@ pk_client_get_categories (PkClient *client, GError **error)
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
- return ret;
-}
-
-/**
- * pk_client_update_system_action:
- **/
-static gboolean
-pk_client_update_system_action (PkClient *client, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (client != NULL, FALSE);
- 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) {
- if (error != 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, "UpdateSystem", error,
- G_TYPE_INVALID, G_TYPE_INVALID);
+out:
return ret;
}
@@ -1524,7 +1460,7 @@ pk_client_update_system_action (PkClient *client, GError **error)
gboolean
pk_client_update_system (PkClient *client, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
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);
@@ -1534,7 +1470,7 @@ pk_client_update_system (PkClient *client, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
@@ -1545,34 +1481,28 @@ pk_client_update_system (PkClient *client, GError **error)
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_UPDATE_SYSTEM;
- /* hopefully do the operation first time */
- ret = pk_client_update_system_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);
-
- /* get a new tid */
- 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_local);
- }
+ /* check to see if we have a valid proxy */
+ if (client->priv->proxy == NULL) {
+ if (error != NULL)
+ *error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
+ ret = FALSE;
+ goto out;
}
-out:
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "UpdateSystem", &error_local,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- if (ret && !client->priv->is_finished) {
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -1580,7 +1510,7 @@ out:
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
-
+out:
return ret;
}
@@ -1599,8 +1529,9 @@ out:
gboolean
pk_client_search_name (PkClient *client, PkBitfield filters, const gchar *search, GError **error)
{
- gboolean ret;
- gchar *filter_text;
+ gboolean ret = FALSE;
+ gchar *filter_text = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -1609,13 +1540,13 @@ pk_client_search_name (PkClient *client, PkBitfield filters, const gchar *search
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_SEARCH_NAME;
@@ -1626,15 +1557,25 @@ pk_client_search_name (PkClient *client, PkBitfield filters, const gchar *search
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
filter_text = pk_filter_bitfield_to_text (filters);
- ret = dbus_g_proxy_call (client->priv->proxy, "SearchName", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "SearchName", &error_local,
G_TYPE_STRING, filter_text,
G_TYPE_STRING, search,
G_TYPE_INVALID, G_TYPE_INVALID);
- g_free (filter_text);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -1642,7 +1583,8 @@ pk_client_search_name (PkClient *client, PkBitfield filters, const gchar *search
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
+ g_free (filter_text);
return ret;
}
@@ -1662,8 +1604,9 @@ pk_client_search_name (PkClient *client, PkBitfield filters, const gchar *search
gboolean
pk_client_search_details (PkClient *client, PkBitfield filters, const gchar *search, GError **error)
{
- gboolean ret;
- gchar *filter_text;
+ gboolean ret = FALSE;
+ gchar *filter_text = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -1672,13 +1615,13 @@ pk_client_search_details (PkClient *client, PkBitfield filters, const gchar *sea
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_SEARCH_DETAILS;
@@ -1689,15 +1632,25 @@ pk_client_search_details (PkClient *client, PkBitfield filters, const gchar *sea
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
filter_text = pk_filter_bitfield_to_text (filters);
- ret = dbus_g_proxy_call (client->priv->proxy, "SearchDetails", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "SearchDetails", &error_local,
G_TYPE_STRING, filter_text,
G_TYPE_STRING, search,
G_TYPE_INVALID, G_TYPE_INVALID);
- g_free (filter_text);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -1705,7 +1658,8 @@ pk_client_search_details (PkClient *client, PkBitfield filters, const gchar *sea
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
+ g_free (filter_text);
return ret;
}
@@ -1723,8 +1677,9 @@ pk_client_search_details (PkClient *client, PkBitfield filters, const gchar *sea
gboolean
pk_client_search_group (PkClient *client, PkBitfield filters, const gchar *search, GError **error)
{
- gboolean ret;
- gchar *filter_text;
+ gboolean ret = FALSE;
+ gchar *filter_text = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -1733,13 +1688,13 @@ pk_client_search_group (PkClient *client, PkBitfield filters, const gchar *searc
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_SEARCH_GROUP;
@@ -1750,15 +1705,25 @@ pk_client_search_group (PkClient *client, PkBitfield filters, const gchar *searc
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
filter_text = pk_filter_bitfield_to_text (filters);
- ret = dbus_g_proxy_call (client->priv->proxy, "SearchGroup", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "SearchGroup", &error_local,
G_TYPE_STRING, filter_text,
G_TYPE_STRING, search,
G_TYPE_INVALID, G_TYPE_INVALID);
- g_free (filter_text);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -1766,7 +1731,8 @@ pk_client_search_group (PkClient *client, PkBitfield filters, const gchar *searc
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
+ g_free (filter_text);
return ret;
}
@@ -1784,8 +1750,9 @@ pk_client_search_group (PkClient *client, PkBitfield filters, const gchar *searc
gboolean
pk_client_search_file (PkClient *client, PkBitfield filters, const gchar *search, GError **error)
{
- gboolean ret;
- gchar *filter_text;
+ gboolean ret = FALSE;
+ gchar *filter_text = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -1794,13 +1761,13 @@ pk_client_search_file (PkClient *client, PkBitfield filters, const gchar *search
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_SEARCH_FILE;
@@ -1811,15 +1778,25 @@ pk_client_search_file (PkClient *client, PkBitfield filters, const gchar *search
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
filter_text = pk_filter_bitfield_to_text (filters);
- ret = dbus_g_proxy_call (client->priv->proxy, "SearchFile", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "SearchFile", &error_local,
G_TYPE_STRING, filter_text,
G_TYPE_STRING, search,
G_TYPE_INVALID, G_TYPE_INVALID);
- g_free (filter_text);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -1827,7 +1804,8 @@ pk_client_search_file (PkClient *client, PkBitfield filters, const gchar *search
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
+ g_free (filter_text);
return ret;
}
@@ -1846,9 +1824,10 @@ pk_client_search_file (PkClient *client, PkBitfield filters, const gchar *search
gboolean
pk_client_get_depends (PkClient *client, PkBitfield filters, gchar **package_ids, gboolean recursive, GError **error)
{
- gboolean ret;
- gchar *filter_text;
+ gboolean ret = FALSE;
+ gchar *filter_text = NULL;
gchar *package_ids_temp;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (package_ids != NULL, FALSE);
@@ -1858,7 +1837,7 @@ pk_client_get_depends (PkClient *client, PkBitfield filters, gchar **package_ids
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* check the PackageIDs here to avoid a round trip if invalid */
@@ -1868,13 +1847,13 @@ pk_client_get_depends (PkClient *client, PkBitfield filters, gchar **package_ids
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_INVALID_INPUT, "package_ids '%s' are not valid", package_ids_temp);
g_free (package_ids_temp);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_GET_DEPENDS;
@@ -1886,16 +1865,26 @@ pk_client_get_depends (PkClient *client, PkBitfield filters, gchar **package_ids
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
filter_text = pk_filter_bitfield_to_text (filters);
- ret = dbus_g_proxy_call (client->priv->proxy, "GetDepends", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetDepends", &error_local,
G_TYPE_STRING, filter_text,
G_TYPE_STRV, package_ids,
G_TYPE_BOOLEAN, recursive,
G_TYPE_INVALID, G_TYPE_INVALID);
- g_free (filter_text);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -1903,7 +1892,8 @@ pk_client_get_depends (PkClient *client, PkBitfield filters, gchar **package_ids
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
+ g_free (filter_text);
return ret;
}
@@ -1919,8 +1909,9 @@ pk_client_get_depends (PkClient *client, PkBitfield filters, gchar **package_ids
gboolean
pk_client_download_packages (PkClient *client, gchar **package_ids, const gchar *directory, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
gchar *package_ids_temp;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (package_ids != NULL, FALSE);
@@ -1930,7 +1921,7 @@ pk_client_download_packages (PkClient *client, gchar **package_ids, const gchar
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* check the PackageIDs here to avoid a round trip if invalid */
@@ -1940,14 +1931,13 @@ pk_client_download_packages (PkClient *client, gchar **package_ids, const gchar
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_INVALID_INPUT, "package_ids '%s' are not valid", package_ids_temp);
g_free (package_ids_temp);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
- if (!ret) {
- return FALSE;
- }
+ if (!ret)
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_DOWNLOAD_PACKAGES;
@@ -1958,12 +1948,23 @@ pk_client_download_packages (PkClient *client, gchar **package_ids, const gchar
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "DownloadPackages", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "DownloadPackages", &error_local,
G_TYPE_STRV, package_ids,
G_TYPE_INVALID, G_TYPE_INVALID);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -1971,7 +1972,7 @@ pk_client_download_packages (PkClient *client, gchar **package_ids, const gchar
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
return ret;
}
@@ -1988,8 +1989,9 @@ pk_client_download_packages (PkClient *client, gchar **package_ids, const gchar
gboolean
pk_client_get_packages (PkClient *client, PkBitfield filters, GError **error)
{
- gboolean ret;
- gchar *filter_text;
+ gboolean ret = FALSE;
+ gchar *filter_text = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -1998,13 +2000,13 @@ pk_client_get_packages (PkClient *client, PkBitfield filters, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_GET_PACKAGES;
@@ -2014,14 +2016,24 @@ pk_client_get_packages (PkClient *client, PkBitfield filters, GError **error)
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
filter_text = pk_filter_bitfield_to_text (filters);
- ret = dbus_g_proxy_call (client->priv->proxy, "GetPackages", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetPackages", &error_local,
G_TYPE_STRING, filter_text,
G_TYPE_INVALID, G_TYPE_INVALID);
- g_free (filter_text);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2029,7 +2041,8 @@ pk_client_get_packages (PkClient *client, PkBitfield filters, GError **error)
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
+ g_free (filter_text);
return ret;
}
@@ -2048,7 +2061,8 @@ pk_client_get_packages (PkClient *client, PkBitfield filters, GError **error)
gboolean
pk_client_set_locale (PkClient *client, const gchar *code, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (code != NULL, FALSE);
@@ -2058,12 +2072,20 @@ pk_client_set_locale (PkClient *client, const gchar *code, GError **error)
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "SetLocale", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "SetLocale", &error_local,
G_TYPE_STRING, code,
G_TYPE_INVALID, G_TYPE_INVALID);
- pk_client_error_fixup (error);
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+out:
return ret;
}
@@ -2082,9 +2104,10 @@ pk_client_set_locale (PkClient *client, const gchar *code, GError **error)
gboolean
pk_client_get_requires (PkClient *client, PkBitfield filters, gchar **package_ids, gboolean recursive, GError **error)
{
- gboolean ret;
- gchar *filter_text;
+ gboolean ret = FALSE;
+ gchar *filter_text = NULL;
gchar *package_ids_temp;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (package_ids != NULL, FALSE);
@@ -2094,7 +2117,7 @@ pk_client_get_requires (PkClient *client, PkBitfield filters, gchar **package_id
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* check the PackageIDs here to avoid a round trip if invalid */
@@ -2104,13 +2127,13 @@ pk_client_get_requires (PkClient *client, PkBitfield filters, gchar **package_id
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_INVALID_INPUT, "package_ids '%s' are not valid", package_ids_temp);
g_free (package_ids_temp);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_GET_REQUIRES;
@@ -2122,16 +2145,26 @@ pk_client_get_requires (PkClient *client, PkBitfield filters, gchar **package_id
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
filter_text = pk_filter_bitfield_to_text (filters);
- ret = dbus_g_proxy_call (client->priv->proxy, "GetRequires", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetRequires", &error_local,
G_TYPE_STRING, filter_text,
G_TYPE_STRV, package_ids,
G_TYPE_BOOLEAN, recursive,
G_TYPE_INVALID, G_TYPE_INVALID);
- g_free (filter_text);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2139,7 +2172,8 @@ pk_client_get_requires (PkClient *client, PkBitfield filters, gchar **package_id
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
+ g_free (filter_text);
return ret;
}
@@ -2161,9 +2195,10 @@ gboolean
pk_client_what_provides (PkClient *client, PkBitfield filters, PkProvidesEnum provides,
const gchar *search, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
const gchar *provides_text;
- gchar *filter_text;
+ gchar *filter_text = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (provides != PK_PROVIDES_ENUM_UNKNOWN, FALSE);
@@ -2174,13 +2209,13 @@ pk_client_what_provides (PkClient *client, PkBitfield filters, PkProvidesEnum pr
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_WHAT_PROVIDES;
@@ -2194,16 +2229,26 @@ pk_client_what_provides (PkClient *client, PkBitfield filters, PkProvidesEnum pr
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
filter_text = pk_filter_bitfield_to_text (filters);
- ret = dbus_g_proxy_call (client->priv->proxy, "WhatProvides", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "WhatProvides", &error_local,
G_TYPE_STRING, filter_text,
G_TYPE_STRING, provides_text,
G_TYPE_STRING, search,
G_TYPE_INVALID, G_TYPE_INVALID);
- g_free (filter_text);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2211,7 +2256,8 @@ pk_client_what_provides (PkClient *client, PkBitfield filters, PkProvidesEnum pr
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
+ g_free (filter_text);
return ret;
}
@@ -2229,8 +2275,9 @@ pk_client_what_provides (PkClient *client, PkBitfield filters, PkProvidesEnum pr
gboolean
pk_client_get_update_detail (PkClient *client, gchar **package_ids, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
gchar *package_ids_temp;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (package_ids != NULL, FALSE);
@@ -2240,7 +2287,7 @@ pk_client_get_update_detail (PkClient *client, gchar **package_ids, GError **err
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* check the PackageIDs here to avoid a round trip if invalid */
@@ -2250,13 +2297,13 @@ pk_client_get_update_detail (PkClient *client, gchar **package_ids, GError **err
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_INVALID_INPUT, "package_ids '%s' are not valid", package_ids_temp);
g_free (package_ids_temp);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_GET_UPDATE_DETAIL;
@@ -2270,12 +2317,23 @@ pk_client_get_update_detail (PkClient *client, gchar **package_ids, GError **err
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "GetUpdateDetail", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetUpdateDetail", &error_local,
G_TYPE_STRV, package_ids,
G_TYPE_INVALID, G_TYPE_INVALID);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2283,30 +2341,7 @@ pk_client_get_update_detail (PkClient *client, gchar **package_ids, GError **err
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
- return ret;
-}
-
-/**
- * pk_client_rollback_action:
- **/
-static gboolean
-pk_client_rollback_action (PkClient *client, const gchar *transaction_id, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (client != NULL, FALSE);
- 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, "Rollback", error,
- G_TYPE_STRING, transaction_id,
- G_TYPE_INVALID, G_TYPE_INVALID);
+out:
return ret;
}
@@ -2324,7 +2359,7 @@ pk_client_rollback_action (PkClient *client, const gchar *transaction_id, GError
gboolean
pk_client_rollback (PkClient *client, const gchar *transaction_id, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
@@ -2334,46 +2369,39 @@ pk_client_rollback (PkClient *client, const gchar *transaction_id, GError **erro
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_ROLLBACK;
client->priv->cached_transaction_id = g_strdup (transaction_id);
- /* hopefully do the operation first time */
- ret = pk_client_rollback_action (client, transaction_id, &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);
-
- /* get a new tid */
- ret = pk_client_allocate_transaction_id (client, &error_local);
- if (!ret)
- goto out;
-
- /* retry the action now we have got auth */
- ret = pk_client_rollback_action (client, transaction_id, &error_local);
- }
+ /* 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");
+ goto out;
}
-out:
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "Rollback", &error_local,
+ G_TYPE_STRING, transaction_id,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- if (ret && !client->priv->is_finished) {
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2381,7 +2409,7 @@ out:
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
-
+out:
return ret;
}
@@ -2401,8 +2429,9 @@ out:
gboolean
pk_client_resolve (PkClient *client, PkBitfield filters, gchar **packages, GError **error)
{
- gboolean ret;
- gchar *filter_text;
+ gboolean ret = FALSE;
+ gchar *filter_text = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (packages != NULL, FALSE);
@@ -2412,13 +2441,13 @@ pk_client_resolve (PkClient *client, PkBitfield filters, gchar **packages, GErro
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_RESOLVE;
@@ -2429,15 +2458,25 @@ pk_client_resolve (PkClient *client, PkBitfield filters, gchar **packages, GErro
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
filter_text = pk_filter_bitfield_to_text (filters);
- ret = dbus_g_proxy_call (client->priv->proxy, "Resolve", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "Resolve", &error_local,
G_TYPE_STRING, filter_text,
G_TYPE_STRV, packages,
G_TYPE_INVALID, G_TYPE_INVALID);
- g_free (filter_text);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2445,7 +2484,8 @@ pk_client_resolve (PkClient *client, PkBitfield filters, gchar **packages, GErro
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
+ g_free (filter_text);
return ret;
}
@@ -2463,8 +2503,9 @@ pk_client_resolve (PkClient *client, PkBitfield filters, gchar **packages, GErro
gboolean
pk_client_get_details (PkClient *client, gchar **package_ids, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
gchar *package_ids_temp;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (package_ids != NULL, FALSE);
@@ -2474,7 +2515,7 @@ pk_client_get_details (PkClient *client, gchar **package_ids, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* check the PackageIDs here to avoid a round trip if invalid */
@@ -2484,13 +2525,13 @@ pk_client_get_details (PkClient *client, gchar **package_ids, GError **error)
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_INVALID_INPUT, "package_ids '%s' are not valid", package_ids_temp);
g_free (package_ids_temp);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* we use the cached objects support */
pk_obj_list_set_copy (client->priv->cached_data, (PkObjListCopyFunc) pk_details_obj_copy);
@@ -2504,12 +2545,23 @@ pk_client_get_details (PkClient *client, gchar **package_ids, GError **error)
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "GetDetails", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetDetails", &error_local,
G_TYPE_STRV, package_ids,
G_TYPE_INVALID, G_TYPE_INVALID);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2517,7 +2569,7 @@ pk_client_get_details (PkClient *client, gchar **package_ids, GError **error)
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
return ret;
}
@@ -2534,7 +2586,8 @@ pk_client_get_details (PkClient *client, gchar **package_ids, GError **error)
gboolean
pk_client_get_distro_upgrades (PkClient *client, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -2543,13 +2596,13 @@ pk_client_get_distro_upgrades (PkClient *client, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_GET_DISTRO_UPGRADES;
@@ -2562,11 +2615,22 @@ pk_client_get_distro_upgrades (PkClient *client, GError **error)
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "GetDistroUpgrades", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetDistroUpgrades", &error_local,
G_TYPE_INVALID, G_TYPE_INVALID);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2574,7 +2638,7 @@ pk_client_get_distro_upgrades (PkClient *client, GError **error)
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
+out:
return ret;
}
@@ -2591,8 +2655,9 @@ pk_client_get_distro_upgrades (PkClient *client, GError **error)
gboolean
pk_client_get_files (PkClient *client, gchar **package_ids, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
gchar *package_ids_temp;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (package_ids != NULL, FALSE);
@@ -2602,7 +2667,7 @@ pk_client_get_files (PkClient *client, gchar **package_ids, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* check the PackageIDs here to avoid a round trip if invalid */
@@ -2612,13 +2677,13 @@ pk_client_get_files (PkClient *client, gchar **package_ids, GError **error)
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_INVALID_INPUT, "package_ids '%s' are not valid", package_ids_temp);
g_free (package_ids_temp);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_GET_FILES;
@@ -2628,12 +2693,23 @@ pk_client_get_files (PkClient *client, gchar **package_ids, GError **error)
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "GetFiles", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetFiles", &error_local,
G_TYPE_STRV, package_ids,
G_TYPE_INVALID, G_TYPE_INVALID);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2641,34 +2717,7 @@ pk_client_get_files (PkClient *client, gchar **package_ids, GError **error)
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- pk_client_error_fixup (error);
- return ret;
-}
-
-/**
- * pk_client_remove_packages_action:
- **/
-static gboolean
-pk_client_remove_packages_action (PkClient *client, gchar **package_ids,
- gboolean allow_deps, gboolean autoremove,
- GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (client != NULL, FALSE);
- 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, "RemovePackages", error,
- G_TYPE_STRV, package_ids,
- G_TYPE_BOOLEAN, allow_deps,
- G_TYPE_BOOLEAN, autoremove,
- G_TYPE_INVALID, G_TYPE_INVALID);
+out:
return ret;
}
@@ -2690,7 +2739,7 @@ gboolean
pk_client_remove_packages (PkClient *client, gchar **package_ids, gboolean allow_deps,
gboolean autoremove, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
gchar *package_ids_temp;
GError *error_local = NULL; /* we can't use the same error as we might be NULL */
@@ -2702,7 +2751,7 @@ pk_client_remove_packages (PkClient *client, gchar **package_ids, gboolean allow
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* check the PackageIDs here to avoid a round trip if invalid */
@@ -2712,7 +2761,7 @@ pk_client_remove_packages (PkClient *client, gchar **package_ids, gboolean allow
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_INVALID_INPUT, "package_ids '%s' are not valid", package_ids_temp);
g_free (package_ids_temp);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
@@ -2726,34 +2775,29 @@ pk_client_remove_packages (PkClient *client, gchar **package_ids, gboolean allow
client->priv->cached_autoremove = autoremove;
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_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);
-
- /* get a new tid */
- 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_local);
- }
+ /* 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");
+ goto out;
}
-out:
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "RemovePackages", &error_local,
+ G_TYPE_STRV, package_ids,
+ G_TYPE_BOOLEAN, allow_deps,
+ G_TYPE_BOOLEAN, autoremove,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- if (ret && !client->priv->is_finished) {
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2761,30 +2805,7 @@ out:
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
-
- return ret;
-}
-
-/**
- * pk_client_refresh_cache_action:
- **/
-static gboolean
-pk_client_refresh_cache_action (PkClient *client, gboolean force, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (client != NULL, FALSE);
- 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, "RefreshCache", error,
- G_TYPE_BOOLEAN, force,
- G_TYPE_INVALID, G_TYPE_INVALID);
+out:
return ret;
}
@@ -2804,7 +2825,7 @@ pk_client_refresh_cache_action (PkClient *client, gboolean force, GError **error
gboolean
pk_client_refresh_cache (PkClient *client, gboolean force, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
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);
@@ -2814,7 +2835,7 @@ pk_client_refresh_cache (PkClient *client, gboolean force, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
@@ -2826,34 +2847,27 @@ pk_client_refresh_cache (PkClient *client, gboolean force, GError **error)
client->priv->role = PK_ROLE_ENUM_REFRESH_CACHE;
client->priv->cached_force = force;
- /* hopefully do the operation first time */
- ret = pk_client_refresh_cache_action (client, force, &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);
-
- /* get a new tid */
- 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_local);
- }
+ /* 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");
+ goto out;
}
-out:
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "RefreshCache", &error_local,
+ G_TYPE_BOOLEAN, force,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- if (ret && !client->priv->is_finished) {
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2861,30 +2875,7 @@ out:
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
-
- return ret;
-}
-
-/**
- * pk_client_install_package_action:
- **/
-static gboolean
-pk_client_install_package_action (PkClient *client, gchar **package_ids, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (client != NULL, FALSE);
- 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, "InstallPackages", error,
- G_TYPE_STRV, package_ids,
- G_TYPE_INVALID, G_TYPE_INVALID);
+out:
return ret;
}
@@ -2901,7 +2892,7 @@ pk_client_install_package_action (PkClient *client, gchar **package_ids, GError
gboolean
pk_client_install_packages (PkClient *client, gchar **package_ids, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
gchar *package_ids_temp;
GError *error_local = NULL; /* we can't use the same error as we might be NULL */
@@ -2913,7 +2904,7 @@ pk_client_install_packages (PkClient *client, gchar **package_ids, GError **erro
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* check the PackageIDs here to avoid a round trip if invalid */
@@ -2923,7 +2914,7 @@ pk_client_install_packages (PkClient *client, gchar **package_ids, GError **erro
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_INVALID_INPUT, "package_ids '%s' are not valid", package_ids_temp);
g_free (package_ids_temp);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
@@ -2935,34 +2926,27 @@ pk_client_install_packages (PkClient *client, gchar **package_ids, GError **erro
client->priv->role = PK_ROLE_ENUM_INSTALL_PACKAGES;
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_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);
-
- /* get a new tid */
- 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_local);
- }
+ /* 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");
+ goto out;
}
-out:
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "InstallPackages", &error_local,
+ G_TYPE_STRV, package_ids,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- if (ret && !client->priv->is_finished) {
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -2970,35 +2954,7 @@ out:
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
-
- return ret;
-}
-
-/**
- * pk_client_install_signature_action:
- **/
-static gboolean
-pk_client_install_signature_action (PkClient *client, PkSigTypeEnum type, const gchar *key_id,
- const gchar *package_id, GError **error)
-{
- gboolean ret;
- const gchar *type_text;
-
- g_return_val_if_fail (client != NULL, FALSE);
- 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;
- }
- type_text = pk_sig_type_enum_to_text (type);
- ret = dbus_g_proxy_call (client->priv->proxy, "InstallSignature", error,
- G_TYPE_STRING, type_text,
- G_TYPE_STRING, key_id,
- G_TYPE_STRING, package_id,
- G_TYPE_INVALID, G_TYPE_INVALID);
+out:
return ret;
}
@@ -3016,7 +2972,8 @@ gboolean
pk_client_install_signature (PkClient *client, PkSigTypeEnum type, const gchar *key_id,
const gchar *package_id, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
+ const gchar *type_text;
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);
@@ -3029,7 +2986,7 @@ pk_client_install_signature (PkClient *client, PkSigTypeEnum type, const gchar *
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
@@ -3042,34 +2999,30 @@ pk_client_install_signature (PkClient *client, PkSigTypeEnum type, const gchar *
client->priv->cached_package_id = g_strdup (package_id);
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_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);
-
- /* get a new tid */
- 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_local);
- }
+ /* 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");
+ goto out;
}
+ type_text = pk_sig_type_enum_to_text (type);
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "InstallSignature", &error_local,
+ G_TYPE_STRING, type_text,
+ G_TYPE_STRING, key_id,
+ G_TYPE_STRING, package_id,
+ G_TYPE_INVALID, G_TYPE_INVALID);
-out:
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- if (ret && !client->priv->is_finished) {
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -3077,30 +3030,7 @@ out:
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
-
- return ret;
-}
-
-/**
- * pk_client_update_packages_action:
- **/
-static gboolean
-pk_client_update_packages_action (PkClient *client, gchar **package_ids, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (client != NULL, FALSE);
- 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, "UpdatePackages", error,
- G_TYPE_STRV, package_ids,
- G_TYPE_INVALID, G_TYPE_INVALID);
+out:
return ret;
}
@@ -3117,7 +3047,7 @@ pk_client_update_packages_action (PkClient *client, gchar **package_ids, GError
gboolean
pk_client_update_packages (PkClient *client, gchar **package_ids, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
gchar *package_ids_temp;
GError *error_local = NULL; /* we can't use the same error as we might be NULL */
@@ -3129,7 +3059,7 @@ pk_client_update_packages (PkClient *client, gchar **package_ids, GError **error
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* check the PackageIDs here to avoid a round trip if invalid */
@@ -3139,7 +3069,7 @@ pk_client_update_packages (PkClient *client, gchar **package_ids, GError **error
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_INVALID_INPUT, "package_ids '%s' are not valid", package_ids_temp);
g_free (package_ids_temp);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
@@ -3155,34 +3085,27 @@ pk_client_update_packages (PkClient *client, gchar **package_ids, GError **error
client->priv->cached_package_ids = g_strdupv (package_ids);
}
- /* hopefully do the operation first time */
- 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_local)) {
- /* try to get auth */
- if (pk_client_error_auth_obtain (error_local)) {
- /* clear old error */
- g_clear_error (&error_local);
-
- /* get a new tid */
- 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_local);
- }
+ /* 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");
+ goto out;
}
-out:
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "UpdatePackages", &error_local,
+ G_TYPE_STRV, package_ids,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- if (ret && !client->priv->is_finished) {
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -3190,31 +3113,7 @@ out:
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
-
- return ret;
-}
-
-/**
- * pk_client_install_files_action:
- **/
-static gboolean
-pk_client_install_files_action (PkClient *client, gboolean trusted, gchar **files, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (client != NULL, FALSE);
- 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, "InstallFiles", error,
- G_TYPE_BOOLEAN, trusted,
- G_TYPE_STRV, files,
- G_TYPE_INVALID, G_TYPE_INVALID);
+out:
return ret;
}
@@ -3232,9 +3131,8 @@ pk_resolve_local_path (const gchar *rel_path)
gchar *temp;
/* don't trust realpath one little bit */
- if (rel_path == NULL) {
+ if (rel_path == NULL)
return NULL;
- }
/* ITS4: ignore, glibc allocates us a buffer to try and fix some brain damage */
temp = realpath (rel_path, NULL);
@@ -3263,7 +3161,7 @@ pk_client_install_files (PkClient *client, gboolean trusted, gchar **files_rel,
{
guint i;
guint length;
- gboolean ret;
+ gboolean ret = FALSE;
gchar **files = NULL;
gchar *file;
GError *error_local = NULL; /* we can't use the same error as we might be NULL */
@@ -3276,7 +3174,7 @@ pk_client_install_files (PkClient *client, gboolean trusted, gchar **files_rel,
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
@@ -3304,34 +3202,28 @@ pk_client_install_files (PkClient *client, gboolean trusted, gchar **files_rel,
client->priv->cached_trusted = trusted;
client->priv->cached_full_paths = g_strdupv (files);
- /* hopefully do the operation first time */
- 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_local)) {
- /* try to get auth */
- if (pk_client_error_auth_obtain (error_local)) {
- /* clear old error */
- g_clear_error (&error_local);
-
- /* get a new tid */
- 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_local);
- }
+ /* 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");
+ goto out;
}
-out:
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "InstallFiles", &error_local,
+ G_TYPE_BOOLEAN, trusted,
+ G_TYPE_STRV, files,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- if (ret && !client->priv->is_finished) {
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -3339,7 +3231,7 @@ out:
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
-
+out:
g_strfreev (files);
return ret;
}
@@ -3356,8 +3248,9 @@ out:
gboolean
pk_client_get_repo_list (PkClient *client, PkBitfield filters, GError **error)
{
- gboolean ret;
- gchar *filter_text;
+ gboolean ret = FALSE;
+ gchar *filter_text = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -3366,13 +3259,13 @@ pk_client_get_repo_list (PkClient *client, PkBitfield filters, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_GET_REPO_LIST;
@@ -3382,15 +3275,24 @@ pk_client_get_repo_list (PkClient *client, PkBitfield filters, GError **error)
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
filter_text = pk_filter_bitfield_to_text (filters);
- ret = dbus_g_proxy_call (client->priv->proxy, "GetRepoList", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetRepoList", &error_local,
G_TYPE_STRING, filter_text,
G_TYPE_INVALID, G_TYPE_INVALID);
- g_free (filter_text);
- pk_client_error_fixup (error);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -3398,29 +3300,8 @@ pk_client_get_repo_list (PkClient *client, PkBitfield filters, GError **error)
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
- return ret;
-}
-
-/**
- * pk_client_accept_eula_action:
- **/
-static gboolean
-pk_client_accept_eula_action (PkClient *client, const gchar *eula_id, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (client != NULL, FALSE);
- 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, "AcceptEula", error,
- G_TYPE_STRING, eula_id,
- G_TYPE_INVALID, G_TYPE_INVALID);
+out:
+ g_free (filter_text);
return ret;
}
@@ -3437,7 +3318,7 @@ pk_client_accept_eula_action (PkClient *client, const gchar *eula_id, GError **e
gboolean
pk_client_accept_eula (PkClient *client, const gchar *eula_id, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
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);
@@ -3448,7 +3329,7 @@ pk_client_accept_eula (PkClient *client, const gchar *eula_id, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
@@ -3459,34 +3340,27 @@ pk_client_accept_eula (PkClient *client, const gchar *eula_id, GError **error)
/* save this so we can re-issue it */
client->priv->role = PK_ROLE_ENUM_ACCEPT_EULA;
- /* hopefully do the operation first time */
- 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_local)) {
- /* try to get auth */
- if (pk_client_error_auth_obtain (error_local)) {
- /* clear old error */
- g_clear_error (&error_local);
-
- /* get a new tid */
- 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_local);
- }
+ /* 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");
+ goto out;
}
-out:
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "AcceptEula", &error_local,
+ G_TYPE_STRING, eula_id,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- if (ret && !client->priv->is_finished) {
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -3494,31 +3368,7 @@ out:
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
-
- return ret;
-}
-
-/**
- * pk_client_repo_enable_action:
- **/
-static gboolean
-pk_client_repo_enable_action (PkClient *client, const gchar *repo_id, gboolean enabled, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (client != NULL, FALSE);
- 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, "RepoEnable", error,
- G_TYPE_STRING, repo_id,
- G_TYPE_BOOLEAN, enabled,
- G_TYPE_INVALID, G_TYPE_INVALID);
+out:
return ret;
}
@@ -3536,7 +3386,7 @@ pk_client_repo_enable_action (PkClient *client, const gchar *repo_id, gboolean e
gboolean
pk_client_repo_enable (PkClient *client, const gchar *repo_id, gboolean enabled, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
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);
@@ -3547,7 +3397,7 @@ pk_client_repo_enable (PkClient *client, const gchar *repo_id, gboolean enabled,
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
@@ -3558,34 +3408,28 @@ pk_client_repo_enable (PkClient *client, const gchar *repo_id, gboolean enabled,
/* save this so we can re-issue it */
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_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);
-
- /* get a new tid */
- 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_local);
- }
+ /* 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");
+ goto out;
}
-out:
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "RepoEnable", &error_local,
+ G_TYPE_STRING, repo_id,
+ G_TYPE_BOOLEAN, enabled,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- if (ret && !client->priv->is_finished) {
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -3593,33 +3437,7 @@ out:
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
-
- return ret;
-}
-
-/**
- * pk_client_repo_set_data_action:
- **/
-static gboolean
-pk_client_repo_set_data_action (PkClient *client, const gchar *repo_id,
- const gchar *parameter, const gchar *value, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (client != NULL, FALSE);
- 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, "RepoSetData", error,
- G_TYPE_STRING, repo_id,
- G_TYPE_STRING, parameter,
- G_TYPE_STRING, value,
- G_TYPE_INVALID, G_TYPE_INVALID);
+out:
return ret;
}
@@ -3640,7 +3458,7 @@ gboolean
pk_client_repo_set_data (PkClient *client, const gchar *repo_id, const gchar *parameter,
const gchar *value, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
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);
@@ -3653,7 +3471,7 @@ pk_client_repo_set_data (PkClient *client, const gchar *repo_id, const gchar *pa
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
@@ -3664,34 +3482,29 @@ pk_client_repo_set_data (PkClient *client, const gchar *repo_id, const gchar *pa
/* save this so we can re-issue it */
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_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);
-
- /* get a new tid */
- 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_local);
- }
+ /* 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");
+ goto out;
}
-out:
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "RepoSetData", &error_local,
+ G_TYPE_STRING, repo_id,
+ G_TYPE_STRING, parameter,
+ G_TYPE_STRING, value,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+
/* we failed one of these, return the error to the user */
if (!ret) {
- pk_client_error_fixup (&error_local);
- g_propagate_error (error, error_local);
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
}
- if (ret && !client->priv->is_finished) {
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -3699,7 +3512,7 @@ out:
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
-
+out:
return ret;
}
@@ -3717,7 +3530,8 @@ out:
gboolean
pk_client_is_caller_active (PkClient *client, gboolean *is_active, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (is_active != NULL, FALSE);
@@ -3727,13 +3541,22 @@ pk_client_is_caller_active (PkClient *client, gboolean *is_active, GError **erro
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "IsCallerActive", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "IsCallerActive", &error_local,
G_TYPE_INVALID,
G_TYPE_BOOLEAN, is_active,
G_TYPE_INVALID);
- pk_client_error_fixup (error);
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+out:
return ret;
}
@@ -3750,7 +3573,8 @@ pk_client_is_caller_active (PkClient *client, gboolean *is_active, GError **erro
gboolean
pk_client_get_old_transactions (PkClient *client, guint number, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
+ GError *error_local = NULL;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -3759,13 +3583,13 @@ pk_client_get_old_transactions (PkClient *client, guint number, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "TID already set to %s", client->priv->tid);
- return FALSE;
+ goto out;
}
/* get and set a new ID */
ret = pk_client_allocate_transaction_id (client, error);
if (!ret)
- return FALSE;
+ goto out;
/* we use the cached objects support */
pk_obj_list_set_copy (client->priv->cached_data, (PkObjListCopyFunc) pk_transaction_obj_copy);
@@ -3775,13 +3599,23 @@ pk_client_get_old_transactions (PkClient *client, guint number, GError **error)
if (client->priv->proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_NO_TID, "No proxy for transaction");
- return FALSE;
+ ret = FALSE;
+ goto out;
}
- ret = dbus_g_proxy_call (client->priv->proxy, "GetOldTransactions", error,
+
+ /* do the method */
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetOldTransactions", &error_local,
G_TYPE_UINT, number,
G_TYPE_INVALID, G_TYPE_INVALID);
- pk_client_error_fixup (error);
- if (ret && !client->priv->is_finished) {
+ if (!ret) {
+ if (error != NULL)
+ *error = pk_client_error_fixup (error_local);
+ g_error_free (error_local);
+ goto out;
+ }
+
+ /* is not already finished */
+ if (!client->priv->is_finished) {
/* allow clients to respond in the status changed callback */
pk_client_change_status (client, PK_STATUS_ENUM_WAIT);
@@ -3789,6 +3623,7 @@ pk_client_get_old_transactions (PkClient *client, guint number, GError **error)
if (client->priv->synchronous)
g_main_loop_run (client->priv->loop);
}
+out:
return ret;
}
@@ -3806,7 +3641,7 @@ pk_client_get_old_transactions (PkClient *client, guint number, GError **error)
gboolean
pk_client_requeue (PkClient *client, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
PkClientPrivate *priv = PK_CLIENT_GET_PRIVATE (client);
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
@@ -3816,14 +3651,14 @@ pk_client_requeue (PkClient *client, GError **error)
if (priv->role == PK_ROLE_ENUM_UNKNOWN) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_ROLE_UNKNOWN, "role unknown for reque");
- return FALSE;
+ goto out;
}
- /* are we still running? */
+ /* is not already finished */
if (!client->priv->is_finished) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "not finished, so cannot requeue");
- return FALSE;
+ goto out;
}
/* clear enough data of the client to allow us to requeue */
@@ -3886,9 +3721,9 @@ pk_client_requeue (PkClient *client, GError **error)
else {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_ROLE_UNKNOWN, "role unknown for reque");
- return FALSE;
+ goto out;
}
- pk_client_error_fixup (error);
+out:
return ret;
}
@@ -3908,6 +3743,7 @@ gboolean
pk_client_set_tid (PkClient *client, const gchar *tid, GError **error)
{
DBusGProxy *proxy = NULL;
+ gboolean ret = FALSE;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -3915,7 +3751,7 @@ pk_client_set_tid (PkClient *client, const gchar *tid, GError **error)
if (client->priv->tid != NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_ALREADY_TID, "cannot set the tid on an already set client");
- return FALSE;
+ goto out;
}
/* get a connection */
@@ -3924,7 +3760,7 @@ pk_client_set_tid (PkClient *client, const gchar *tid, GError **error)
if (proxy == NULL) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_ALREADY_TID, "Cannot connect to PackageKit tid %s", tid);
- return FALSE;
+ goto out;
}
/* don't timeout, as dbus-glib sets the timeout ~25 seconds */
@@ -4016,8 +3852,9 @@ pk_client_set_tid (PkClient *client, const gchar *tid, GError **error)
dbus_g_proxy_connect_signal (proxy, "Destroy",
G_CALLBACK (pk_client_destroy_cb), client, NULL);
client->priv->proxy = proxy;
-
- return TRUE;
+ ret = TRUE;
+out:
+ return ret;
}
/**
@@ -4425,7 +4262,7 @@ pk_client_disconnect_proxy (PkClient *client)
gboolean
pk_client_reset (PkClient *client, GError **error)
{
- gboolean ret;
+ gboolean ret = FALSE;
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -4436,7 +4273,7 @@ pk_client_reset (PkClient *client, GError **error)
if (client->priv->is_finishing && client->priv->synchronous) {
if (error != NULL)
*error = g_error_new (PK_CLIENT_ERROR, PK_CLIENT_ERROR_FAILED, "unable to reset synchronous client in finished handler");
- return FALSE;
+ goto out;
}
if (client->priv->tid != NULL && !client->priv->is_finished) {
@@ -4444,7 +4281,7 @@ pk_client_reset (PkClient *client, GError **error)
/* we try to cancel the running tranaction */
ret = pk_client_cancel (client, error);
if (!ret)
- return FALSE;
+ goto out;
}
/* stop the timeout timer if running */
@@ -4489,7 +4326,9 @@ pk_client_reset (PkClient *client, GError **error)
/* TODO: make clean */
pk_obj_list_clear (client->priv->cached_data);
- return TRUE;
+ ret = TRUE;
+out:
+ return ret;
}
/**
diff --git a/lib/packagekit-qt/src/client.cpp b/lib/packagekit-qt/src/client.cpp
index d231d0e..ffcd200 100644
--- a/lib/packagekit-qt/src/client.cpp
+++ b/lib/packagekit-qt/src/client.cpp
@@ -153,10 +153,12 @@ void Client::setLocale(const QString& locale)
void Client::setProxy(const QString& http_proxy, const QString& ftp_proxy)
{
+#if 0
if(!PolkitClient::instance()->getAuth(AUTH_SYSTEM_NETWORK_PROXY_CONFIGURE)) {
emit authError(AUTH_SYSTEM_NETWORK_PROXY_CONFIGURE);
return;
}
+#endif
d->daemon->SetProxy(http_proxy, ftp_proxy);
}
@@ -180,10 +182,12 @@ Client::DaemonError Client::getLastError ()
Transaction* Client::acceptEula(EulaInfo info)
{
+#if 0
if(!PolkitClient::instance()->getAuth(AUTH_PACKAGE_EULA_ACCEPT)) {
emit authError(AUTH_PACKAGE_EULA_ACCEPT);
return NULL;
}
+#endif
Transaction* t = d->createNewTransaction();
if (!t) {
@@ -376,10 +380,12 @@ Transaction* Client::getDistroUpgrades()
Transaction* Client::installFiles(const QStringList& files, bool trusted)
{
QString polkitAction = trusted ? AUTH_PACKAGE_INSTALL : AUTH_PACKAGE_INSTALL_UNTRUSTED;
+#if 0
if(!PolkitClient::instance()->getAuth(polkitAction)) {
emit authError(polkitAction);
return NULL;
}
+#endif
Transaction* t = d->createNewTransaction();
if (!t) {
@@ -399,10 +405,12 @@ Transaction* Client::installFile(const QString& file, bool trusted)
Transaction* Client::installPackages(const QList<Package*>& packages)
{
+#if 0
if(!PolkitClient::instance()->getAuth(AUTH_PACKAGE_INSTALL)) {
emit authError(AUTH_PACKAGE_INSTALL);
return NULL;
}
+#endif
Transaction* t = d->createNewTransaction();
if (!t) {
@@ -422,10 +430,12 @@ Transaction* Client::installPackage(Package* p)
Transaction* Client::installSignature(SignatureType type, const QString& key_id, Package* p)
{
+#if 0
if(!PolkitClient::instance()->getAuth(AUTH_SYSTEM_TRUST_SIGNING_KEY)) {
emit authError(AUTH_SYSTEM_TRUST_SIGNING_KEY);
return NULL;
}
+#endif
Transaction* t = d->createNewTransaction();
if (!t) {
@@ -440,10 +450,12 @@ Transaction* Client::installSignature(SignatureType type, const QString& key_id,
Transaction* Client::refreshCache(bool force)
{
+#if 0
if(!PolkitClient::instance()->getAuth(AUTH_SYSTEM_SOURCES_REFRESH)) {
emit authError(AUTH_SYSTEM_SOURCES_REFRESH);
return NULL;
}
+#endif
Transaction* t = d->createNewTransaction();
if (!t) {
@@ -458,10 +470,12 @@ Transaction* Client::refreshCache(bool force)
Transaction* Client::removePackages(const QList<Package*>& packages, bool allow_deps, bool autoremove)
{
+#if 0
if(!PolkitClient::instance()->getAuth(AUTH_PACKAGE_REMOVE)) {
emit authError(AUTH_PACKAGE_REMOVE);
return NULL;
}
+#endif
Transaction* t = d->createNewTransaction();
if (!t) {
@@ -481,10 +495,12 @@ Transaction* Client::removePackage(Package* p, bool allow_deps, bool autoremove)
Transaction* Client::repoEnable(const QString& repo_id, bool enable)
{
+#if 0
if(!PolkitClient::instance()->getAuth(AUTH_SYSTEM_SOURCES_CONFIGURE)) {
emit authError(AUTH_SYSTEM_SOURCES_CONFIGURE);
return NULL;
}
+#endif
Transaction* t = d->createNewTransaction();
if (!t) {
@@ -499,10 +515,12 @@ Transaction* Client::repoEnable(const QString& repo_id, bool enable)
Transaction* Client::repoSetData(const QString& repo_id, const QString& parameter, const QString& value)
{
+#if 0
if(!PolkitClient::instance()->getAuth(AUTH_SYSTEM_SOURCES_CONFIGURE)) {
emit authError(AUTH_SYSTEM_SOURCES_CONFIGURE);
return NULL;
}
+#endif
Transaction* t = d->createNewTransaction();
if (!t) {
@@ -535,10 +553,12 @@ Transaction* Client::resolve(const QString& packageName, Filters filters)
Transaction* Client::rollback(Transaction* oldtrans)
{
+#if 0
if(!PolkitClient::instance()->getAuth(AUTH_SYSTEM_ROLLBACK)) {
emit authError(AUTH_SYSTEM_ROLLBACK);
return NULL;
}
+#endif
Transaction* t = d->createNewTransaction();
if (!t) {
@@ -627,10 +647,12 @@ Package* Client::searchFromDesktopFile(const QString& path)
Transaction* Client::updatePackages(const QList<Package*>& packages)
{
+#if 0
if(!PolkitClient::instance()->getAuth(AUTH_SYSTEM_UPDATE)) {
emit authError(AUTH_SYSTEM_UPDATE);
return NULL;
}
+#endif
Transaction* t = d->createNewTransaction();
if (!t) {
@@ -650,10 +672,12 @@ Transaction* Client::updatePackage(Package* package)
Transaction* Client::updateSystem()
{
+#if 0
if(!PolkitClient::instance()->getAuth(AUTH_SYSTEM_UPDATE)) {
emit authError(AUTH_SYSTEM_UPDATE);
return NULL;
}
+#endif
Transaction* t = d->createNewTransaction();
if (!t) {
diff --git a/lib/packagekit-qt/src/polkitclient.cpp b/lib/packagekit-qt/src/polkitclient.cpp
index 7998752..5623c31 100644
--- a/lib/packagekit-qt/src/polkitclient.cpp
+++ b/lib/packagekit-qt/src/polkitclient.cpp
@@ -19,10 +19,6 @@
*/
#include "config.h"
-#ifdef USE_SECURITY_POLKIT
- #include <polkit-dbus/polkit-dbus.h>
-#endif
-
#include "polkitclient.h"
using namespace PackageKit;
@@ -38,6 +34,8 @@ PolkitClient* PolkitClient::instance()
PolkitClient::PolkitClient(QObject *parent) : QObject(parent) {
}
+#if 0
+
#ifdef USE_SECURITY_POLKIT
bool PolkitClient::getAuth(const QString &action) {
DBusError e;
@@ -55,10 +53,11 @@ bool PolkitClient::getAuth(const QString &action) {
}
#else
bool PolkitClient::getAuth(const QString &action) {
- qDebug() << "Not configured with PolicyKit support";
+ qDebug() << "Not configured with old PolicyKit support";
return false;
}
#endif
+#endif
#include "polkitclient.moc"
diff --git a/lib/packagekit-qt/src/polkitclient.h b/lib/packagekit-qt/src/polkitclient.h
index 2b8bd91..4788951 100644
--- a/lib/packagekit-qt/src/polkitclient.h
+++ b/lib/packagekit-qt/src/polkitclient.h
@@ -31,7 +31,9 @@ class PolkitClient : QObject{
public:
static PolkitClient* instance();
+#if 0
bool getAuth(const QString& action);
+#endif
private:
static PolkitClient* m_instance;
PolkitClient(QObject *parent = 0);
diff --git a/lib/packagekit-qt/src/transaction.cpp b/lib/packagekit-qt/src/transaction.cpp
index 7948441..9414e84 100644
--- a/lib/packagekit-qt/src/transaction.cpp
+++ b/lib/packagekit-qt/src/transaction.cpp
@@ -102,13 +102,14 @@ bool Transaction::callerActive()
void Transaction::cancel()
{
if (!d->p->Cancel().isValid ()) {
+#if 0
// Cancel failed, maybe it's not our transaction and we need authorization
if(!PolkitClient::instance()->getAuth(AUTH_CANCEL_FOREIGN)) {
// FIXME : should warn somehow here
qDebug () << "Authorization to cancel foreign failed";
return;
}
-
+#endif
d->p->Cancel();
}
}
diff --git a/policy/.gitignore b/policy/.gitignore
index 171e260..c04f1d1 100644
--- a/policy/.gitignore
+++ b/policy/.gitignore
@@ -4,5 +4,5 @@ Makefile
Makefile.in
*.o
*~
-org.freedesktop.packagekit.policy
+*.policy
diff --git a/policy/Makefile.am b/policy/Makefile.am
index 9fcdc91..9f0ab3c 100644
--- a/policy/Makefile.am
+++ b/policy/Makefile.am
@@ -1,7 +1,7 @@
NULL =
-polkit_policydir = $(datadir)/PolicyKit/policy
+polkit_policydir = $(datadir)/polkit-1/actions
dist_polkit_policy_DATA = \
org.freedesktop.packagekit.policy \
$(NULL)
@@ -10,11 +10,6 @@ dist_polkit_policy_DATA = \
# http://bugzilla.gnome.org/show_bug.cgi?id=462312
@INTLTOOL_POLICY_RULE@
-if SECURITY_TYPE_POLKIT
-check:
- $(POLKIT_POLICY_FILE_VALIDATE) $(top_srcdir)/policy/$(dist_polkit_policy_DATA)
-endif
-
EXTRA_DIST = org.freedesktop.packagekit.policy.in
DISTCLEANFILES = org.freedesktop.packagekit.policy
diff --git a/policy/org.freedesktop.packagekit.policy.in b/policy/org.freedesktop.packagekit.policy.in
index b12b8ab..98bf5f3 100644
--- a/policy/org.freedesktop.packagekit.policy.in
+++ b/policy/org.freedesktop.packagekit.policy.in
@@ -6,7 +6,7 @@
<!--
Policy definitions for PackageKit system actions.
- Copyright (c) 2007-2008 Richard Hughes <richard at hughsie.com>
+ Copyright (c) 2007-2009 Richard Hughes <richard at hughsie.com>
-->
<vendor>The PackageKit Project</vendor>
@@ -18,8 +18,9 @@
<_message>Authentication is required to cancel a task that was not started by yourself</_message>
<icon_name>pk-package-delete</icon_name>
<defaults>
+ <allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
- <allow_active>auth_admin_keep_always</allow_active>
+ <allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
@@ -28,8 +29,9 @@
<_message>Authentication is required to install a signed package</_message>
<icon_name>pk-package-add</icon_name>
<defaults>
+ <allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
- <allow_active>auth_admin_keep_always</allow_active>
+ <allow_active>yes</allow_active>
</defaults>
</action>
@@ -38,6 +40,7 @@
<_message>Authentication is required to install an untrusted package</_message>
<icon_name>pk-package-add</icon_name>
<defaults>
+ <allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
@@ -48,6 +51,7 @@
<_message>Authentication is required to consider a key used for signing packages as trusted</_message>
<icon_name>pk-package-add</icon_name>
<defaults>
+ <allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
@@ -58,6 +62,7 @@
<_message>Authentication is required to accept a EULA</_message>
<icon_name>pk-package-add</icon_name>
<defaults>
+ <allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
@@ -68,8 +73,9 @@
<_message>Authentication is required to remove packages</_message>
<icon_name>pk-package-delete</icon_name>
<defaults>
+ <allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
- <allow_active>auth_admin_keep_always</allow_active>
+ <allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
@@ -78,8 +84,9 @@
<_message>Authentication is required to update packages</_message>
<icon_name>pk-package-update</icon_name>
<defaults>
+ <allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
- <allow_active>auth_admin_keep_always</allow_active>
+ <allow_active>yes</allow_active>
</defaults>
</action>
@@ -88,8 +95,9 @@
<_message>Authentication is required to rollback a transaction</_message>
<icon_name>pk-rollback</icon_name>
<defaults>
+ <allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
- <allow_active>auth_admin_keep_always</allow_active>
+ <allow_active>auth_admin</allow_active>
</defaults>
</action>
@@ -98,8 +106,9 @@
<_message>Authentication is required to change software source parameters</_message>
<icon_name>pk-package-info</icon_name>
<defaults>
+ <allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
- <allow_active>auth_admin_keep_always</allow_active>
+ <allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
@@ -108,6 +117,7 @@
<_message>Authentication is required to refresh the system sources</_message>
<icon_name>pk-refresh-cache</icon_name>
<defaults>
+ <allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
@@ -118,6 +128,7 @@
<_message>Authentication is required to set the network proxy used for downloading packages</_message>
<icon_name>applications-internet</icon_name>
<defaults>
+ <allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
diff --git a/src/Makefile.am b/src/Makefile.am
index 5969300..62d1ff4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -56,7 +56,6 @@ shared_SOURCES = \
pk-backend.c \
pk-backend.h \
pk-backend-internal.h \
- pk-security.h \
pk-network.c \
pk-network.h \
pk-shared.c \
@@ -109,14 +108,6 @@ shared_SOURCES += \
pk-network-stack-connman.c
endif
-if SECURITY_TYPE_POLKIT
-shared_SOURCES += pk-security-polkit.c
-endif
-
-if SECURITY_TYPE_DUMMY
-shared_SOURCES += pk-security-dummy.c
-endif
-
sbin_PROGRAMS = \
packagekitd \
$(NULL)
@@ -170,7 +161,7 @@ org.freedesktop.PackageKit.h: org.freedesktop.PackageKit.xml
$(LIBTOOL) --mode=execute dbus-binding-tool \
--prefix=pk_engine \
--mode=glib-server \
- --output=org.freedesktop.PackageKit.h \
+ --output=org.freedesktop.PackageKit.h \
$(srcdir)/org.freedesktop.PackageKit.xml
org.freedesktop.PackageKit.Transaction.h: org.freedesktop.PackageKit.Transaction.xml
@@ -225,8 +216,6 @@ install-data-hook:
EXTRA_DIST = \
pk-marshal.list \
- pk-security-polkit.c \
- pk-security-dummy.c \
org.freedesktop.PackageKit.xml \
org.freedesktop.PackageKit.Transaction.xml \
org.freedesktop.PackageKit.Backend.xml \
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 88c3e4b..0d88e46 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2007-2008 Richard Hughes <richard at hughsie.com>
+ * Copyright (C) 2007-2009 Richard Hughes <richard at hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -38,6 +38,9 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <packagekit-glib/packagekit.h>
+#ifdef USE_SECURITY_POLKIT
+#include <polkit/polkit.h>
+#endif
#include "egg-debug.h"
#include "egg-string.h"
@@ -55,7 +58,6 @@
#include "pk-marshal.h"
#include "pk-notify.h"
#include "pk-file-monitor.h"
-#include "pk-security.h"
#include "pk-conf.h"
static void pk_engine_finalize (GObject *object);
@@ -95,7 +97,6 @@ struct PkEnginePrivate
PkBackend *backend;
PkInhibit *inhibit;
PkNetwork *network;
- PkSecurity *security;
PkNotify *notify;
PkConf *conf;
PkFileMonitor *file_monitor_conf;
@@ -106,6 +107,11 @@ struct PkEnginePrivate
gchar *mime_types;
guint signal_state_priority_timeout;
guint signal_state_normal_timeout;
+#ifdef USE_SECURITY_POLKIT
+ PolkitAuthority *authority;
+#endif
+ gchar *proxy_http;
+ gchar *proxy_ftp;
};
enum {
@@ -577,61 +583,103 @@ pk_engine_suggest_daemon_quit (PkEngine *engine, GError **error)
return TRUE;
}
+#ifdef USE_SECURITY_POLKIT
/**
- * pk_engine_set_proxy:
+ * pk_engine_action_obtain_authorization:
**/
-void
-pk_engine_set_proxy (PkEngine *engine, const gchar *proxy_http, const gchar *proxy_ftp, DBusGMethodInvocation *context)
+static void
+pk_engine_action_obtain_authorization_finished_cb (GObject *source_object, GAsyncResult *res, PkEngine *engine)
{
+ PolkitAuthorizationResult *result;
+ GError *error = NULL;
gboolean ret;
- GError *error;
- gchar *sender = NULL;
- gchar *error_detail = NULL;
- PkSecurityCaller *caller;
-
- g_return_if_fail (PK_IS_ENGINE (engine));
- egg_debug ("SetProxy method called: %s, %s", proxy_http, proxy_ftp);
+ /* finish the call */
+ result = polkit_authority_check_authorization_finish (engine->priv->authority, res, &error);
- /* check if the action is allowed from this client - if not, set an error */
- sender = dbus_g_method_get_sender (context);
+ /* failed */
+ if (result == NULL) {
+ egg_warning ("failed to check for auth: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
- /* get caller */
- caller = pk_security_caller_new_from_sender (engine->priv->security, sender);
- if (caller == NULL) {
- error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_REFUSED_BY_POLICY,
- "caller %s not found", sender);
- dbus_g_method_return_error (context, error);
+ /* did not auth */
+ if (!polkit_authorization_result_get_is_authorized (result)) {
+ egg_warning ("failed to obtain auth");
goto out;
}
- /* use security model to get auth */
- ret = pk_security_action_is_allowed (engine->priv->security, caller, FALSE, PK_ROLE_ENUM_SET_PROXY_PRIVATE, &error_detail);
+ /* try to set the new proxy */
+ ret = pk_backend_set_proxy (engine->priv->backend, engine->priv->proxy_http, engine->priv->proxy_ftp);
if (!ret) {
- error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_REFUSED_BY_POLICY, "%s", error_detail);
- dbus_g_method_return_error (context, error);
+ egg_warning ("setting the proxy failed");
goto out;
}
+out:
+ if (result != NULL)
+ g_object_unref (result);
+ return;
+}
+#endif
+
+/**
+ * pk_engine_set_proxy:
+ **/
+void
+pk_engine_set_proxy (PkEngine *engine, const gchar *proxy_http, const gchar *proxy_ftp, DBusGMethodInvocation *context)
+{
+#ifdef USE_SECURITY_POLKIT
+ gchar *sender = NULL;
+ PolkitSubject *subject;
+#else
+ gboolean ret;
+ GError *error = NULL;
+#endif
+ g_return_if_fail (PK_IS_ENGINE (engine));
+
+ egg_debug ("SetProxy method called: %s, %s", proxy_http, proxy_ftp);
+
+ /* save these so we can set them after the auth success */
+ egg_debug ("potentially changing http proxy from %s to %s", engine->priv->proxy_http, proxy_http);
+ egg_debug ("potentially changing ftp proxy from %s to %s", engine->priv->proxy_ftp, proxy_ftp);
+ g_free (engine->priv->proxy_http);
+ g_free (engine->priv->proxy_ftp);
+ engine->priv->proxy_http = g_strdup (proxy_http);
+ engine->priv->proxy_ftp = g_strdup (proxy_ftp);
+
+#ifdef USE_SECURITY_POLKIT
+ /* check subject */
+ sender = dbus_g_method_get_sender (context);
+ subject = polkit_system_bus_name_new (sender);
+ polkit_authority_check_authorization (engine->priv->authority, subject,
+ "org.freedesktop.packagekit.system-network-proxy-configure",
+ NULL,
+ POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
+ NULL,
+ (GAsyncReadyCallback) pk_engine_action_obtain_authorization_finished_cb,
+ engine);
+#else
+ egg_warning ("*** THERE IS NO SECURITY MODEL BEING USED!!! ***");
/* try to set the new proxy */
ret = pk_backend_set_proxy (engine->priv->backend, proxy_http, proxy_ftp);
if (!ret) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_CANNOT_SET_PROXY, "%s", "setting the proxy failed");
dbus_g_method_return_error (context, error);
- goto out;
+ return;
}
-
+#endif
/* all okay */
dbus_g_method_return (context);
/* reset the timer */
pk_engine_reset_timer (engine);
-out:
- if (caller != NULL)
- pk_security_caller_unref (caller);
+#ifdef USE_SECURITY_POLKIT
+ g_object_unref (subject);
g_free (sender);
- g_free (error_detail);
+#endif
}
/**
@@ -793,8 +841,6 @@ pk_engine_init (PkEngine *engine)
DBusGConnection *connection;
gboolean ret;
gchar *filename;
- gchar *proxy_http;
- gchar *proxy_ftp;
engine->priv = PK_ENGINE_GET_PRIVATE (engine);
engine->priv->notify_clients_of_upgrade = FALSE;
@@ -820,9 +866,6 @@ pk_engine_init (PkEngine *engine)
if (!ret)
egg_error ("could not lock backend, you need to restart the daemon");
- /* we dont need this, just don't keep creating and destroying it */
- engine->priv->security = pk_security_new ();
-
/* proxy the network state */
engine->priv->network = pk_network_new ();
g_signal_connect (engine->priv->network, "state-changed",
@@ -863,18 +906,21 @@ pk_engine_init (PkEngine *engine)
G_CALLBACK (pk_engine_conf_file_changed_cb), engine);
g_free (filename);
+#ifdef USE_SECURITY_POLKIT
+ /* protect the session SetProxy with a PolicyKit action */
+ engine->priv->authority = polkit_authority_get ();
+#endif
+
/* monitor the binary file for changes */
engine->priv->file_monitor_binary = pk_file_monitor_new ();
pk_file_monitor_set_file (engine->priv->file_monitor_binary, SBINDIR "/packagekitd");
g_signal_connect (engine->priv->file_monitor_binary, "file-changed",
G_CALLBACK (pk_engine_binary_file_changed_cb), engine);
- /* set the proxy */
- proxy_http = pk_conf_get_string (engine->priv->conf, "ProxyHTTP");
- proxy_ftp = pk_conf_get_string (engine->priv->conf, "ProxyFTP");
- pk_backend_set_proxy (engine->priv->backend, proxy_http, proxy_ftp);
- g_free (proxy_http);
- g_free (proxy_ftp);
+ /* set the default proxy */
+ engine->priv->proxy_http = pk_conf_get_string (engine->priv->conf, "ProxyHTTP");
+ engine->priv->proxy_ftp = pk_conf_get_string (engine->priv->conf, "ProxyFTP");
+ pk_backend_set_proxy (engine->priv->backend, engine->priv->proxy_http, engine->priv->proxy_ftp);
engine->priv->transaction_list = pk_transaction_list_new ();
g_signal_connect (engine->priv->transaction_list, "changed",
@@ -928,12 +974,16 @@ pk_engine_finalize (GObject *object)
g_object_unref (engine->priv->transaction_list);
g_object_unref (engine->priv->transaction_db);
g_object_unref (engine->priv->network);
- g_object_unref (engine->priv->security);
+#ifdef USE_SECURITY_POLKIT
+ g_object_unref (engine->priv->authority);
+#endif
g_object_unref (engine->priv->notify);
g_object_unref (engine->priv->backend);
g_object_unref (engine->priv->cache);
g_object_unref (engine->priv->conf);
g_free (engine->priv->mime_types);
+ g_free (engine->priv->proxy_http);
+ g_free (engine->priv->proxy_ftp);
G_OBJECT_CLASS (pk_engine_parent_class)->finalize (object);
}
diff --git a/src/pk-post-trans.c b/src/pk-post-trans.c
index 199d258..4575c53 100644
--- a/src/pk-post-trans.c
+++ b/src/pk-post-trans.c
@@ -32,11 +32,6 @@
#include <gio/gdesktopappinfo.h>
#include <sqlite3.h>
-#ifdef USE_SECURITY_POLKIT
- #include <polkit/polkit.h>
- #include <polkit-dbus/polkit-dbus.h>
-#endif
-
#include "egg-debug.h"
#include "pk-post-trans.h"
@@ -542,6 +537,32 @@ pk_post_trans_update_files_check_running_cb (PkBackend *backend, const gchar *pa
pk_package_id_free (id);
}
+#ifdef USE_SECURITY_POLKIT
+/**
+ * dkp_post_trans_get_cmdline:
+ **/
+static gchar *
+dkp_post_trans_get_cmdline (guint pid)
+{
+ gboolean ret;
+ gchar *filename = NULL;
+ gchar *cmdline = NULL;
+ GError *error = NULL;
+
+ /* get command line from proc */
+ filename = g_strdup_printf ("/proc/%i/cmdline", pid);
+ ret = g_file_get_contents (filename, &cmdline, NULL, &error);
+ if (!ret) {
+ egg_debug ("failed to get cmdline: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+out:
+ g_free (filename);
+ return cmdline;
+}
+#endif
+
/**
* pk_post_trans_update_process_list:
**/
@@ -556,8 +577,7 @@ pk_post_trans_update_process_list (PkPostTrans *post)
gboolean ret;
guint uid;
pid_t pid;
- gint retval;
- gchar exec[128];
+ gchar *exec;
uid = getuid ();
dir = g_dir_open ("/proc", 0, NULL);
@@ -582,12 +602,12 @@ pk_post_trans_update_process_list (PkPostTrans *post)
/* get the exec for the pid */
pid = atoi (name);
#ifdef USE_SECURITY_POLKIT
- retval = polkit_sysdeps_get_exe_for_pid (pid, exec, 128);
+ exec = dkp_post_trans_get_cmdline (pid);
+ if (exec == NULL)
+ goto out;
#else
- retval = -1;
+ goto out;
#endif
- if (retval <= 0)
- goto out;
/* can be /usr/libexec/notification-daemon.#prelink#.9sOhao */
offset = g_strrstr (exec, ".#prelink#.");
diff --git a/src/pk-security-dummy.c b/src/pk-security-dummy.c
deleted file mode 100644
index 3e3713a..0000000
--- a/src/pk-security-dummy.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-
-#include <glib/gi18n.h>
-#include <glib.h>
-#include <packagekit-glib/packagekit.h>
-
-#include <config.h>
-
-#include "egg-debug.h"
-#include "pk-security.h"
-
-#define PK_SECURITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_SECURITY, PkSecurityPrivate))
-
-struct PkSecurityPrivate
-{
- gpointer data;
-};
-
-typedef gpointer PkSecurityCaller_;
-
-G_DEFINE_TYPE (PkSecurity, pk_security, G_TYPE_OBJECT)
-
-/**
- * pk_security_caller_new_from_sender:
- **/
-PkSecurityCaller *
-pk_security_caller_new_from_sender (PkSecurity *security, const gchar *sender)
-{
- g_return_val_if_fail (PK_IS_SECURITY (security), NULL);
- return GUINT_TO_POINTER (1);
-}
-
-/**
- * pk_security_caller_unref:
- **/
-void
-pk_security_caller_unref (PkSecurityCaller *caller)
-{
- return;
-}
-
-/**
- * pk_security_get_uid:
- **/
-guint
-pk_security_get_uid (PkSecurity *security, PkSecurityCaller *caller)
-{
- g_return_val_if_fail (PK_IS_SECURITY (security), -1);
- return -1;
-}
-
-/**
- * pk_security_get_cmdline:
- **/
-gchar *
-pk_security_get_cmdline (PkSecurity *security, PkSecurityCaller *caller)
-{
- g_return_val_if_fail (PK_IS_SECURITY (security), NULL);
- return NULL;
-}
-
-/**
- * pk_security_action_is_allowed:
- **/
-gboolean
-pk_security_action_is_allowed (PkSecurity *security, PkSecurityCaller *caller, gboolean trusted, PkRoleEnum role, gchar **error_detail)
-{
- g_return_val_if_fail (PK_IS_SECURITY (security), FALSE);
- return TRUE;
-}
-
-/**
- * pk_security_finalize:
- **/
-static void
-pk_security_finalize (GObject *object)
-{
- PkSecurity *security;
- g_return_if_fail (PK_IS_SECURITY (object));
- security = PK_SECURITY (object);
- G_OBJECT_CLASS (pk_security_parent_class)->finalize (object);
-}
-
-/**
- * pk_security_class_init:
- **/
-static void
-pk_security_class_init (PkSecurityClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = pk_security_finalize;
- g_type_class_add_private (klass, sizeof (PkSecurityPrivate));
-}
-
-/**
- * pk_security_init:
- *
- * initializes the security class. NOTE: We expect security objects
- * to *NOT* be removed or added during the session.
- * We only control the first security object if there are more than one.
- **/
-static void
-pk_security_init (PkSecurity *security)
-{
- egg_debug ("Using dummy security framework");
- egg_warning ("*** THERE IS NO SECURITY MODEL BEING USED!!! ***");
-}
-
-/**
- * pk_security_new:
- * Return value: A new security class instance.
- **/
-PkSecurity *
-pk_security_new (void)
-{
- PkSecurity *security;
- security = g_object_new (PK_TYPE_SECURITY, NULL);
- return PK_SECURITY (security);
-}
-
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-pk_security_test (EggTest *test)
-{
- return;
-}
-#endif
-
diff --git a/src/pk-security-polkit.c b/src/pk-security-polkit.c
deleted file mode 100644
index 2cac522..0000000
--- a/src/pk-security-polkit.c
+++ /dev/null
@@ -1,424 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007-2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-
-#include <glib/gi18n.h>
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-
-#include <polkit/polkit.h>
-#include <polkit-dbus/polkit-dbus.h>
-#include <packagekit-glib/packagekit.h>
-
-#include "egg-debug.h"
-#include "egg-string.h"
-
-#include "pk-security.h"
-#include "pk-syslog.h"
-
-#define PK_SECURITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_SECURITY, PkSecurityPrivate))
-
-struct PkSecurityPrivate
-{
- PolKitContext *pk_context;
- DBusConnection *connection;
- PkSyslog *syslog;
-};
-
-typedef PolKitCaller PkSecurityCaller_;
-
-G_DEFINE_TYPE (PkSecurity, pk_security, G_TYPE_OBJECT)
-static gpointer pk_security_object = NULL;
-
-/**
- * pk_security_caller_new_from_sender:
- **/
-PkSecurityCaller *
-pk_security_caller_new_from_sender (PkSecurity *security, const gchar *sender)
-{
- PolKitCaller *caller;
- DBusError dbus_error;
-
- g_return_val_if_fail (PK_IS_SECURITY (security), NULL);
- g_return_val_if_fail (sender != NULL, NULL);
-
- /* get the PolKitCaller information */
- dbus_error_init (&dbus_error);
- caller = polkit_caller_new_from_dbus_name (security->priv->connection, sender, &dbus_error);
- if (dbus_error_is_set (&dbus_error)) {
- egg_debug ("failed to get caller %s: %s", dbus_error.name, dbus_error.message);
- dbus_error_free (&dbus_error);
- }
-
- return (PkSecurityCaller*) caller;
-}
-
-/**
- * pk_security_caller_unref:
- **/
-void
-pk_security_caller_unref (PkSecurityCaller *caller)
-{
- if (caller != NULL)
- polkit_caller_unref ((PolKitCaller *) caller);
-}
-
-/**
- * pk_security_get_uid:
- **/
-guint
-pk_security_get_uid (PkSecurity *security, PkSecurityCaller *caller)
-{
- polkit_bool_t retval;
- guint uid;
-
- g_return_val_if_fail (PK_IS_SECURITY (security), -1);
- g_return_val_if_fail (caller != NULL, -1);
-
- /* get uid */
- retval = polkit_caller_get_uid ((PolKitCaller *) caller, &uid);
- if (!retval) {
- egg_warning ("failed to get UID");
- uid = PK_SECURITY_UID_INVALID;
- }
-
- return uid;
-}
-
-/**
- * pk_security_get_cmdline:
- **/
-gchar *
-pk_security_get_cmdline (PkSecurity *security, PkSecurityCaller *caller)
-{
- gboolean ret;
- gchar *filename = NULL;
- gchar *cmdline = NULL;
- GError *error = NULL;
- polkit_bool_t retval;
- pid_t pid;
-
- g_return_val_if_fail (PK_IS_SECURITY (security), NULL);
- g_return_val_if_fail (caller != NULL, NULL);
-
- /* get pid */
- retval = polkit_caller_get_pid ((PolKitCaller *) caller, &pid);
- if (!retval) {
- egg_warning ("failed to get PID");
- goto out;
- }
-
- /* get command line from proc */
- filename = g_strdup_printf ("/proc/%i/cmdline", pid);
- ret = g_file_get_contents (filename, &cmdline, NULL, &error);
- if (!ret) {
- egg_warning ("failed to get cmdline: %s", error->message);
- g_error_free (error);
- }
-out:
- g_free (filename);
- return cmdline;
-}
-
-/**
- * pk_security_role_to_action:
- **/
-static const gchar *
-pk_security_role_to_action (PkSecurity *security, gboolean trusted, PkRoleEnum role)
-{
- const gchar *policy = NULL;
-
- g_return_val_if_fail (PK_IS_SECURITY (security), NULL);
-
- if (role == PK_ROLE_ENUM_UPDATE_PACKAGES ||
- role == PK_ROLE_ENUM_UPDATE_SYSTEM) {
- policy = "org.freedesktop.packagekit.system-update";
- } else if (role == PK_ROLE_ENUM_INSTALL_SIGNATURE) {
- policy = "org.freedesktop.packagekit.system-trust-signing-key";
- } else if (role == PK_ROLE_ENUM_ROLLBACK) {
- policy = "org.freedesktop.packagekit.system-rollback";
- } else if (role == PK_ROLE_ENUM_REPO_ENABLE ||
- role == PK_ROLE_ENUM_REPO_SET_DATA) {
- policy = "org.freedesktop.packagekit.system-sources-configure";
- } else if (role == PK_ROLE_ENUM_REFRESH_CACHE) {
- policy = "org.freedesktop.packagekit.system-sources-refresh";
- } else if (role == PK_ROLE_ENUM_SET_PROXY_PRIVATE) {
- policy = "org.freedesktop.packagekit.system-network-proxy-configure";
- } else if (role == PK_ROLE_ENUM_REMOVE_PACKAGES) {
- policy = "org.freedesktop.packagekit.package-remove";
- } else if (role == PK_ROLE_ENUM_INSTALL_PACKAGES) {
- policy = "org.freedesktop.packagekit.package-install";
- } else if (role == PK_ROLE_ENUM_INSTALL_FILES && trusted) {
- policy = "org.freedesktop.packagekit.package-install";
- } else if (role == PK_ROLE_ENUM_INSTALL_FILES && !trusted) {
- 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;
-}
-
-/**
- * pk_security_action_is_allowed:
- **/
-gboolean
-pk_security_action_is_allowed (PkSecurity *security, PkSecurityCaller *caller, gboolean trusted, PkRoleEnum role, gchar **error_detail)
-{
- gboolean ret = FALSE;
- PolKitResult result;
- const gchar *policy;
- PolKitAction *action;
- guint uid;
- gchar *cmdline;
-
- g_return_val_if_fail (PK_IS_SECURITY (security), FALSE);
- g_return_val_if_fail (caller != NULL, FALSE);
-
- /* map the roles to policykit rules */
- policy = pk_security_role_to_action (security, trusted, role);
- if (policy == NULL) {
- egg_warning ("policykit type required for '%s'", pk_role_enum_to_text (role));
- return FALSE;
- }
-
- /* set action */
- action = polkit_action_new ();
- if (action == NULL) {
- egg_warning ("error: polkit_action_new failed");
- goto out;
- }
- polkit_action_set_action_id (action, policy);
-
- /* set caller */
- result = polkit_context_is_caller_authorized (security->priv->pk_context, action, (PolKitCaller *) caller, TRUE, NULL);
- egg_debug ("PolicyKit result = '%s'", polkit_result_to_string_representation (result));
- if (result != POLKIT_RESULT_YES) {
- if (error_detail != NULL)
- *error_detail = g_strdup_printf ("%s %s", policy, polkit_result_to_string_representation (result));
- goto out;
- }
-
- /* yippee */
- ret = TRUE;
-
-out:
- /* log result */
- uid = pk_security_get_uid (security, caller);
- cmdline = pk_security_get_cmdline (security, caller);
- if (ret)
- pk_syslog_add (security->priv->syslog, PK_SYSLOG_TYPE_AUTH, "uid %i obtained %s auth (trusted:%i)", uid, policy, trusted);
- else
- pk_syslog_add (security->priv->syslog, PK_SYSLOG_TYPE_AUTH, "uid %i failed to obtain %s auth (trusted:%i)", uid, policy, trusted);
- g_free (cmdline);
-
- if (action != NULL)
- polkit_action_unref (action);
- return ret;
-}
-
-/**
- * pk_security_finalize:
- **/
-static void
-pk_security_finalize (GObject *object)
-{
- PkSecurity *security;
- g_return_if_fail (PK_IS_SECURITY (object));
- security = PK_SECURITY (object);
-
- /* unref PolicyKit */
- polkit_context_unref (security->priv->pk_context);
- g_object_unref (security->priv->syslog);
-
- G_OBJECT_CLASS (pk_security_parent_class)->finalize (object);
-}
-
-/**
- * pk_security_class_init:
- **/
-static void
-pk_security_class_init (PkSecurityClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = pk_security_finalize;
- g_type_class_add_private (klass, sizeof (PkSecurityPrivate));
-}
-
-/**
- * pk_security_io_watch_have_data:
- **/
-static gboolean
-pk_security_io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_data)
-{
- int fd;
- PolKitContext *pk_context = user_data;
- fd = g_io_channel_unix_get_fd (channel);
- polkit_context_io_func (pk_context, fd);
- return TRUE;
-}
-
-/**
- * pk_security_io_add_watch:
- **/
-static int
-pk_security_io_add_watch (PolKitContext *pk_context, int fd)
-{
- guint id = 0;
- GIOChannel *channel;
- channel = g_io_channel_unix_new (fd);
- if (channel == NULL)
- return id;
- id = g_io_add_watch (channel, G_IO_IN, pk_security_io_watch_have_data, pk_context);
- if (id == 0) {
- g_io_channel_unref (channel);
- return id;
- }
- g_io_channel_unref (channel);
- return id;
-}
-
-/**
- * pk_security_io_remove_watch:
- **/
-static void
-pk_security_io_remove_watch (PolKitContext *pk_context, int watch_id)
-{
- g_source_remove (watch_id);
-}
-
-/**
- * pk_security_init:
- *
- * initializes the security class. NOTE: We expect security objects
- * to *NOT* be removed or added during the session.
- * We only control the first security object if there are more than one.
- **/
-static void
-pk_security_init (PkSecurity *security)
-{
- PolKitError *pk_error;
- polkit_bool_t retval;
- DBusError dbus_error;
-
- security->priv = PK_SECURITY_GET_PRIVATE (security);
-
- egg_debug ("Using PolicyKit security framework");
-
- /* use syslog */
- security->priv->syslog = pk_syslog_new ();
-
- /* get a connection to the bus */
- dbus_error_init (&dbus_error);
- security->priv->connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);
- if (security->priv->connection == NULL) {
- if (dbus_error_is_set (&dbus_error)) {
- egg_warning ("failed to get system connection %s: %s\n", dbus_error.name, dbus_error.message);
- dbus_error_free (&dbus_error);
- }
- }
-
- /* get PolicyKit context */
- security->priv->pk_context = polkit_context_new ();
-
- /* watch for changes */
- polkit_context_set_io_watch_functions (security->priv->pk_context,
- pk_security_io_add_watch,
- pk_security_io_remove_watch);
-
- pk_error = NULL;
- retval = polkit_context_init (security->priv->pk_context, &pk_error);
- if (retval == FALSE) {
- egg_warning ("Could not init PolicyKit context: %s", polkit_error_get_error_message (pk_error));
- polkit_error_free (pk_error);
- }
-}
-
-/**
- * pk_security_new:
- * Return value: A new security class instance.
- **/
-PkSecurity *
-pk_security_new (void)
-{
- if (pk_security_object != NULL) {
- g_object_ref (pk_security_object);
- } else {
- pk_security_object = g_object_new (PK_TYPE_SECURITY, NULL);
- g_object_add_weak_pointer (pk_security_object, &pk_security_object);
- }
- return PK_SECURITY (pk_security_object);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-pk_security_test (EggTest *test)
-{
- PkSecurity *security;
- const gchar *action;
-
- if (!egg_test_start (test, "PkSecurity"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get an instance");
- security = pk_security_new ();
- egg_test_assert (test, security != NULL);
- egg_test_title_assert (test, "check connection", security->priv->connection != NULL);
- egg_test_title_assert (test, "check PolKit context", security->priv->pk_context != NULL);
-
- /************************************************************/
- egg_test_title (test, "map valid role to action");
- action = pk_security_role_to_action (security, FALSE, PK_ROLE_ENUM_UPDATE_PACKAGES);
- if (egg_strequal (action, "org.freedesktop.packagekit.system-update"))
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "did not get correct action '%s'", action);
-
- /************************************************************/
- egg_test_title (test, "map invalid role to action");
- action = pk_security_role_to_action (security, FALSE, PK_ROLE_ENUM_SEARCH_NAME);
- if (action == NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "did not get correct action '%s'", action);
-
- g_object_unref (security);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/pk-security.h b/src/pk-security.h
deleted file mode 100644
index a90d9f4..0000000
--- a/src/pk-security.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __PK_SECURITY_H
-#define __PK_SECURITY_H
-
-#include <glib-object.h>
-#include <packagekit-glib/packagekit.h>
-
-G_BEGIN_DECLS
-
-#define PK_TYPE_SECURITY (pk_security_get_type ())
-#define PK_SECURITY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_SECURITY, PkSecurity))
-#define PK_SECURITY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_SECURITY, PkSecurityClass))
-#define PK_IS_SECURITY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_SECURITY))
-#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 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
-
-typedef struct PkSecurityPrivate PkSecurityPrivate;
-
-typedef struct
-{
- GObject parent;
- PkSecurityPrivate *priv;
-} PkSecurity;
-
-typedef struct
-{
- GObjectClass parent_class;
-} PkSecurityClass;
-
-typedef struct PkSecurityCaller_ PkSecurityCaller;
-
-GType pk_security_get_type (void);
-PkSecurity *pk_security_new (void);
-
-PkSecurityCaller *pk_security_caller_new_from_sender (PkSecurity *security,
- const gchar *sender);
-void pk_security_caller_unref (PkSecurityCaller *caller);
-guint pk_security_get_uid (PkSecurity *security,
- PkSecurityCaller *caller);
-gchar *pk_security_get_cmdline (PkSecurity *security,
- PkSecurityCaller *caller);
-gboolean pk_security_action_is_allowed (PkSecurity *security,
- PkSecurityCaller *caller,
- gboolean trusted,
- PkRoleEnum role,
- gchar **error_detail)
- G_GNUC_WARN_UNUSED_RESULT;
-
-G_END_DECLS
-
-#endif /* __PK_SECURITY_H */
diff --git a/src/pk-self-test.c b/src/pk-self-test.c
index e8370d9..ccaf919 100644
--- a/src/pk-self-test.c
+++ b/src/pk-self-test.c
@@ -32,7 +32,6 @@ void pk_inhibit_test (EggTest *test);
void pk_spawn_test (EggTest *test);
void pk_transaction_list_test (EggTest *test);
void pk_transaction_db_test (EggTest *test);
-void pk_security_test (EggTest *test);
void pk_time_test (EggTest *test);
void pk_backend_test (EggTest *test);
void pk_backend_test_spawn (EggTest *test);
@@ -55,7 +54,6 @@ main (int argc, char **argv)
/* components */
pk_file_monitor_test (test);
- pk_security_test (test);
pk_time_test (test);
pk_conf_test (test);
pk_store_test (test);
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 95edc0d..1be4264 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -570,10 +570,6 @@ pk_transaction_list_get_state (PkTransactionList *tlist)
if (wrong != 0)
g_string_append_printf (string, "ERROR: %i have inconsistent flags\n", wrong);
- /* some are not committed */
- if (no_commit != 0)
- g_string_append_printf (string, "WARNING: %i have not been committed\n", no_commit);
-
/* more than one running */
if (running > 1)
g_string_append_printf (string, "ERROR: %i are running\n", running);
@@ -649,7 +645,7 @@ pk_transaction_list_is_consistent (PkTransactionList *tlist)
/* some are not committed */
if (no_commit != 0)
- egg_debug ("%i have not been committed", no_commit);
+ egg_debug ("%i have not been committed and may be pending auth", no_commit);
/* more than one running */
if (running > 1) {
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 255cb7d..0897694 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -42,6 +42,9 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <gio/gio.h>
#include <packagekit-glib/packagekit.h>
+#ifdef USE_SECURITY_POLKIT
+#include <polkit/polkit.h>
+#endif
#include "egg-debug.h"
#include "egg-string.h"
@@ -58,7 +61,6 @@
#include "pk-shared.h"
#include "pk-cache.h"
#include "pk-notify.h"
-#include "pk-security.h"
#include "pk-post-trans.h"
#include "pk-syslog.h"
@@ -68,6 +70,9 @@ static void pk_transaction_dispose (GObject *object);
#define PK_TRANSACTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_TRANSACTION, PkTransactionPrivate))
#define PK_TRANSACTION_UPDATES_CHANGED_TIMEOUT 100 /* ms */
+/* when the UID is invalid or not known */
+#define PK_TRANSACTION_UID_INVALID G_MAXUINT
+
static void pk_transaction_status_changed_cb (PkBackend *backend, PkStatusEnum status, PkTransaction *transaction);
static void pk_transaction_progress_changed_cb (PkBackend *backend, guint percentage, guint subpercentage, guint elapsed, guint remaining, PkTransaction *transaction);
@@ -83,6 +88,7 @@ struct PkTransactionPrivate
gboolean running;
gboolean has_been_run;
gboolean allow_cancel;
+ gboolean waiting_for_auth;
gboolean emit_eula_required;
gboolean emit_signature_required;
gboolean emit_media_change_required;
@@ -94,8 +100,13 @@ struct PkTransactionPrivate
PkCache *cache;
PkConf *conf;
PkNotify *notify;
- PkSecurity *security;
- PkSecurityCaller *caller;
+#ifdef USE_SECURITY_POLKIT
+ PolkitAuthority *authority;
+ PolkitSubject *subject;
+ GCancellable *cancellable;
+#endif
+ DBusGConnection *connection;
+ DBusGProxy *proxy_pid;
PkPostTrans *post_trans;
PkSyslog *syslog;
@@ -410,6 +421,18 @@ pk_transaction_finished_emit (PkTransaction *transaction, PkExitEnum exit_enum,
}
/**
+ * pk_transaction_error_code_emit:
+ **/
+static void
+pk_transaction_error_code_emit (PkTransaction *transaction, PkErrorCodeEnum error_enum, const gchar *details)
+{
+ const gchar *text;
+ text = pk_error_enum_to_text (error_enum);
+ egg_debug ("emitting error-code %s, '%s'", text, details);
+ g_signal_emit (transaction, signals [PK_TRANSACTION_ERROR_CODE], 0, text, details);
+}
+
+/**
* pk_transaction_allow_cancel_cb:
**/
static void
@@ -462,8 +485,6 @@ static void
pk_transaction_error_code_cb (PkBackend *backend, PkErrorCodeEnum code,
const gchar *details, PkTransaction *transaction)
{
- const gchar *code_text;
-
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
@@ -473,9 +494,7 @@ pk_transaction_error_code_cb (PkBackend *backend, PkErrorCodeEnum code,
"- this is a backend problem and should be fixed!", pk_role_enum_to_text (transaction->priv->role));
}
- code_text = pk_error_enum_to_text (code);
- egg_debug ("emitting error-code %s, '%s'", code_text, details);
- g_signal_emit (transaction, signals [PK_TRANSACTION_ERROR_CODE], 0, code_text, details);
+ pk_transaction_error_code_emit (transaction, code, details);
}
/**
@@ -727,7 +746,7 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit_enum, PkTransact
pk_inhibit_remove (transaction->priv->inhibit, transaction);
/* report to syslog */
- if (transaction->priv->uid != PK_SECURITY_UID_INVALID)
+ if (transaction->priv->uid != PK_TRANSACTION_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,
transaction->priv->uid, pk_exit_enum_to_text (exit_enum), time_ms);
@@ -1235,6 +1254,31 @@ pk_transaction_set_tid (PkTransaction *transaction, const gchar *tid)
}
/**
+ * pk_transaction_get_uid:
+ **/
+static guint
+pk_transaction_get_uid (PkTransaction *transaction, const gchar *sender)
+{
+ guint uid;
+ DBusError error;
+ DBusConnection *con;
+
+ g_return_val_if_fail (PK_IS_TRANSACTION (transaction), G_MAXUINT);
+ g_return_val_if_fail (sender != NULL, G_MAXUINT);
+
+ dbus_error_init (&error);
+ con = dbus_g_connection_get_connection (transaction->priv->connection);
+ uid = dbus_bus_get_unix_user (con, sender, &error);
+ if (dbus_error_is_set (&error)) {
+ egg_warning ("Could not get uid for connection: %s %s", error.name, error.message);
+ uid = G_MAXUINT;
+ goto out;
+ }
+out:
+ return uid;
+}
+
+/**
* pk_transaction_set_sender:
*/
gboolean
@@ -1249,9 +1293,10 @@ pk_transaction_set_sender (PkTransaction *transaction, const gchar *sender)
egg_dbus_monitor_assign (transaction->priv->monitor, EGG_DBUS_MONITOR_SYSTEM, sender);
/* we get the UID for all callers as we need to know when to cancel */
- transaction->priv->caller = pk_security_caller_new_from_sender (transaction->priv->security, sender);
- if (transaction->priv->caller != NULL)
- transaction->priv->uid = pk_security_get_uid (transaction->priv->security, transaction->priv->caller);
+#ifdef USE_SECURITY_POLKIT
+ transaction->priv->subject = polkit_system_bus_name_new (sender);
+#endif
+ transaction->priv->uid = pk_transaction_get_uid (transaction, sender);
return TRUE;
}
@@ -1270,6 +1315,77 @@ pk_transaction_release_tid (PkTransaction *transaction)
return ret;
}
+#ifdef USE_SECURITY_POLKIT
+/**
+ * pk_transaction_get_pid:
+ **/
+static guint
+pk_transaction_get_pid (PkTransaction *transaction, PolkitSubject *subject)
+{
+ guint pid;
+ gboolean ret;
+ gchar *sender = NULL;
+ GError *error = NULL;
+
+ g_return_val_if_fail (PK_IS_TRANSACTION (transaction), G_MAXUINT);
+ g_return_val_if_fail (transaction->priv->proxy_pid != NULL, G_MAXUINT);
+ g_return_val_if_fail (subject != NULL, G_MAXUINT);
+
+ /* this comes back as 'system-bus-name::1.127' */
+ sender = polkit_subject_to_string (subject);
+
+ /* get pid from DBus (quite slow) */
+ ret = dbus_g_proxy_call (transaction->priv->proxy_pid, "GetConnectionUnixProcessID", &error,
+ G_TYPE_STRING, sender+16,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &pid,
+ G_TYPE_INVALID);
+ if (!ret) {
+ egg_error ("failed to get pid: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+out:
+ g_free (sender);
+ return pid;
+}
+
+
+/**
+ * pk_transaction_get_cmdline:
+ **/
+static gchar *
+pk_transaction_get_cmdline (PkTransaction *transaction, PolkitSubject *subject)
+{
+ gboolean ret;
+ gchar *filename = NULL;
+ gchar *cmdline = NULL;
+ GError *error = NULL;
+ guint pid;
+
+ g_return_val_if_fail (PK_IS_TRANSACTION (transaction), NULL);
+ g_return_val_if_fail (subject != NULL, NULL);
+
+ /* get pid */
+ pid = pk_transaction_get_pid (transaction, subject);
+ if (pid == G_MAXUINT) {
+ egg_warning ("failed to get PID");
+ goto out;
+ }
+
+ /* get command line from proc */
+ filename = g_strdup_printf ("/proc/%i/cmdline", pid);
+ ret = g_file_get_contents (filename, &cmdline, NULL, &error);
+ if (!ret) {
+ egg_warning ("failed to get cmdline: %s", error->message);
+ g_error_free (error);
+ }
+out:
+ g_free (filename);
+ return cmdline;
+}
+#endif
+
/**
* pk_transaction_commit:
**/
@@ -1277,7 +1393,9 @@ G_GNUC_WARN_UNUSED_RESULT static gboolean
pk_transaction_commit (PkTransaction *transaction)
{
gboolean ret;
+#ifdef USE_SECURITY_POLKIT
gchar *cmdline;
+#endif
g_return_val_if_fail (PK_IS_TRANSACTION (transaction), FALSE);
g_return_val_if_fail (transaction->priv->tid != NULL, FALSE);
@@ -1306,15 +1424,16 @@ pk_transaction_commit (PkTransaction *transaction)
/* save uid */
pk_transaction_db_set_uid (transaction->priv->transaction_db, transaction->priv->tid, transaction->priv->uid);
+#ifdef USE_SECURITY_POLKIT
/* save cmdline */
- cmdline = pk_security_get_cmdline (transaction->priv->security, transaction->priv->caller);
+ cmdline = pk_transaction_get_cmdline (transaction, transaction->priv->subject);
pk_transaction_db_set_cmdline (transaction->priv->transaction_db, transaction->priv->tid, cmdline);
+ g_free (cmdline);
+#endif
/* 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, transaction->priv->uid);
-
- g_free (cmdline);
}
return TRUE;
}
@@ -1425,35 +1544,163 @@ out:
return ret;
}
+#ifdef USE_SECURITY_POLKIT
+/**
+ * pk_transaction_action_obtain_authorization:
+ **/
+static void
+pk_transaction_action_obtain_authorization_finished_cb (GObject *source_object, GAsyncResult *res, PkTransaction *transaction)
+{
+ PolkitAuthorizationResult *result;
+ gboolean ret;
+ GError *error = NULL;
+
+ /* finish the call */
+ result = polkit_authority_check_authorization_finish (transaction->priv->authority, res, &error);
+ transaction->priv->waiting_for_auth = FALSE;
+
+ /* failed */
+ if (result == NULL) {
+ egg_warning ("failed to check for auth: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* did not auth */
+ if (!polkit_authorization_result_get_is_authorized (result)) {
+
+ /* emit an ::ErrorCode() and then ::Finished() */
+ pk_transaction_error_code_emit (transaction, PK_ERROR_ENUM_NOT_AUTHORIZED, "failed to obtain auth");
+ pk_transaction_finished_emit (transaction, PK_EXIT_ENUM_FAILED, 0);
+
+ pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_AUTH, "uid %i failed to obtain auth", transaction->priv->uid);
+ goto out;
+ }
+
+ /* try to commit this */
+ ret = pk_transaction_commit (transaction);
+ if (!ret) {
+ egg_warning ("Could not commit to a transaction object");
+ pk_transaction_release_tid (transaction);
+ goto out;
+ }
+
+ /* log success too */
+ pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_AUTH, "uid %i obtained auth", transaction->priv->uid);
+out:
+ if (result != NULL)
+ g_object_unref (result);
+ return;
+}
+
/**
- * pk_transaction_action_is_allowed:
+ * pk_transaction_role_to_action:
+ **/
+static const gchar *
+pk_transaction_role_to_action (gboolean trusted, PkRoleEnum role)
+{
+ const gchar *policy = NULL;
+
+ if (role == PK_ROLE_ENUM_UPDATE_PACKAGES ||
+ role == PK_ROLE_ENUM_UPDATE_SYSTEM) {
+ policy = "org.freedesktop.packagekit.system-update";
+ } else if (role == PK_ROLE_ENUM_INSTALL_SIGNATURE) {
+ policy = "org.freedesktop.packagekit.system-trust-signing-key";
+ } else if (role == PK_ROLE_ENUM_ROLLBACK) {
+ policy = "org.freedesktop.packagekit.system-rollback";
+ } else if (role == PK_ROLE_ENUM_REPO_ENABLE ||
+ role == PK_ROLE_ENUM_REPO_SET_DATA) {
+ policy = "org.freedesktop.packagekit.system-sources-configure";
+ } else if (role == PK_ROLE_ENUM_REFRESH_CACHE) {
+ policy = "org.freedesktop.packagekit.system-sources-refresh";
+ } else if (role == PK_ROLE_ENUM_REMOVE_PACKAGES) {
+ policy = "org.freedesktop.packagekit.package-remove";
+ } else if (role == PK_ROLE_ENUM_INSTALL_PACKAGES) {
+ policy = "org.freedesktop.packagekit.package-install";
+ } else if (role == PK_ROLE_ENUM_INSTALL_FILES && trusted) {
+ policy = "org.freedesktop.packagekit.package-install";
+ } else if (role == PK_ROLE_ENUM_INSTALL_FILES && !trusted) {
+ 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;
+}
+
+/**
+ * pk_transaction_obtain_authorization:
*
* Only valid from an async caller, which is fine, as we won't prompt the user
* when not async.
+ *
+ * Because checking for authentication might have to respond to user input, this
+ * is treated as async. As such, the transaction should only be added to the
+ * transaction list when authorised, and not before.
**/
static gboolean
-pk_transaction_action_is_allowed (PkTransaction *transaction, gboolean trusted, PkRoleEnum role, GError **error)
+pk_transaction_obtain_authorization (PkTransaction *transaction, gboolean trusted, PkRoleEnum role, GError **error)
{
- gboolean ret;
- gchar *error_detail;
+ const gchar *action_id;
+ gboolean ret = FALSE;
g_return_val_if_fail (transaction->priv->sender != NULL, FALSE);
- /* we should always have caller */
- if (transaction->priv->caller == NULL) {
+ /* we should always have subject */
+ if (transaction->priv->subject == NULL) {
*error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_REFUSED_BY_POLICY,
- "caller %s not found", transaction->priv->sender);
- return FALSE;
+ "subject %s not found", transaction->priv->sender);
+ goto out;
}
- /* use security model to get auth */
- ret = pk_security_action_is_allowed (transaction->priv->security, transaction->priv->caller, trusted, role, &error_detail);
+ /* map the roles to policykit rules */
+ action_id = pk_transaction_role_to_action (trusted, role);
+ if (action_id == NULL) {
+ *error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_REFUSED_BY_POLICY, "policykit type required for '%s'", pk_role_enum_to_text (role));
+ goto out;
+ }
+
+ /* log */
+ pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_AUTH, "uid %i is trying to obtain %s auth (trusted:%i)", transaction->priv->uid, action_id, trusted);
+
+ /* check subject */
+ transaction->priv->waiting_for_auth = TRUE;
+ polkit_authority_check_authorization (transaction->priv->authority,
+ transaction->priv->subject,
+ action_id,
+ NULL,
+ POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
+ transaction->priv->cancellable,
+ (GAsyncReadyCallback) pk_transaction_action_obtain_authorization_finished_cb,
+ transaction);
+ /* assume success, as this is async */
+ ret = TRUE;
+out:
+ return ret;
+}
+
+#else
+/**
+ * pk_transaction_obtain_authorization:
+ **/
+static gboolean
+pk_transaction_obtain_authorization (PkTransaction *transaction, gboolean trusted, PkRoleEnum role, GError **error)
+{
+ gboolean ret;
+
+ egg_warning ("*** THERE IS NO SECURITY MODEL BEING USED!!! ***");
+
+ /* try to commit this */
+ ret = pk_transaction_commit (transaction);
if (!ret) {
- *error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_REFUSED_BY_POLICY, "%s", error_detail);
- g_free (error_detail);
+ egg_warning ("Could not commit to a transaction object");
+ pk_transaction_release_tid (transaction);
}
+
return ret;
}
+#endif
/**
* pk_transaction_priv_get_role:
@@ -1554,8 +1801,8 @@ pk_transaction_accept_eula (PkTransaction *transaction, const gchar *eula_id, DB
return;
}
- /* 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);
+ /* try to get authorization */
+ ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_ACCEPT_EULA, &error);
if (!ret) {
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
@@ -1589,7 +1836,6 @@ pk_transaction_cancel (PkTransaction *transaction, DBusGMethodInvocation *contex
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);
@@ -1628,7 +1874,7 @@ pk_transaction_cancel (PkTransaction *transaction, DBusGMethodInvocation *contex
}
/* check if we saved the uid */
- if (transaction->priv->uid == PK_SECURITY_UID_INVALID) {
+ if (transaction->priv->uid == PK_TRANSACTION_UID_INVALID) {
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_CANNOT_CANCEL,
"No context from caller to get UID from");
pk_transaction_dbus_return_error (context, error);
@@ -1637,13 +1883,11 @@ pk_transaction_cancel (PkTransaction *transaction, DBusGMethodInvocation *contex
/* 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);
+ uid = pk_transaction_get_uid (transaction, sender);
g_free (sender);
- pk_security_caller_unref (caller);
/* check we got a valid value */
- if (uid == PK_SECURITY_UID_INVALID) {
+ if (uid == PK_TRANSACTION_UID_INVALID) {
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_INVALID_STATE, "unable to get uid of caller");
pk_transaction_dbus_return_error (context, error);
return;
@@ -1652,7 +1896,7 @@ pk_transaction_cancel (PkTransaction *transaction, DBusGMethodInvocation *contex
/* 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);
+ ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_CANCEL, &error);
if (!ret) {
pk_transaction_dbus_return_error (context, error);
return;
@@ -2680,8 +2924,8 @@ pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
}
}
- /* 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);
+ /* try to get authorization */
+ ret = pk_transaction_obtain_authorization (transaction, trusted, PK_ROLE_ENUM_INSTALL_FILES, &error);
if (!ret) {
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
@@ -2693,16 +2937,6 @@ pk_transaction_install_files (PkTransaction *transaction, gboolean trusted,
transaction->priv->cached_full_paths = g_strdupv (full_paths);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_INSTALL_FILES);
- /* try to commit this */
- ret = pk_transaction_commit (transaction);
- if (!ret) {
- error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_COMMIT_FAILED,
- "Could not commit to a transaction object");
- pk_transaction_release_tid (transaction);
- pk_transaction_dbus_return_error (context, error);
- return;
- }
-
/* return from async with success */
pk_transaction_dbus_return (context);
return;
@@ -2755,23 +2989,13 @@ pk_transaction_install_packages (PkTransaction *transaction, gchar **package_ids
return;
}
- /* 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) {
- pk_transaction_release_tid (transaction);
- pk_transaction_dbus_return_error (context, error);
- return;
- }
-
/* save so we can run later */
transaction->priv->cached_package_ids = g_strdupv (package_ids);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_INSTALL_PACKAGES);
- /* try to commit this */
- ret = pk_transaction_commit (transaction);
+ /* try to get authorization */
+ ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_INSTALL_PACKAGES, &error);
if (!ret) {
- error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_COMMIT_FAILED,
- "Could not commit to a transaction object");
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
return;
@@ -2834,24 +3058,14 @@ pk_transaction_install_signature (PkTransaction *transaction, const gchar *sig_t
return;
}
- /* 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) {
- pk_transaction_release_tid (transaction);
- pk_transaction_dbus_return_error (context, error);
- return;
- }
-
/* save so we can run later */
transaction->priv->cached_package_id = g_strdup (package_id);
transaction->priv->cached_key_id = g_strdup (key_id);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_INSTALL_SIGNATURE);
- /* try to commit this */
- ret = pk_transaction_commit (transaction);
+ /* try to get authorization */
+ ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_INSTALL_SIGNATURE, &error);
if (!ret) {
- error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_COMMIT_FAILED,
- "Could not commit to a transaction object");
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
return;
@@ -2907,14 +3121,6 @@ pk_transaction_refresh_cache (PkTransaction *transaction, gboolean force, DBusGM
return;
}
- /* 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_REFRESH_CACHE, &error);
- if (!ret) {
- pk_transaction_release_tid (transaction);
- pk_transaction_dbus_return_error (context, error);
- return;
- }
-
/* we unref the update cache if it exists */
pk_cache_invalidate (transaction->priv->cache);
@@ -2922,11 +3128,9 @@ pk_transaction_refresh_cache (PkTransaction *transaction, gboolean force, DBusGM
transaction->priv->cached_force = force;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_REFRESH_CACHE);
- /* try to commit this */
- ret = pk_transaction_commit (transaction);
+ /* try to get authorization */
+ ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_REFRESH_CACHE, &error);
if (!ret) {
- error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_COMMIT_FAILED,
- "Could not commit to a transaction object");
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
return;
@@ -2984,24 +3188,14 @@ pk_transaction_remove_packages (PkTransaction *transaction, gchar **package_ids,
return;
}
- /* 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) {
- pk_transaction_release_tid (transaction);
- pk_transaction_dbus_return_error (context, error);
- return;
- }
-
/* save so we can run later */
transaction->priv->cached_allow_deps = allow_deps;
transaction->priv->cached_package_ids = g_strdupv (package_ids);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_REMOVE_PACKAGES);
- /* try to commit this */
- ret = pk_transaction_commit (transaction);
+ /* try to get authorization */
+ ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_REMOVE_PACKAGES, &error);
if (!ret) {
- error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_COMMIT_FAILED,
- "Could not commit to a transaction object");
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
return;
@@ -3053,24 +3247,14 @@ pk_transaction_repo_enable (PkTransaction *transaction, const gchar *repo_id, gb
return;
}
- /* 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) {
- pk_transaction_release_tid (transaction);
- pk_transaction_dbus_return_error (context, error);
- return;
- }
-
/* save so we can run later */
transaction->priv->cached_repo_id = g_strdup (repo_id);
transaction->priv->cached_enabled = enabled;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_REPO_ENABLE);
- /* try to commit this */
- ret = pk_transaction_commit (transaction);
+ /* try to get authorization */
+ ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_REPO_ENABLE, &error);
if (!ret) {
- error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_COMMIT_FAILED,
- "Could not commit to a transaction object");
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
return;
@@ -3123,25 +3307,15 @@ pk_transaction_repo_set_data (PkTransaction *transaction, const gchar *repo_id,
return;
}
- /* 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) {
- pk_transaction_release_tid (transaction);
- pk_transaction_dbus_return_error (context, error);
- return;
- }
-
/* save so we can run later */
transaction->priv->cached_repo_id = g_strdup (repo_id);
transaction->priv->cached_parameter = g_strdup (parameter);
transaction->priv->cached_value = g_strdup (value);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_REPO_SET_DATA);
- /* try to commit this */
- ret = pk_transaction_commit (transaction);
+ /* try to get authorization */
+ ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_REPO_SET_DATA, &error);
if (!ret) {
- error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_COMMIT_FAILED,
- "Could not commit to a transaction object");
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
return;
@@ -3270,23 +3444,13 @@ pk_transaction_rollback (PkTransaction *transaction, const gchar *transaction_id
return;
}
- /* 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) {
- pk_transaction_release_tid (transaction);
- pk_transaction_dbus_return_error (context, error);
- return;
- }
-
/* save so we can run later */
transaction->priv->cached_transaction_id = g_strdup (transaction_id);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_ROLLBACK);
- /* try to commit this */
- ret = pk_transaction_commit (transaction);
+ /* try to get authorization */
+ ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_ROLLBACK, &error);
if (!ret) {
- error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_COMMIT_FAILED,
- "Could not commit to a transaction object");
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
return;
@@ -3646,23 +3810,13 @@ pk_transaction_update_packages (PkTransaction *transaction, gchar **package_ids,
return;
}
- /* 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) {
- pk_transaction_release_tid (transaction);
- pk_transaction_dbus_return_error (context, error);
- return;
- }
-
/* save so we can run later */
transaction->priv->cached_package_ids = g_strdupv (package_ids);
pk_transaction_set_role (transaction, PK_ROLE_ENUM_UPDATE_PACKAGES);
- /* try to commit this */
- ret = pk_transaction_commit (transaction);
+ /* try to get authorization */
+ ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_UPDATE_PACKAGES, &error);
if (!ret) {
- error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_COMMIT_FAILED,
- "Could not commit to a transaction object");
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
return;
@@ -3703,14 +3857,6 @@ pk_transaction_update_system (PkTransaction *transaction, DBusGMethodInvocation
return;
}
- /* 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_SYSTEM, &error);
- if (!ret) {
- pk_transaction_release_tid (transaction);
- pk_transaction_dbus_return_error (context, error);
- return;
- }
-
/* are we already performing an update? */
if (pk_transaction_list_role_present (transaction->priv->transaction_list, PK_ROLE_ENUM_UPDATE_SYSTEM)) {
error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_TRANSACTION_EXISTS_WITH_ROLE,
@@ -3722,11 +3868,9 @@ pk_transaction_update_system (PkTransaction *transaction, DBusGMethodInvocation
pk_transaction_set_role (transaction, PK_ROLE_ENUM_UPDATE_SYSTEM);
- /* try to commit this */
- ret = pk_transaction_commit (transaction);
+ /* try to get authorization */
+ ret = pk_transaction_obtain_authorization (transaction, FALSE, PK_ROLE_ENUM_UPDATE_SYSTEM, &error);
if (!ret) {
- error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_COMMIT_FAILED,
- "Could not commit to a transaction object");
pk_transaction_release_tid (transaction);
pk_transaction_dbus_return_error (context, error);
return;
@@ -3943,10 +4087,13 @@ pk_transaction_class_init (PkTransactionClass *klass)
static void
pk_transaction_init (PkTransaction *transaction)
{
+ GError *error = NULL;
+
transaction->priv = PK_TRANSACTION_GET_PRIVATE (transaction);
transaction->priv->finished = FALSE;
transaction->priv->running = FALSE;
transaction->priv->has_been_run = FALSE;
+ transaction->priv->waiting_for_auth = FALSE;
transaction->priv->allow_cancel = TRUE;
transaction->priv->emit_eula_required = FALSE;
transaction->priv->emit_signature_required = FALSE;
@@ -3967,8 +4114,10 @@ pk_transaction_init (PkTransaction *transaction)
transaction->priv->tid = NULL;
transaction->priv->sender = NULL;
transaction->priv->locale = NULL;
- transaction->priv->caller = NULL;
- transaction->priv->uid = PK_SECURITY_UID_INVALID;
+#ifdef USE_SECURITY_POLKIT
+ transaction->priv->subject = NULL;
+#endif
+ transaction->priv->uid = PK_TRANSACTION_UID_INVALID;
transaction->priv->role = PK_ROLE_ENUM_UNKNOWN;
transaction->priv->status = PK_STATUS_ENUM_WAIT;
transaction->priv->percentage = PK_BACKEND_PERCENTAGE_INVALID;
@@ -3976,7 +4125,6 @@ pk_transaction_init (PkTransaction *transaction)
transaction->priv->elapsed = 0;
transaction->priv->remaining = 0;
transaction->priv->backend = pk_backend_new ();
- transaction->priv->security = pk_security_new ();
transaction->priv->cache = pk_cache_new ();
transaction->priv->conf = pk_conf_new ();
transaction->priv->notify = pk_notify_new ();
@@ -3984,6 +4132,10 @@ pk_transaction_init (PkTransaction *transaction)
transaction->priv->package_list = pk_package_list_new ();
transaction->priv->transaction_list = pk_transaction_list_new ();
transaction->priv->syslog = pk_syslog_new ();
+#ifdef USE_SECURITY_POLKIT
+ transaction->priv->authority = polkit_authority_get ();
+ transaction->priv->cancellable = g_cancellable_new ();
+#endif
transaction->priv->post_trans = pk_post_trans_new ();
g_signal_connect (transaction->priv->post_trans, "status-changed",
@@ -3998,6 +4150,17 @@ pk_transaction_init (PkTransaction *transaction)
transaction->priv->monitor = egg_dbus_monitor_new ();
g_signal_connect (transaction->priv->monitor, "connection-changed",
G_CALLBACK (pk_transaction_caller_active_changed_cb), transaction);
+
+ /* connect to DBus so we can get the pid */
+ transaction->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+ transaction->priv->proxy_pid = dbus_g_proxy_new_for_name_owner (transaction->priv->connection,
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus/Bus",
+ "org.freedesktop.DBus", &error);
+ if (transaction->priv->proxy_pid == NULL) {
+ egg_warning ("cannot connect to DBus: %s", error->message);
+ g_error_free (error);
+ }
}
/**
@@ -4015,6 +4178,16 @@ pk_transaction_dispose (GObject *object)
/* remove any inhibit, it's okay to call this function when it's not needed */
pk_inhibit_remove (transaction->priv->inhibit, transaction);
+ /* were we waiting for the client to authorise */
+ if (transaction->priv->waiting_for_auth) {
+#ifdef USE_SECURITY_POLKIT
+ g_cancellable_cancel (transaction->priv->cancellable);
+#endif
+ /* emit an ::ErrorCode() and then ::Finished() */
+ pk_transaction_error_code_emit (transaction, PK_ERROR_ENUM_NOT_AUTHORIZED, "client did not authorize action");
+ pk_transaction_finished_emit (transaction, PK_EXIT_ENUM_FAILED, 0);
+ }
+
/* send signal to clients that we are about to be destroyed */
egg_debug ("emitting destroy %s", transaction->priv->tid);
g_signal_emit (transaction, signals [PK_TRANSACTION_DESTROY], 0);
@@ -4034,6 +4207,11 @@ pk_transaction_finalize (GObject *object)
transaction = PK_TRANSACTION (object);
+#ifdef USE_SECURITY_POLKIT
+ if (transaction->priv->subject != NULL)
+ g_object_unref (transaction->priv->subject);
+#endif
+
g_free (transaction->priv->last_package_id);
g_free (transaction->priv->locale);
g_free (transaction->priv->cached_package_id);
@@ -4056,11 +4234,14 @@ pk_transaction_finalize (GObject *object)
g_object_unref (transaction->priv->package_list);
g_object_unref (transaction->priv->transaction_list);
g_object_unref (transaction->priv->transaction_db);
- g_object_unref (transaction->priv->security);
+ g_object_unref (transaction->priv->proxy_pid);
g_object_unref (transaction->priv->notify);
g_object_unref (transaction->priv->syslog);
g_object_unref (transaction->priv->post_trans);
- pk_security_caller_unref (transaction->priv->caller);
+#ifdef USE_SECURITY_POLKIT
+// g_object_unref (transaction->priv->authority);
+ g_object_unref (transaction->priv->cancellable);
+#endif
G_OBJECT_CLASS (pk_transaction_parent_class)->finalize (object);
}
@@ -4091,6 +4272,9 @@ egg_test_transaction (EggTest *test)
gboolean ret;
const gchar *temp;
GError *error = NULL;
+#ifdef USE_SECURITY_POLKIT
+ const gchar *action;
+#endif
if (!egg_test_start (test, "PkTransaction"))
return;
@@ -4101,6 +4285,26 @@ egg_test_transaction (EggTest *test)
egg_test_assert (test, transaction != NULL);
/************************************************************
+ **************** MAP ROLES ******************
+ ************************************************************/
+#ifdef USE_SECURITY_POLKIT
+ egg_test_title (test, "map valid role to action");
+ action = pk_transaction_role_to_action (FALSE, PK_ROLE_ENUM_UPDATE_PACKAGES);
+ if (egg_strequal (action, "org.freedesktop.packagekit.system-update"))
+ egg_test_success (test, NULL);
+ else
+ egg_test_failed (test, "did not get correct action '%s'", action);
+
+ /************************************************************/
+ egg_test_title (test, "map invalid role to action");
+ action = pk_transaction_role_to_action (FALSE, PK_ROLE_ENUM_SEARCH_NAME);
+ if (action == NULL)
+ egg_test_success (test, NULL);
+ else
+ egg_test_failed (test, "did not get correct action '%s'", action);
+#endif
+
+ /************************************************************
**************** FILTERS ******************
************************************************************/
temp = NULL;
commit ad387b212aa8da94df3693359512549ac756ce8e
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Jun 16 17:12:24 2009 +0100
Bump the release now we've forked PACKAGEKIT_0_4_X
diff --git a/configure.ac b/configure.ac
index d640ee2..92cfb42 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,8 +2,8 @@
AC_PREREQ(2.52)
m4_define([pk_major_version], [0])
-m4_define([pk_minor_version], [4])
-m4_define([pk_micro_version], [9])
+m4_define([pk_minor_version], [5])
+m4_define([pk_micro_version], [0])
m4_define([pk_version],
[pk_major_version.pk_minor_version.pk_micro_version])
More information about the PackageKit-commit
mailing list