[PackageKit-commit] packagekit: Branch 'master' - 7 commits

Richard Hughes hughsient at kemper.freedesktop.org
Wed Nov 19 11:05:29 PST 2008


 lib/packagekit-glib/pk-control.c |    1 
 src/Makefile.am                  |    2 
 src/pk-main.c                    |   34 ++++-----
 src/pk-security-polkit.c         |   21 +++++
 src/pk-security.h                |    3 
 src/pk-syslog.c                  |  144 +++++++++++++++++++++++++++++++++++++++
 src/pk-syslog.h                  |   64 +++++++++++++++++
 src/pk-transaction.c             |   44 ++++++++++-
 8 files changed, 291 insertions(+), 22 deletions(-)

New commits:
commit 96e8125e97ac1a041c033ad2b998fd7fb693c92a
Merge: 722d1f8... c915378...
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Nov 19 18:51:43 2008 +0000

    Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit

commit 722d1f8306eef1f3a841512930b1f3614207090e
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Nov 19 18:49:51 2008 +0000

    trivial: log to syslog in the PkTransaction object also

diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 2ccc88b..282b38d 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -60,6 +60,7 @@
 #include "pk-notify.h"
 #include "pk-security.h"
 #include "pk-post-trans.h"
+#include "pk-syslog.h"
 
 static void     pk_transaction_class_init	(PkTransactionClass *klass);
 static void     pk_transaction_init		(PkTransaction      *transaction);
@@ -96,6 +97,7 @@ struct PkTransactionPrivate
 	PkSecurity		*security;
 	PkSecurityCaller	*caller;
 	PkPostTrans		*post_trans;
+	PkSyslog		*syslog;
 
 	/* needed for gui coldplugging */
 	gchar			*last_package_id;
@@ -552,6 +554,7 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit, PkTransaction *
 	guint i, length;
 	PkPackageList *list;
 	const PkPackageObj *obj;
+	guint uid = PK_SECURITY_UID_INVALID;
 
 	g_return_if_fail (PK_IS_TRANSACTION (transaction));
 	g_return_if_fail (transaction->priv->tid != NULL);
@@ -680,15 +683,35 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit, PkTransaction *
 	time = pk_transaction_get_runtime (transaction);
 	egg_debug ("backend was running for %i ms", time);
 
+	/* get user for logging */
+	if (transaction->priv->caller != NULL)
+		uid = pk_security_get_uid (transaction->priv->security, transaction->priv->caller);
+
 	/* add to the database if we are going to log it */
 	if (transaction->priv->role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
 	    transaction->priv->role == PK_ROLE_ENUM_UPDATE_PACKAGES ||
 	    transaction->priv->role == PK_ROLE_ENUM_INSTALL_PACKAGES ||
 	    transaction->priv->role == PK_ROLE_ENUM_REMOVE_PACKAGES) {
 		packages = pk_obj_list_to_string (PK_OBJ_LIST(transaction->priv->package_list));
+
+		/* save to database */
 		if (!egg_strzero (packages))
 			pk_transaction_db_set_data (transaction->priv->transaction_db, transaction->priv->tid, packages);
 		g_free (packages);
+
+		/* report to syslog */
+		length = PK_OBJ_LIST(transaction->priv->package_list)->len;
+		for (i=0; i<length; i++) {
+			obj = pk_package_list_get_obj (transaction->priv->package_list, i);
+			if (obj->info == PK_INFO_ENUM_REMOVING ||
+			    obj->info == PK_INFO_ENUM_INSTALLING ||
+			    obj->info == PK_INFO_ENUM_UPDATING) {
+				packages = pk_package_id_to_string (obj->id);
+				pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_INFO, "in %s for %s package %s was %s for uid %i",
+					       transaction->priv->tid, pk_role_enum_to_text (transaction->priv->role), packages, pk_info_enum_to_text (obj->info), uid);
+				g_free (packages);
+			}
+		}
 	}
 
 	/* the repo list will have changed */
@@ -710,6 +733,14 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit, PkTransaction *
 	/* remove any inhibit */
 	pk_inhibit_remove (transaction->priv->inhibit, transaction);
 
+	/* report to syslog */
+	if (uid != G_MAXUINT)
+		pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_INFO, "%s transaction %s from uid %i finished with %s after %ims",
+			       pk_role_enum_to_text (transaction->priv->role), transaction->priv->tid, uid, pk_exit_enum_to_text (exit), time);
+	else
+		pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_INFO, "%s transaction %s finished with %s after %ims",
+			       pk_role_enum_to_text (transaction->priv->role), transaction->priv->tid, pk_exit_enum_to_text (exit), time);
+
 	/* we emit last, as other backends will be running very soon after us, and we don't want to be notified */
 	pk_transaction_finished_emit (transaction, exit, time);
 }
@@ -1234,6 +1265,11 @@ pk_transaction_commit (PkTransaction *transaction)
 		/* save cmdline */
 		cmdline = pk_security_get_cmdline (transaction->priv->security, transaction->priv->caller);
 		pk_transaction_db_set_cmdline (transaction->priv->transaction_db, transaction->priv->tid, cmdline);
+
+		/* report to syslog */
+		pk_syslog_add (transaction->priv->syslog, PK_SYSLOG_TYPE_INFO, "new %s transaction %s scheduled from uid %i",
+			       pk_role_enum_to_text (transaction->priv->role), transaction->priv->tid, uid);
+
 		g_free (cmdline);
 	}
 	return TRUE;
@@ -3819,6 +3855,7 @@ pk_transaction_init (PkTransaction *transaction)
 	transaction->priv->inhibit = pk_inhibit_new ();
 	transaction->priv->package_list = pk_package_list_new ();
 	transaction->priv->transaction_list = pk_transaction_list_new ();
+	transaction->priv->syslog = pk_syslog_new ();
 
 	transaction->priv->post_trans = pk_post_trans_new ();
 	g_signal_connect (transaction->priv->post_trans, "status-changed",
@@ -3880,6 +3917,7 @@ pk_transaction_finalize (GObject *object)
 	g_object_unref (transaction->priv->transaction_db);
 	g_object_unref (transaction->priv->security);
 	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);
 
commit 7fe04c59a21237bf04e6e125ebb86770983e2dc9
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Nov 19 18:49:24 2008 +0000

    bugfix: when logging to LOG_AUTHPRIV also log to LOG_DAEMON

diff --git a/src/pk-syslog.c b/src/pk-syslog.c
index e74fc13..3706139 100644
--- a/src/pk-syslog.c
+++ b/src/pk-syslog.c
@@ -43,7 +43,6 @@ void
 pk_syslog_add (PkSyslog *self, PkSyslogType type, const gchar *format, ...)
 {
 	va_list args;
-	gint syslogtype = LOG_USER;
 	gchar va_args_buffer[1025];
 
 	g_return_if_fail (PK_IS_SYSLOG (self));
@@ -54,10 +53,10 @@ pk_syslog_add (PkSyslog *self, PkSyslogType type, const gchar *format, ...)
 
 	/* auth messages are special */
 	if (type == PK_SYSLOG_TYPE_AUTH)
-		syslogtype = LOG_AUTHPRIV;
+		syslog (LOG_AUTHPRIV, "%s", va_args_buffer);
 
 	egg_debug ("logging to syslog '%s'", va_args_buffer);
-	syslog (syslogtype, "%s", va_args_buffer);
+	syslog (LOG_DAEMON, "%s", va_args_buffer);
 }
 
 /**
diff --git a/src/pk-syslog.h b/src/pk-syslog.h
index 87e780f..297b5ac 100644
--- a/src/pk-syslog.h
+++ b/src/pk-syslog.h
@@ -50,8 +50,6 @@ typedef struct
 typedef enum {
 	PK_SYSLOG_TYPE_AUTH,
 	PK_SYSLOG_TYPE_INFO,
-	PK_SYSLOG_TYPE_SUCCESS,
-	PK_SYSLOG_TYPE_FAILURE,
 	PK_SYSLOG_TYPE_UNKNOWN
 } PkSyslogType;
 
commit b010577acf9e6e6932e6cb873feb4d0b4fc0e656
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Nov 19 18:48:19 2008 +0000

    trivial: define PK_SECURITY_UID_INVALID when the uid is invalid or unknown

diff --git a/src/pk-security-polkit.c b/src/pk-security-polkit.c
index fd21848..42aa95c 100644
--- a/src/pk-security-polkit.c
+++ b/src/pk-security-polkit.c
@@ -99,12 +99,13 @@ pk_security_get_uid (PkSecurity *security, PkSecurityCaller *caller)
 	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 = -1;
+		uid = PK_SECURITY_UID_INVALID;
 	}
 
 	return uid;
@@ -124,6 +125,7 @@ pk_security_get_cmdline (PkSecurity *security, PkSecurityCaller *caller)
 	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);
diff --git a/src/pk-security.h b/src/pk-security.h
index e433df4..339fd73 100644
--- a/src/pk-security.h
+++ b/src/pk-security.h
@@ -37,6 +37,9 @@ G_BEGIN_DECLS
 /* not actually a role, but treated as one */
 #define PK_ROLE_ENUM_SET_PROXY_PRIVATE		1 << 31
 
+/* when the UID is invalid or not known */
+#define PK_SECURITY_UID_INVALID			G_MAXUINT
+
 typedef struct PkSecurityPrivate PkSecurityPrivate;
 
 typedef struct
commit 9314f11847629db7728cc3768747dcbb900bda19
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Nov 19 18:46:24 2008 +0000

    trivial: when we ctr-c out of the daemon, just exit the loop and unref everything properly

diff --git a/src/pk-main.c b/src/pk-main.c
index 0ed05dd..85ae3d7 100644
--- a/src/pk-main.c
+++ b/src/pk-main.c
@@ -42,8 +42,7 @@
 #include "org.freedesktop.PackageKit.h"
 
 static guint exit_idle_time;
-static PkEngine *engine = NULL;
-static PkBackend *backend = NULL;
+static GMainLoop *loop;
 
 /**
  * pk_object_register:
@@ -151,16 +150,8 @@ pk_main_sigint_handler (int sig)
 	/* restore default ASAP, as the finalisers might hang */
 	signal (SIGINT, SIG_DFL);
 
-	/* cleanup */
-	g_object_unref (backend);
-	g_object_unref (engine);
-
-	/* give the backend a sporting chance */
-	g_usleep (500*1000);
-
-	/* kill ourselves */
-	egg_debug ("Retrying SIGINT");
-	kill (getpid (), SIGINT);
+	/* exit loop */
+	g_main_loop_quit (loop);
 }
 
 /**
@@ -169,7 +160,6 @@ pk_main_sigint_handler (int sig)
 int
 main (int argc, char *argv[])
 {
-	GMainLoop *loop;
 	DBusGConnection *system_connection;
 	EggDbusMonitor *monitor;
 	gboolean ret;
@@ -181,6 +171,8 @@ main (int argc, char *argv[])
 	gboolean immediate_exit = FALSE;
 	gboolean do_logging = FALSE;
 	gchar *backend_name = NULL;
+	PkEngine *engine = NULL;
+	PkBackend *backend = NULL;
 	PkConf *conf = NULL;
 	PkSyslog *syslog = NULL;
 	GError *error = NULL;
commit c9153782244546be8b141596c5c5c72becae6cfd
Author: Scott Reeves <sreeves at novell.com>
Date:   Wed Nov 19 11:03:32 2008 -0700

    fix crash when pk-control is referenced after it's finalized

diff --git a/lib/packagekit-glib/pk-control.c b/lib/packagekit-glib/pk-control.c
index 4952677..d0bbd47 100644
--- a/lib/packagekit-glib/pk-control.c
+++ b/lib/packagekit-glib/pk-control.c
@@ -984,6 +984,7 @@ pk_control_finalize (GObject *object)
 	if (control->priv->idle_id != 0)
 		g_source_remove (control->priv->idle_id);
 	g_object_unref (G_OBJECT (control->priv->proxy));
+	g_object_unref (G_OBJECT (control->priv->pconnection));
 	g_strfreev (control->priv->array);
 
 	G_OBJECT_CLASS (pk_control_parent_class)->finalize (object);
commit 6bf84b6dbf09ff0f30eb1f02588e80ab031f3969
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Nov 19 17:45:14 2008 +0000

    feature: add syslog logging so that we keep a record of obtained authorisations

diff --git a/src/Makefile.am b/src/Makefile.am
index 4073875..cf53125 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,6 +66,8 @@ shared_SOURCES =					\
 	pk-network-unix.h				\
 	pk-time.h					\
 	pk-time.c					\
+	pk-syslog.h					\
+	pk-syslog.c					\
 	pk-conf.c					\
 	pk-conf.h					\
 	pk-store.c					\
diff --git a/src/pk-main.c b/src/pk-main.c
index 32eea39..0ed05dd 100644
--- a/src/pk-main.c
+++ b/src/pk-main.c
@@ -36,6 +36,7 @@
 
 #include "pk-conf.h"
 #include "pk-engine.h"
+#include "pk-syslog.h"
 #include "pk-transaction.h"
 #include "pk-backend-internal.h"
 #include "org.freedesktop.PackageKit.h"
@@ -181,6 +182,7 @@ main (int argc, char *argv[])
 	gboolean do_logging = FALSE;
 	gchar *backend_name = NULL;
 	PkConf *conf = NULL;
+	PkSyslog *syslog = NULL;
 	GError *error = NULL;
 	GOptionContext *context;
 	const gchar *env_pk_verbose;
@@ -205,9 +207,8 @@ main (int argc, char *argv[])
 		{ NULL}
 	};
 
-	if (! g_thread_supported ()) {
+	if (! g_thread_supported ())
 		g_thread_init (NULL);
-	}
 	dbus_g_thread_init ();
 	g_type_init ();
 
@@ -265,6 +266,10 @@ main (int argc, char *argv[])
 	/* get values from the config file */
 	conf = pk_conf_new ();
 
+	/* log the startup */
+	syslog = pk_syslog_new ();
+	pk_syslog_add (syslog, PK_SYSLOG_TYPE_INFO, "daemon start");
+
 	/* do we log? */
 	do_logging = pk_conf_get_bool (conf, "TransactionLogging");
 	egg_debug ("Log all transactions: %i", do_logging);
@@ -285,9 +290,8 @@ main (int argc, char *argv[])
 	g_free (backend_name);
 
 	/* all okay? */
-	if (!ret) {
+	if (!ret)
 		egg_error ("cannot continue, backend invalid");
-	}
 
 	/* create a new engine object */
 	engine = pk_engine_new ();
@@ -317,6 +321,10 @@ main (int argc, char *argv[])
 	g_main_loop_unref (loop);
 
 out:
+	/* log the shutdown */
+	pk_syslog_add (syslog, PK_SYSLOG_TYPE_INFO, "daemon quit");
+
+	g_object_unref (syslog);
 	g_object_unref (conf);
 	g_object_unref (engine);
 	g_object_unref (backend);
diff --git a/src/pk-security-polkit.c b/src/pk-security-polkit.c
index 2c75fde..fd21848 100644
--- a/src/pk-security-polkit.c
+++ b/src/pk-security-polkit.c
@@ -41,6 +41,7 @@
 #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))
 
@@ -48,6 +49,7 @@ struct PkSecurityPrivate
 {
 	PolKitContext		*pk_context;
 	DBusConnection		*connection;
+	PkSyslog		*syslog;
 };
 
 typedef PolKitCaller PkSecurityCaller_;
@@ -190,6 +192,8 @@ pk_security_action_is_allowed (PkSecurity *security, PkSecurityCaller *caller, g
 	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);
@@ -222,6 +226,15 @@ pk_security_action_is_allowed (PkSecurity *security, PkSecurityCaller *caller, g
 	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;
@@ -239,6 +252,7 @@ pk_security_finalize (GObject *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);
 }
@@ -314,6 +328,9 @@ pk_security_init (PkSecurity *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);
diff --git a/src/pk-syslog.c b/src/pk-syslog.c
new file mode 100644
index 0000000..e74fc13
--- /dev/null
+++ b/src/pk-syslog.c
@@ -0,0 +1,145 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 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.
+ */
+
+#include <syslog.h>
+#include <glib.h>
+
+#include "egg-debug.h"
+#include "pk-syslog.h"
+
+#define PK_SYSLOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_SYSLOG, PkSyslogPrivate))
+
+struct PkSyslogPrivate
+{
+	gpointer		data;
+	/* any logging instance data here */
+};
+
+G_DEFINE_TYPE (PkSyslog, pk_syslog, G_TYPE_OBJECT)
+static gpointer pk_syslog_object = NULL;
+
+/**
+ * pk_syslog_add:
+ **/
+void
+pk_syslog_add (PkSyslog *self, PkSyslogType type, const gchar *format, ...)
+{
+	va_list args;
+	gint syslogtype = LOG_USER;
+	gchar va_args_buffer[1025];
+
+	g_return_if_fail (PK_IS_SYSLOG (self));
+
+	va_start (args, format);
+	g_vsnprintf (va_args_buffer, 1024, format, args);
+	va_end (args);
+
+	/* auth messages are special */
+	if (type == PK_SYSLOG_TYPE_AUTH)
+		syslogtype = LOG_AUTHPRIV;
+
+	egg_debug ("logging to syslog '%s'", va_args_buffer);
+	syslog (syslogtype, "%s", va_args_buffer);
+}
+
+/**
+ * pk_syslog_finalize:
+ **/
+static void
+pk_syslog_finalize (GObject *object)
+{
+	PkSyslog *self;
+	g_return_if_fail (PK_IS_SYSLOG (object));
+	self = PK_SYSLOG (object);
+
+	/* shut down syslog */
+	closelog ();
+
+	G_OBJECT_CLASS (pk_syslog_parent_class)->finalize (object);
+}
+
+/**
+ * pk_syslog_class_init:
+ **/
+static void
+pk_syslog_class_init (PkSyslogClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = pk_syslog_finalize;
+	g_type_class_add_private (klass, sizeof (PkSyslogPrivate));
+}
+
+/**
+ * pk_syslog_init:
+ **/
+static void
+pk_syslog_init (PkSyslog *self)
+{
+	self->priv = PK_SYSLOG_GET_PRIVATE (self);
+
+	/* open syslog */
+	openlog ("PackageKit", LOG_NDELAY, LOG_USER);
+}
+
+/**
+ * pk_syslog_new:
+ * Return value: A new syslog class instance.
+ **/
+PkSyslog *
+pk_syslog_new (void)
+{
+	if (pk_syslog_object != NULL) {
+		g_object_ref (pk_syslog_object);
+	} else {
+		pk_syslog_object = g_object_new (PK_TYPE_SYSLOG, NULL);
+		g_object_add_weak_pointer (pk_syslog_object, &pk_syslog_object);
+	}
+	return PK_SYSLOG (pk_syslog_object);
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+void
+egg_test_syslog (EggTest *test)
+{
+	PkSyslog *self;
+
+	if (!egg_test_start (test, "PkSyslog"))
+		return;
+
+	/************************************************************/
+	egg_test_title (test, "get an instance");
+	syslog = pk_syslog_new ();
+	if (syslog != NULL)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, NULL);
+
+	g_object_unref (syslog);
+
+	egg_test_end (test);
+}
+#endif
+
diff --git a/src/pk-syslog.h b/src/pk-syslog.h
new file mode 100644
index 0000000..87e780f
--- /dev/null
+++ b/src/pk-syslog.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 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.
+ */
+
+#ifndef __PK_SYSLOG_H
+#define __PK_SYSLOG_H
+
+#include <glib-object.h>
+#include <packagekit-glib/packagekit.h>
+
+G_BEGIN_DECLS
+
+#define PK_TYPE_SYSLOG		(pk_syslog_get_type ())
+#define PK_SYSLOG(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_SYSLOG, PkSyslog))
+#define PK_SYSLOG_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_SYSLOG, PkSyslogClass))
+#define PK_IS_SYSLOG(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_SYSLOG))
+#define PK_IS_SYSLOG_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_SYSLOG))
+#define PK_SYSLOG_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_SYSLOG, PkSyslogClass))
+
+typedef struct PkSyslogPrivate PkSyslogPrivate;
+
+typedef struct
+{
+	GObject		      parent;
+	PkSyslogPrivate	     *priv;
+} PkSyslog;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+} PkSyslogClass;
+
+typedef enum {
+	PK_SYSLOG_TYPE_AUTH,
+	PK_SYSLOG_TYPE_INFO,
+	PK_SYSLOG_TYPE_SUCCESS,
+	PK_SYSLOG_TYPE_FAILURE,
+	PK_SYSLOG_TYPE_UNKNOWN
+} PkSyslogType;
+
+GType		 pk_syslog_get_type		(void) G_GNUC_CONST;
+PkSyslog	*pk_syslog_new			(void);
+void		 pk_syslog_add			(PkSyslog	*syslog,
+						 PkSyslogType	 type,
+						 const gchar	*format, ...);
+
+G_END_DECLS
+
+#endif /* __PK_SYSLOG_H */
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 7fa1bd6..2ccc88b 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -1369,11 +1369,9 @@ pk_transaction_action_is_allowed (PkTransaction *transaction, gboolean trusted,
 
 	/* use security model to get auth */
 	ret = pk_security_action_is_allowed (transaction->priv->security, transaction->priv->caller, trusted, role, &error_detail);
-	if (!ret) {
+	if (!ret)
 		*error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_REFUSED_BY_POLICY, "%s", error_detail);
-		return FALSE;
-	}
-	return TRUE;
+	return ret;
 }
 
 /**


More information about the PackageKit-commit mailing list