PolicyKit: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Mon Apr 9 15:38:28 PDT 2007


 libpolkit/libpolkit-action.c                    |    6 -
 libpolkit/libpolkit-action.h                    |   17 +---
 libpolkit/libpolkit-caller.c                    |   10 +-
 libpolkit/libpolkit-caller.h                    |   14 +--
 libpolkit/libpolkit-context.c                   |   39 ++++++----
 libpolkit/libpolkit-context.h                   |   32 +++-----
 libpolkit/libpolkit-debug.c                     |   10 +-
 libpolkit/libpolkit-debug.h                     |    5 -
 libpolkit/libpolkit-error.c                     |   91 ++++++++++++++++++++++--
 libpolkit/libpolkit-error.h                     |   27 +++----
 libpolkit/libpolkit-module.c                    |   78 ++++++++++----------
 libpolkit/libpolkit-module.h                    |   20 ++---
 libpolkit/libpolkit-policy-cache.c              |   32 ++++----
 libpolkit/libpolkit-policy-cache.h              |    8 --
 libpolkit/libpolkit-policy-default.c            |   57 +++++++--------
 libpolkit/libpolkit-policy-default.h            |    9 --
 libpolkit/libpolkit-policy-file-entry.c         |   21 +----
 libpolkit/libpolkit-policy-file-entry.h         |    6 -
 libpolkit/libpolkit-policy-file.c               |   68 +++++++++++------
 libpolkit/libpolkit-policy-file.h               |   28 +++++--
 libpolkit/libpolkit-resource.c                  |    4 -
 libpolkit/libpolkit-resource.h                  |    9 --
 libpolkit/libpolkit-result.c                    |    6 -
 libpolkit/libpolkit-result.h                    |    4 -
 libpolkit/libpolkit-seat.c                      |    8 +-
 libpolkit/libpolkit-seat.h                      |    7 -
 libpolkit/libpolkit-session.c                   |   28 +++----
 libpolkit/libpolkit-session.h                   |   20 ++---
 modules/allow-all/Makefile.am                   |    4 -
 modules/allow-all/polkit-module-allow-all.c     |   23 +-----
 modules/default/Makefile.am                     |    4 -
 modules/default/polkit-module-default.c         |   23 +-----
 modules/deny-all/Makefile.am                    |    4 -
 modules/deny-all/polkit-module-deny-all.c       |   23 +-----
 modules/run-program/polkit-module-run-program.c |   80 +++++++++------------
 tools/Makefile.am                               |    2 
 tools/polkit-check-caller.c                     |   12 +--
 tools/polkit-check-session.c                    |   12 +--
 tools/polkit-policy-file-validate.c             |   10 +-
 39 files changed, 451 insertions(+), 410 deletions(-)

New commits:
diff-tree 192f04cef946c0ebe5f90c8dbecc933b6ac3c197 (from 02a4c5101ca4751963f76a0e016d3308389dc2a5)
Author: David Zeuthen <davidz at redhat.com>
Date:   Mon Apr 9 18:38:20 2007 -0400

    remove all usage of glib from the header files
    
    This paves the way for getting rid of a glib dependency; when and if
    that happens is to be determined; right now it just doesn't make a lot
    of sense to reimplement GKeyFile, GSList, GHashTable, g_spawn_sync and
    other useful routines. But it might make sense if we want to get the
    message bus daemon to link with libpolkit so you e.g. can say
    
     <policy polkit="acme-frobnicate">
       <allow send_interface="com.acme.Frobnicator"
     </policy>
    
    to allow a caller on the system message bus to access that interface
    if, and only if, he can do the "acme-frobnicate" action according to
    PolicyKit.

diff --git a/libpolkit/libpolkit-action.c b/libpolkit/libpolkit-action.c
index d3ab2c6..19bd3dd 100644
--- a/libpolkit/libpolkit-action.c
+++ b/libpolkit/libpolkit-action.c
@@ -140,7 +140,7 @@ libpolkit_action_set_action_id (PolKitAc
  * 
  * Returns: TRUE iff the value was returned.
  **/
-gboolean
+bool
 libpolkit_action_get_action_id (PolKitAction *action, char **out_action_id)
 {
         g_return_val_if_fail (action != NULL, FALSE);
@@ -205,7 +205,7 @@ libpolkit_action_get_param (PolKitAction
 typedef struct {
         PolKitAction *action;
         PolKitActionParamForeachFunc cb;
-        gpointer user_data;
+        void *user_data;
 } HashClosure;
 
 static void
@@ -224,7 +224,7 @@ _hash_cb (gpointer key, gpointer value, 
  * Calls the given function for each parameter on the object.
  **/
 void
-libpolkit_action_param_foreach (PolKitAction *action, PolKitActionParamForeachFunc cb, gpointer user_data)
+libpolkit_action_param_foreach (PolKitAction *action, PolKitActionParamForeachFunc cb, void *user_data)
 {
         HashClosure data;
 
diff --git a/libpolkit/libpolkit-action.h b/libpolkit/libpolkit-action.h
index 4486c8a..1f7b192 100644
--- a/libpolkit/libpolkit-action.h
+++ b/libpolkit/libpolkit-action.h
@@ -26,10 +26,7 @@
 #ifndef LIBPOLKIT_ACTION_H
 #define LIBPOLKIT_ACTION_H
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <glib.h>
+#include <stdbool.h>
 
 struct PolKitAction;
 typedef struct PolKitAction PolKitAction;
@@ -46,19 +43,19 @@ typedef struct PolKitAction PolKitAction
 typedef void (*PolKitActionParamForeachFunc) (PolKitAction *action, 
                                               const char *key, 
                                               const char *value, 
-                                              gpointer user_data);
+                                              void *user_data);
 
-PolKitAction *libpolkit_action_new              (void);
-PolKitAction *libpolkit_action_ref              (PolKitAction *action);
+PolKitAction *libpolkit_action_new           (void);
+PolKitAction *libpolkit_action_ref           (PolKitAction *action);
 void          libpolkit_action_unref         (PolKitAction *action);
 void          libpolkit_action_set_action_id (PolKitAction *action, const char  *action_id);
-gboolean      libpolkit_action_get_action_id (PolKitAction *action, char       **out_action_id);
+bool          libpolkit_action_get_action_id (PolKitAction *action, char       **out_action_id);
 
 void          libpolkit_action_set_param     (PolKitAction *action, const char *key, const char *value);
 const char   *libpolkit_action_get_param     (PolKitAction *action, const char *key);
-void          libpolkit_action_param_foreach (PolKitAction *action, PolKitActionParamForeachFunc cb, gpointer user_data);
+void          libpolkit_action_param_foreach (PolKitAction *action, PolKitActionParamForeachFunc cb, void *user_data);
 
-void          libpolkit_action_debug            (PolKitAction *action);
+void          libpolkit_action_debug         (PolKitAction *action);
 
 #endif /* LIBPOLKIT_ACTION_H */
 
diff --git a/libpolkit/libpolkit-caller.c b/libpolkit/libpolkit-caller.c
index 56ef035..c029d41 100644
--- a/libpolkit/libpolkit-caller.c
+++ b/libpolkit/libpolkit-caller.c
@@ -205,7 +205,7 @@ libpolkit_caller_set_ck_session (PolKitC
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
+bool
 libpolkit_caller_get_dbus_name (PolKitCaller *caller, char **out_dbus_name)
 {
         g_return_val_if_fail (caller != NULL, FALSE);
@@ -223,7 +223,7 @@ libpolkit_caller_get_dbus_name (PolKitCa
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
+bool
 libpolkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid)
 {
         g_return_val_if_fail (caller != NULL, FALSE);
@@ -241,7 +241,7 @@ libpolkit_caller_get_uid (PolKitCaller *
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
+bool
 libpolkit_caller_get_pid (PolKitCaller *caller, pid_t *out_pid)
 {
         g_return_val_if_fail (caller != NULL, FALSE);
@@ -260,7 +260,7 @@ libpolkit_caller_get_pid (PolKitCaller *
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
+bool
 libpolkit_caller_get_selinux_context (PolKitCaller *caller, char **out_selinux_context)
 {
         g_return_val_if_fail (caller != NULL, FALSE);
@@ -279,7 +279,7 @@ libpolkit_caller_get_selinux_context (Po
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
+bool
 libpolkit_caller_get_ck_session (PolKitCaller *caller, PolKitSession **out_session)
 {
         g_return_val_if_fail (caller != NULL, FALSE);
diff --git a/libpolkit/libpolkit-caller.h b/libpolkit/libpolkit-caller.h
index 7e8bb3a..2c9d93e 100644
--- a/libpolkit/libpolkit-caller.h
+++ b/libpolkit/libpolkit-caller.h
@@ -26,10 +26,8 @@
 #ifndef LIBPOLKIT_CALLER_H
 #define LIBPOLKIT_CALLER_H
 
-#include <stdio.h>
-#include <unistd.h>
+#include <stdbool.h>
 #include <sys/types.h>
-#include <glib.h>
 #include <dbus/dbus.h>
 
 #include <libpolkit/libpolkit-session.h>
@@ -46,11 +44,11 @@ void              libpolkit_caller_set_u
 void              libpolkit_caller_set_pid             (PolKitCaller   *caller, pid_t           pid);
 void              libpolkit_caller_set_selinux_context (PolKitCaller   *caller, const char     *selinux_context);
 void              libpolkit_caller_set_ck_session      (PolKitCaller   *caller, PolKitSession  *session);
-gboolean          libpolkit_caller_get_dbus_name       (PolKitCaller   *caller, char          **out_dbus_name);
-gboolean          libpolkit_caller_get_uid             (PolKitCaller   *caller, uid_t          *out_uid);
-gboolean          libpolkit_caller_get_pid             (PolKitCaller   *caller, pid_t          *out_pid);
-gboolean          libpolkit_caller_get_selinux_context (PolKitCaller   *caller, char          **out_selinux_context);
-gboolean          libpolkit_caller_get_ck_session      (PolKitCaller   *caller, PolKitSession **out_session);
+bool              libpolkit_caller_get_dbus_name       (PolKitCaller   *caller, char          **out_dbus_name);
+bool              libpolkit_caller_get_uid             (PolKitCaller   *caller, uid_t          *out_uid);
+bool              libpolkit_caller_get_pid             (PolKitCaller   *caller, pid_t          *out_pid);
+bool              libpolkit_caller_get_selinux_context (PolKitCaller   *caller, char          **out_selinux_context);
+bool              libpolkit_caller_get_ck_session      (PolKitCaller   *caller, PolKitSession **out_session);
 
 void              libpolkit_caller_debug               (PolKitCaller   *caller);
 
diff --git a/libpolkit/libpolkit-context.c b/libpolkit/libpolkit-context.c
index 205bea3..61a3599 100644
--- a/libpolkit/libpolkit-context.c
+++ b/libpolkit/libpolkit-context.c
@@ -66,7 +66,7 @@ struct PolKitContext
         int refcount;
 
         PolKitContextConfigChangedCB config_changed_cb;
-        gpointer config_changed_user_data;
+        void *config_changed_user_data;
 
         PolKitContextFileMonitorAddWatch      file_monitor_add_watch_func;
         PolKitContextFileMonitorRemoveWatch   file_monitor_remove_watch_func;
@@ -94,7 +94,7 @@ libpolkit_context_new (void)
         return pk_context;
 }
 
-static gboolean
+static bool
 unload_modules (PolKitContext *pk_context)
 {
         GSList *i;
@@ -109,11 +109,11 @@ unload_modules (PolKitContext *pk_contex
         return TRUE;
 }
 
-static gboolean
-load_modules (PolKitContext *pk_context, GError **error)
+static bool
+load_modules (PolKitContext *pk_context, PolKitError **error)
 {
         const char *config_file;
-        gboolean ret;
+        bool ret;
         char *buf;
         char *end;
         char line[256];
@@ -122,17 +122,24 @@ load_modules (PolKitContext *pk_context,
         gsize len;
         int line_number;
         int mod_number;
+        GError *g_error;
 
         ret = FALSE;
         buf = NULL;
         mod_number = 0;
 
         config_file = PACKAGE_SYSCONF_DIR "/PolicyKit/PolicyKit.conf";
+        g_error = NULL;
         if (!g_file_get_contents (config_file,
                                   &buf,
                                   &len,
-                                  error)) {
+                                  &g_error)) {
                 _pk_debug ("Cannot load PolicyKit configuration file at '%s'", config_file);
+                polkit_error_set_error (error, POLKIT_ERROR_POLICY_FILE_INVALID,
+                                        "Cannot load PolicyKit configuration file at '%s': %s",
+                                        config_file,
+                                        g_error->message);
+                g_error_free (g_error);
                 goto out;
         }
 
@@ -223,7 +230,7 @@ static void
 _config_file_events (PolKitContext                 *pk_context,
                      PolKitContextFileMonitorEvent  event_mask,
                      const char                    *path,
-                     gpointer                       user_data)
+                     void                          *user_data)
 {
         _pk_debug ("Config file changed");
         unload_modules (pk_context);
@@ -239,7 +246,7 @@ static void
 _policy_dir_events (PolKitContext                 *pk_context,
                        PolKitContextFileMonitorEvent  event_mask,
                        const char                    *path,
-                       gpointer                       user_data)
+                       void                          *user_data)
 {
         /* mark cache of policy files as stale.. (will be populated on-demand, see _get_cache()) */
         if (pk_context->priv_cache != NULL) {
@@ -265,8 +272,8 @@ _policy_dir_events (PolKitContext       
  *
  * Returns: #FALSE if @error was set, otherwise #TRUE
  **/
-gboolean
-libpolkit_context_init (PolKitContext *pk_context, GError **error)
+bool
+libpolkit_context_init (PolKitContext *pk_context, PolKitError **error)
 {
         const char *dirname;
 
@@ -373,8 +380,8 @@ libpolkit_context_unref (PolKitContext *
  **/
 void
 libpolkit_context_set_config_changed (PolKitContext                *pk_context, 
-                                      PolKitContextConfigChangedCB cb, 
-                                      gpointer                     user_data)
+                                      PolKitContextConfigChangedCB  cb, 
+                                      void                         *user_data)
 {
         g_return_if_fail (pk_context != NULL);
         pk_context->config_changed_cb = cb;
@@ -414,7 +421,7 @@ libpolkit_context_get_policy_cache (PolK
         g_return_val_if_fail (pk_context != NULL, NULL);
 
         if (pk_context->priv_cache == NULL) {
-                GError *error;
+                PolKitError *error;
 
                 _pk_debug ("Populating cache from directory %s", pk_context->policy_dir);
 
@@ -422,8 +429,8 @@ libpolkit_context_get_policy_cache (PolK
                 pk_context->priv_cache = libpolkit_policy_cache_new (pk_context->policy_dir, &error);
                 if (pk_context->priv_cache == NULL) {
                         g_warning ("Error loading policy files from %s: %s", 
-                                   pk_context->policy_dir, error->message);
-                        g_error_free (error);
+                                   pk_context->policy_dir, polkit_error_get_error_message (error));
+                        polkit_error_free (error);
                 } else {
                         libpolkit_policy_cache_debug (pk_context->priv_cache);
                 }
@@ -459,7 +466,7 @@ libpolkit_context_get_policy_cache (PolK
 PolKitResult
 libpolkit_context_get_seat_resource_association (PolKitContext       *pk_context,
                                                  PolKitSeatVisitorCB  visitor,
-                                                 gpointer            *user_data)
+                                                 void                *user_data)
 {
         return LIBPOLKIT_RESULT_YES;
 }
diff --git a/libpolkit/libpolkit-context.h b/libpolkit/libpolkit-context.h
index 088ec35..b16e598 100644
--- a/libpolkit/libpolkit-context.h
+++ b/libpolkit/libpolkit-context.h
@@ -26,11 +26,7 @@
 #ifndef LIBPOLKIT_CONTEXT_H
 #define LIBPOLKIT_CONTEXT_H
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <glib.h>
-
+#include <stdbool.h>
 #include <libpolkit/libpolkit-error.h>
 #include <libpolkit/libpolkit-result.h>
 #include <libpolkit/libpolkit-context.h>
@@ -63,7 +59,7 @@ typedef struct PolKitContext PolKitConte
  * timeframe.
  */
 typedef void (*PolKitContextConfigChangedCB) (PolKitContext  *pk_context,
-                                              gpointer        user_data);
+                                              void           *user_data);
 
 /**
  * PolKitContextFileMonitorEvent:
@@ -96,7 +92,7 @@ typedef enum
 typedef void (*PolKitContextFileMonitorNotifyFunc) (PolKitContext                 *pk_context,
                                                     PolKitContextFileMonitorEvent  event_mask,
                                                     const char                    *path,
-                                                    gpointer                       user_data);
+                                                    void                          *user_data);
 
 /**
  * PolKitContextFileMonitorAddWatch:
@@ -114,11 +110,11 @@ typedef void (*PolKitContextFileMonitorN
  * be watched. Caller can remove the watch using the supplied function
  * of type #PolKitContextFileMonitorRemoveWatch and the handle.
  */
-typedef guint (*PolKitContextFileMonitorAddWatch) (PolKitContext                     *pk_context,
-                                                   const char                        *path,
-                                                   PolKitContextFileMonitorEvent      event_mask,
-                                                   PolKitContextFileMonitorNotifyFunc notify_cb,
-                                                   gpointer                           user_data);
+typedef int (*PolKitContextFileMonitorAddWatch) (PolKitContext                     *pk_context,
+                                                 const char                        *path,
+                                                 PolKitContextFileMonitorEvent      event_mask,
+                                                 PolKitContextFileMonitorNotifyFunc notify_cb,
+                                                 void                              *user_data);
 
 /**
  * PolKitContextFileMonitorRemoveWatch:
@@ -130,18 +126,18 @@ typedef guint (*PolKitContextFileMonitor
  * type #PolKitContextFileMonitorAddWatch.
  */
 typedef void (*PolKitContextFileMonitorRemoveWatch) (PolKitContext                     *pk_context,
-                                                     guint                              watch_id);
+                                                     int                                watch_id);
 
 
 PolKitContext *libpolkit_context_new                (void);
 void           libpolkit_context_set_config_changed (PolKitContext                        *pk_context, 
                                                      PolKitContextConfigChangedCB          cb, 
-                                                     gpointer                              user_data);
+                                                     void                                 *user_data);
 void           libpolkit_context_set_file_monitor   (PolKitContext                        *pk_context, 
                                                      PolKitContextFileMonitorAddWatch      add_watch_func,
                                                      PolKitContextFileMonitorRemoveWatch   remove_watch_func);
-gboolean       libpolkit_context_init               (PolKitContext                        *pk_context, 
-                                                     GError                              **error);
+bool           libpolkit_context_init               (PolKitContext                        *pk_context, 
+                                                     PolKitError                         **error);
 PolKitContext *libpolkit_context_ref                (PolKitContext                        *pk_context);
 void           libpolkit_context_unref              (PolKitContext                        *pk_context);
 
@@ -157,12 +153,12 @@ PolKitPolicyCache *libpolkit_context_get
  */
 typedef void (*PolKitSeatVisitorCB) (PolKitSeat      *seat,
                                      PolKitResource **resources_associated_with_seat,
-                                     gpointer         user_data);
+                                     void            *user_data);
 
 PolKitResult
 libpolkit_context_get_seat_resource_association (PolKitContext       *pk_context,
                                                  PolKitSeatVisitorCB  visitor,
-                                                 gpointer            *user_data);
+                                                 void                *user_data);
 
 PolKitResult
 libpolkit_context_is_resource_associated_with_seat (PolKitContext   *pk_context,
diff --git a/libpolkit/libpolkit-debug.c b/libpolkit/libpolkit-debug.c
index b4987a5..37a8fb2 100644
--- a/libpolkit/libpolkit-debug.c
+++ b/libpolkit/libpolkit-debug.c
@@ -34,10 +34,12 @@
 #  include <config.h>
 #endif
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <sys/time.h>
+#include <time.h>
 
 #include "libpolkit-debug.h"
 
@@ -51,13 +53,13 @@ void 
 _pk_debug (const char *format, ...)
 {
         va_list args;
-        static gboolean show_debug = FALSE;
-        static gboolean init = FALSE;
+        static bool show_debug = false;
+        static bool init = false;
 
         if (!init) {
-                init = TRUE;
+                init = true;
                 if (getenv ("POLKIT_DEBUG") != NULL) {
-                        show_debug = TRUE;
+                        show_debug = true;
                 }
         }
 
diff --git a/libpolkit/libpolkit-debug.h b/libpolkit/libpolkit-debug.h
index c576f11..d6c51f2 100644
--- a/libpolkit/libpolkit-debug.h
+++ b/libpolkit/libpolkit-debug.h
@@ -26,11 +26,6 @@
 #ifndef LIBPOLKIT_DEBUG_H
 #define LIBPOLKIT_DEBUG_H
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <glib.h>
-
 void _pk_debug (const char *format, ...) __attribute__((__format__ (__printf__, 1, 2)));
 
 #endif /* LIBPOLKIT_DEBUG_H */
diff --git a/libpolkit/libpolkit-error.c b/libpolkit/libpolkit-error.c
index 7e6ed8d..1ca8c4e 100644
--- a/libpolkit/libpolkit-error.c
+++ b/libpolkit/libpolkit-error.c
@@ -34,6 +34,7 @@
 #  include <config.h>
 #endif
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -44,18 +45,96 @@
 #include <errno.h>
 
 #include <glib.h>
+
 #include "libpolkit-error.h"
 
+/**
+ * PolKitError:
+ *
+ * Objects of this class are used for error reporting.
+ **/
+struct PolKitError
+{
+        bool is_static;
+        PolKitErrorCode error_code;
+        char *error_message;
+};
+
+//static PolKitError _oom_error = {true, POLKIT_ERROR_OUT_OF_MEMORY, "Out of memory"};
+
+/**
+ * polkit_error_get_error_code:
+ * @error: the error object
+ * 
+ * Returns the error code.
+ * 
+ * Returns: A value from the #PolKitErrorCode enumeration.
+ **/
+PolKitErrorCode 
+polkit_error_get_error_code (PolKitError *error)
+{
+        g_return_val_if_fail (error != NULL, -1);
+        return error->error_code;
+}
+
+/**
+ * polkit_error_get_error_message:
+ * @error: the error object
+ * 
+ * Get the error message.
+ * 
+ * Returns: A string describing the error. Caller shall not free this string.
+ **/
+const char *
+polkit_error_get_error_message (PolKitError *error)
+{
+        g_return_val_if_fail (error != NULL, NULL);
+        return error->error_message;
+}
 
 /**
- * libpolkit_error_quark:
+ * polkit_error_free:
+ * @error: the error
  * 
- * Returns error domain for PolicyKit library.
+ * Free an error.
+ **/
+void
+polkit_error_free (PolKitError *error)
+{
+        g_return_if_fail (error != NULL);
+        if (!error->is_static) {
+                g_free (error->error_message);
+                g_free (error);
+        }
+}
+
+/**
+ * polkit_error_set_error:
+ * @error: the error object
+ * @error_code: A value from the #PolKitErrorCode enumeration.
+ * @format: printf style formatting string
+ * @Varargs: printf style arguments
  * 
- * Returns: The error domain
+ * Sets an error. If OOM, the error will be set to a pre-allocated OOM error.
  **/
-GQuark
-libpolkit_error_quark (void)
+void
+polkit_error_set_error (PolKitError **error, PolKitErrorCode error_code, const char *format, ...)
 {
-        return g_quark_from_static_string ("libpolkit-error-quark");
+        va_list args;
+        PolKitError *e;
+
+        if (*error == NULL)
+                return;
+
+        e = g_new0 (PolKitError, 1);
+        e->is_static = false;
+        e->error_code = error_code;
+        va_start (args, format);
+        e->error_message = g_strdup_vprintf (format, args);
+        va_end (args);
+
+        *error = e;
 }
+
+
+
diff --git a/libpolkit/libpolkit-error.h b/libpolkit/libpolkit-error.h
index d89eade..eaaf827 100644
--- a/libpolkit/libpolkit-error.h
+++ b/libpolkit/libpolkit-error.h
@@ -1,7 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
 /***************************************************************************
  *
- * libpolkit-error.h : GError error codes from PolicyKit
+ * libpolkit-error.h : error reporting from PolicyKit
  *
  * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
  *
@@ -26,28 +26,25 @@
 #ifndef LIBPOLKIT_ERROR_H
 #define LIBPOLKIT_ERROR_H
 
-#include <glib.h>
-
 /**
- * PolKitError:
+ * PolKitErrorCode:
+ * @POLKIT_ERROR_OUT_OF_MEMORY: Out of memory
  * @POLKIT_ERROR_POLICY_FILE_INVALID: There was an error parsing the given policy file
  *
  * Error codes returned by PolicyKit
  */
 typedef enum
 {      
+        POLKIT_ERROR_OUT_OF_MEMORY,
         POLKIT_ERROR_POLICY_FILE_INVALID
-} PolKitError;
-
-/**
- * POLKIT_ERROR:
- *
- * Error domain for PolicyKit library. Errors in this domain will be
- * from the #PolKitError enumeration. See GError for details.
- **/
-#define POLKIT_ERROR libpolkit_error_quark()
+} PolKitErrorCode;
 
-GQuark libpolkit_error_quark (void);
+struct PolKitError;
+typedef struct PolKitError PolKitError;
 
+PolKitErrorCode  polkit_error_get_error_code (PolKitError *error);
+const char      *polkit_error_get_error_message (PolKitError *error);
+void             polkit_error_free (PolKitError *error);
+void             polkit_error_set_error (PolKitError **error, PolKitErrorCode error_code, const char *format, ...) __attribute__((__format__ (__printf__, 3, 4)));
 
-#endif /* LIBPOLKIT_RESULT_H */
+#endif /* LIBPOLKIT_ERROR_H */
diff --git a/libpolkit/libpolkit-module.c b/libpolkit/libpolkit-module.c
index 9885caa..505a0b7 100644
--- a/libpolkit/libpolkit-module.c
+++ b/libpolkit/libpolkit-module.c
@@ -37,6 +37,8 @@
 #include <regex.h>
 #include <pwd.h>
 #include <grp.h>
+#include <glib.h>
+#include <unistd.h>
 
 #include "libpolkit-debug.h"
 #include "libpolkit-module.h"
@@ -52,7 +54,7 @@ struct PolKitModuleInterface
         void *dlopen_handle;
         char *name;
 
-        gpointer module_user_data;
+        void *module_user_data;
         PolKitModuleControl module_control;
 
         PolKitModuleInitialize                     func_initialize;
@@ -62,7 +64,7 @@ struct PolKitModuleInterface
         PolKitModuleCanSessionAccessResource       func_can_session_access_resource;
         PolKitModuleCanCallerAccessResource        func_can_caller_access_resource;
 
-        gboolean builtin_have_action_regex;
+        bool builtin_have_action_regex;
         regex_t  builtin_action_regex_compiled;
 
         GSList *builtin_users;
@@ -107,13 +109,13 @@ _parse_builtin_remove_option (int *argc,
         (*argc)--;
 }
 
-static gboolean
+static bool
 _parse_builtin (PolKitModuleInterface *mi, int *argc, char *argv[])
 {
         int n;
-        gboolean ret;
+        bool ret;
 
-        ret = FALSE;
+        ret = false;
 
         for (n = 1; n < *argc; ) {
                 if (g_str_has_prefix (argv[n], "action=")) {
@@ -129,7 +131,7 @@ _parse_builtin (PolKitModuleInterface *m
                                 _pk_debug ("Regex '%s' didn't compile", regex);
                                 goto error;
                         }
-                        mi->builtin_have_action_regex = TRUE;
+                        mi->builtin_have_action_regex = true;
 
                         _pk_debug ("Compiled regex '%s' for option 'action=' OK", regex);
 
@@ -163,7 +165,7 @@ _parse_builtin (PolKitModuleInterface *m
                 }
         }
 
-        ret = TRUE;
+        ret = true;
 
 error:
         return ret;
@@ -185,7 +187,7 @@ libpolkit_module_interface_load_module (
 {
         void *handle;
         PolKitModuleInterface *mi;
-        gboolean (*func) (PolKitModuleInterface *);
+        bool (*func) (PolKitModuleInterface *);
 
         mi = NULL;
 
@@ -554,12 +556,12 @@ libpolkit_module_control_to_string_repre
  * 
  * Returns: TRUE if the textual representation was valid, otherwise FALSE
  **/
-gboolean
+bool
 libpolkit_module_control_from_string_representation (const char *string, PolKitModuleControl *out_module_control)
 {
         int n;
 
-        g_return_val_if_fail (out_module_control != NULL, FALSE);
+        g_return_val_if_fail (out_module_control != NULL, false);
 
         for (n = 0; n < LIBPOLKIT_MODULE_CONTROL_N_CONTROLS; n++) {
                 if (mapping[n].str == NULL)
@@ -570,9 +572,9 @@ libpolkit_module_control_from_string_rep
                 }
         }
 
-        return FALSE;
+        return false;
 found:
-        return TRUE;
+        return true;
 }
 
 
@@ -586,7 +588,7 @@ found:
  * instantiated at the same time.
  **/
 void
-libpolkit_module_set_user_data (PolKitModuleInterface *module_interface, gpointer user_data)
+libpolkit_module_set_user_data (PolKitModuleInterface *module_interface, void *user_data)
 {
         g_return_if_fail (module_interface != NULL);
         module_interface->module_user_data = user_data;
@@ -600,30 +602,30 @@ libpolkit_module_set_user_data (PolKitMo
  * 
  * Returns: The user data set with libpolkit_module_set_user_data()
  **/
-gpointer
+void *
 libpolkit_module_get_user_data   (PolKitModuleInterface *module_interface)
 {
         g_return_val_if_fail (module_interface != NULL, NULL);
         return module_interface->module_user_data;
 }
 
-static gboolean 
+static bool 
 _check_action (PolKitModuleInterface *module_interface, PolKitAction *action)
 {
-        gboolean ret;
+        bool ret;
 
-        ret = FALSE;
+        ret = false;
 
         if (module_interface->builtin_have_action_regex) {
                 char *action_name;
                 if (libpolkit_action_get_action_id (action, &action_name)) {
                         if (regexec (&module_interface->builtin_action_regex_compiled, 
                                      action_name, 0, NULL, 0) == 0) {
-                                ret = TRUE;
+                                ret = true;
                         }
                 }
         } else {
-                ret = TRUE;
+                ret = true;
         }
 
         return ret;
@@ -631,7 +633,7 @@ _check_action (PolKitModuleInterface *mo
 
 /*----*/
 
-static gboolean
+static bool
 _check_uid_in_list (GSList *list, uid_t given_uid)
 {
         GSList *i;
@@ -639,36 +641,36 @@ _check_uid_in_list (GSList *list, uid_t 
         for (i = list; i != NULL; i = g_slist_next (i)) {
                 uid_t uid = GPOINTER_TO_INT (i->data);
                 if (given_uid == uid)
-                        return TRUE;                
+                        return true;                
         }
-        return FALSE;
+        return false;
 }
 
-static gboolean
+static bool
 _check_users_for_session (PolKitModuleInterface *module_interface, PolKitSession *session)
 {
         uid_t uid;
         GSList *list;
         if ((list = module_interface->builtin_users) == NULL)
-                return TRUE;
+                return true;
         if (session == NULL)
-                return FALSE;
+                return false;
         if (!libpolkit_session_get_uid (session, &uid))
-                return FALSE;
+                return false;
         return _check_uid_in_list (list, uid);
 }
 
-static gboolean
+static bool
 _check_users_for_caller (PolKitModuleInterface *module_interface, PolKitCaller *caller)
 {
         uid_t uid;
         GSList *list;
         if ((list = module_interface->builtin_users) == NULL)
-                return TRUE;
+                return true;
         if (caller == NULL)
-                return FALSE;
+                return false;
         if (!libpolkit_caller_get_uid (caller, &uid))
-                return FALSE;
+                return false;
         return _check_uid_in_list (list, uid);
 }
 
@@ -686,15 +688,15 @@ _check_users_for_caller (PolKitModuleInt
  * 
  * Returns: TRUE if, and only if, the module is confined from handling the request
  **/
-gboolean
+bool
 libpolkit_module_interface_check_builtin_confinement_for_session (PolKitModuleInterface *module_interface,
                                                                   PolKitContext   *pk_context,
                                                                   PolKitAction *action,
                                                                   PolKitResource  *resource,
                                                                   PolKitSession   *session)
 {
-        gboolean ret;
-        ret = TRUE;
+        bool ret;
+        ret = true;
 
         g_return_val_if_fail (module_interface != NULL, ret);
 
@@ -704,7 +706,7 @@ libpolkit_module_interface_check_builtin
                 goto out;
 
         /* not confined */
-        ret = FALSE;
+        ret = false;
 out:
         return ret;
 }
@@ -722,15 +724,15 @@ out:
  * 
  * Returns: TRUE if, and only if, the module is confined from handling the request
  **/
-gboolean
+bool
 libpolkit_module_interface_check_builtin_confinement_for_caller (PolKitModuleInterface *module_interface,
                                                                  PolKitContext   *pk_context,
                                                                  PolKitAction *action,
                                                                  PolKitResource  *resource,
                                                                  PolKitCaller    *caller)
 {
-        gboolean ret;
-        ret = TRUE;
+        bool ret;
+        ret = true;
 
         g_return_val_if_fail (module_interface != NULL, ret);
 
@@ -740,7 +742,7 @@ libpolkit_module_interface_check_builtin
                 goto out;
 
         /* not confined */
-        ret = FALSE;
+        ret = false;
 out:
         return ret;
 }
diff --git a/libpolkit/libpolkit-module.h b/libpolkit/libpolkit-module.h
index 7f79e4f..7088491 100644
--- a/libpolkit/libpolkit-module.h
+++ b/libpolkit/libpolkit-module.h
@@ -26,11 +26,7 @@
 #ifndef LIBPOLKIT_MODULE_H
 #define LIBPOLKIT_MODULE_H
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <glib.h>
-
+#include <stdbool.h>
 #include <libpolkit/libpolkit.h>
 
 struct PolKitModuleInterface;
@@ -46,7 +42,7 @@ typedef struct PolKitModuleInterface Pol
  *
  * Returns: Whether the module was initialized.
  **/
-typedef gboolean (*PolKitModuleInitialize) (PolKitModuleInterface *module_interface, 
+typedef bool     (*PolKitModuleInitialize) (PolKitModuleInterface *module_interface, 
                                             int                    argc, 
                                             char                  *argv[]);
 
@@ -72,7 +68,7 @@ typedef void (*PolKitModuleShutdown) (Po
 typedef PolKitResult (*PolKitModuleGetSeatResourceAssociation) (PolKitModuleInterface *module_interface,
                                                                 PolKitContext         *pk_context,
                                                                 PolKitSeatVisitorCB    visitor,
-                                                                gpointer              *user_data);
+                                                                void                  *user_data);
 
 /**
  * PolKitModuleIsResourceAssociatedWithSeat:
@@ -131,8 +127,8 @@ PolKitModuleInterface *libpolkit_module_
 void                   libpolkit_module_interface_unref (PolKitModuleInterface *module_interface);
 const char            *libpolkit_module_get_name        (PolKitModuleInterface *module_interface);
 
-void                   libpolkit_module_set_user_data   (PolKitModuleInterface *module_interface, gpointer user_data);
-gpointer               libpolkit_module_get_user_data   (PolKitModuleInterface *module_interface);
+void                   libpolkit_module_set_user_data   (PolKitModuleInterface *module_interface, void *user_data);
+void                  *libpolkit_module_get_user_data   (PolKitModuleInterface *module_interface);
 
 void libpolkit_module_set_func_initialize                       (PolKitModuleInterface               *module_interface, 
                                                                  PolKitModuleInitialize               func);
@@ -180,7 +176,7 @@ typedef enum
 const char *
 libpolkit_module_control_to_string_representation (PolKitModuleControl module_control);
 
-gboolean
+bool
 libpolkit_module_control_from_string_representation (const char *string, PolKitModuleControl *out_module_control);
 
 PolKitModuleInterface *libpolkit_module_interface_load_module (const char *name, 
@@ -190,14 +186,14 @@ PolKitModuleInterface *libpolkit_module_
 PolKitModuleControl libpolkit_module_interface_get_control (PolKitModuleInterface *module_interface);
 
 
-gboolean
+bool
 libpolkit_module_interface_check_builtin_confinement_for_session (PolKitModuleInterface *module_interface,
                                                                   PolKitContext   *pk_context,
                                                                   PolKitAction *action,
                                                                   PolKitResource  *resource,
                                                                   PolKitSession   *session);
 
-gboolean
+bool
 libpolkit_module_interface_check_builtin_confinement_for_caller (PolKitModuleInterface *module_interface,
                                                                  PolKitContext   *pk_context,
                                                                  PolKitAction *action,
diff --git a/libpolkit/libpolkit-policy-cache.c b/libpolkit/libpolkit-policy-cache.c
index a2c8d4a..f5549d0 100644
--- a/libpolkit/libpolkit-policy-cache.c
+++ b/libpolkit/libpolkit-policy-cache.c
@@ -64,20 +64,14 @@ struct PolKitPolicyCache
 
 
 static void
-add_entries_from_file (PolKitPolicyCache *policy_cache,
-                       PolKitPolicyFile  *policy_file)
+_append_entry (PolKitPolicyFile       *policy_file,
+               PolKitPolicyFileEntry  *policy_file_entry,
+               void                   *user_data)
 {
-        GSList *i;
-
-        g_return_if_fail (policy_cache != NULL);
-        g_return_if_fail (policy_file != NULL);
+        PolKitPolicyCache *policy_cache = user_data;
 
-        for (i = libpolkit_policy_file_get_entries (policy_file); i != NULL; i = g_slist_next (i)) {
-                PolKitPolicyFileEntry  *policy_file_entry = i->data;
-                libpolkit_policy_file_entry_ref (policy_file_entry);
-                policy_cache->priv_entries = g_slist_append (policy_cache->priv_entries, 
-                                                                policy_file_entry);
-        }
+        libpolkit_policy_file_entry_ref (policy_file_entry);
+        policy_cache->priv_entries = g_slist_append (policy_cache->priv_entries, policy_file_entry);
 }
 
 /**
@@ -90,17 +84,24 @@ add_entries_from_file (PolKitPolicyCache
  * Returns: #NULL if @error was set, otherwise the #PolKitPolicyCache object
  **/
 PolKitPolicyCache *
-libpolkit_policy_cache_new (const char *dirname, GError **error)
+libpolkit_policy_cache_new (const char *dirname, PolKitError **error)
 {
         const char *file;
         GDir *dir;
         PolKitPolicyCache *pc;
+        GError *g_error;
 
         pc = g_new0 (PolKitPolicyCache, 1);
         pc->refcount = 1;
 
-        dir = g_dir_open (dirname, 0, error);
+        g_error = NULL;
+        dir = g_dir_open (dirname, 0, &g_error);
         if (dir == NULL) {
+                polkit_error_set_error (error, POLKIT_ERROR_POLICY_FILE_INVALID,
+                                        "Cannot load policy files from directory %s: %s",
+                                        dirname,
+                                        g_error->message);
+                g_error_free (g_error);
                 goto out;
         }
         while ((file = g_dir_read_name (dir)) != NULL) {
@@ -123,7 +124,8 @@ libpolkit_policy_cache_new (const char *
                         goto out;
                 }
 
-                add_entries_from_file (pc, pf);
+                /* steal entries */
+                libpolkit_policy_file_entry_foreach (pf, _append_entry, pc);
                 libpolkit_policy_file_unref (pf);
         }
         g_dir_close (dir);
diff --git a/libpolkit/libpolkit-policy-cache.h b/libpolkit/libpolkit-policy-cache.h
index 72b626c..92378a7 100644
--- a/libpolkit/libpolkit-policy-cache.h
+++ b/libpolkit/libpolkit-policy-cache.h
@@ -26,18 +26,14 @@
 #ifndef LIBPOLKIT_POLICY_CACHE_H
 #define LIBPOLKIT_POLICY_CACHE_H
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <glib.h>
-
+#include <libpolkit/libpolkit-error.h>
 #include <libpolkit/libpolkit-action.h>
 #include <libpolkit/libpolkit-policy-file-entry.h>
 
 struct PolKitPolicyCache;
 typedef struct PolKitPolicyCache PolKitPolicyCache;
 
-PolKitPolicyCache *libpolkit_policy_cache_new                   (const char *dirname, GError **error);
+PolKitPolicyCache *libpolkit_policy_cache_new                   (const char *dirname, PolKitError **error);
 PolKitPolicyCache *libpolkit_policy_cache_ref                   (PolKitPolicyCache *policy_cache);
 void               libpolkit_policy_cache_unref                 (PolKitPolicyCache *policy_cache);
 void               libpolkit_policy_cache_debug                 (PolKitPolicyCache *policy_cache);
diff --git a/libpolkit/libpolkit-policy-default.c b/libpolkit/libpolkit-policy-default.c
index 3edde5f..852c3aa 100644
--- a/libpolkit/libpolkit-policy-default.c
+++ b/libpolkit/libpolkit-policy-default.c
@@ -64,7 +64,7 @@ struct PolKitPolicyDefault
 };
 
 static gboolean
-parse_default (const char *key, char *s, const char *group, PolKitResult* target, GError **error)
+parse_default (const char *key, char *s, const char *group, PolKitResult* target, PolKitError **error)
 {
         gboolean ret;
 
@@ -86,14 +86,14 @@ parse_default (const char *key, char *s,
                 }
                 s2 = g_string_free (str, FALSE);
 
-                g_set_error (error, 
-                             POLKIT_ERROR, 
-                             POLKIT_ERROR_POLICY_FILE_INVALID,
-                             "Value '%s' is not allowed for key '%s' in group '%s' - supported values are: %s", 
-                             s, 
-                             key,
-                             group,
-                             s2);
+                polkit_error_set_error (error, 
+                                        POLKIT_ERROR_POLICY_FILE_INVALID,
+                                        "Value '%s' is not allowed for key '%s' in group '%s'; "
+                                        "supported values are: %s", 
+                                        s, 
+                                        key,
+                                        group,
+                                        s2);
                 g_free (s2);
         }
         
@@ -101,24 +101,17 @@ parse_default (const char *key, char *s,
         return ret;
 }
 
-/**
- * libpolkit_policy_default_new:
- * @key_file: a #GKeyFile object
- * @action: action to look up defaults for in key_file
- * @error: return location for error
- * 
- * Create a new #PolKitPolicyDefault object.
- * 
- * Returns: the new object or #NULL if error is set
- **/
+extern PolKitPolicyDefault *_libpolkit_policy_default_new (GKeyFile *key_file, const char *action, PolKitError **error);
+
 PolKitPolicyDefault *
-libpolkit_policy_default_new (GKeyFile *key_file, const char *action, GError **error)
+_libpolkit_policy_default_new (GKeyFile *key_file, const char *action, PolKitError **error)
 {
         const char *key;
         const char *group;
         char *s;
         char buf[256];
         PolKitPolicyDefault *pd;
+        GError *g_error;
 
         pd = g_new0 (PolKitPolicyDefault, 1);
         pd->refcount = 1;
@@ -126,29 +119,37 @@ libpolkit_policy_default_new (GKeyFile *
         g_snprintf (buf, sizeof (buf), "Action %s", action);
         group = buf;
 
+        g_error = NULL;
         key = "AllowRemoteInactive";
-        if ((s = g_key_file_get_string (key_file, group, key, error)) == NULL)
+        if ((s = g_key_file_get_string (key_file, group, key, &g_error)) == NULL)
                 goto error;
         if (!parse_default (key, s, group, &pd->default_remote_inactive, error))
                 goto error;
         key = "AllowRemoteActive";
-        if ((s = g_key_file_get_string (key_file, group, key, error)) == NULL)
+        if ((s = g_key_file_get_string (key_file, group, key, &g_error)) == NULL)
                 goto error;
         if (!parse_default (key, s, group, &pd->default_remote_active, error))
                 goto error;
         key = "AllowLocalInactive";
-        if ((s = g_key_file_get_string (key_file, group, key, error)) == NULL)
+        if ((s = g_key_file_get_string (key_file, group, key, &g_error)) == NULL)
                 goto error;
         if (!parse_default (key, s, group, &pd->default_local_inactive, error))
                 goto error;
         key = "AllowLocalActive";
-        if ((s = g_key_file_get_string (key_file, group, key, error)) == NULL)
+        if ((s = g_key_file_get_string (key_file, group, key, &g_error)) == NULL)
                 goto error;
         if (!parse_default (key, s, group, &pd->default_local_active, error))
                 goto error;
 
         return pd;
 error:
+        if (g_error != NULL) {
+                polkit_error_set_error (error, POLKIT_ERROR_POLICY_FILE_INVALID,
+                                        "Missing key in policy file: %s",
+                                        g_error->message);
+                g_error_free (g_error);
+        }
+
         if (pd != NULL)
                 libpolkit_policy_default_ref (pd);
         return NULL;
@@ -231,8 +232,8 @@ libpolkit_policy_default_can_session_acc
                                                          PolKitResource         *resource,
                                                          PolKitSession          *session)
 {
-        gboolean is_local;
-        gboolean is_active;
+        bool is_local;
+        bool is_active;
         PolKitResult ret;
 
         ret = LIBPOLKIT_RESULT_NO;
@@ -283,8 +284,8 @@ libpolkit_policy_default_can_caller_acce
                                                         PolKitResource         *resource,
                                                         PolKitCaller           *caller)
 {
-        gboolean is_local;
-        gboolean is_active;
+        bool is_local;
+        bool is_active;
         PolKitSession *session;
         PolKitResult ret;
 
diff --git a/libpolkit/libpolkit-policy-default.h b/libpolkit/libpolkit-policy-default.h
index 6db6c62..9daaee1 100644
--- a/libpolkit/libpolkit-policy-default.h
+++ b/libpolkit/libpolkit-policy-default.h
@@ -26,22 +26,17 @@
 #ifndef LIBPOLKIT_POLICY_DEFAULT_H
 #define LIBPOLKIT_POLICY_DEFAULT_H
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <glib.h>
-
 #include <libpolkit/libpolkit-result.h>
 #include <libpolkit/libpolkit-action.h>
 #include <libpolkit/libpolkit-resource.h>
 #include <libpolkit/libpolkit-session.h>
 #include <libpolkit/libpolkit-caller.h>
+#include <libpolkit/libpolkit-error.h>
 
 struct PolKitPolicyDefault;
 typedef struct PolKitPolicyDefault PolKitPolicyDefault;
 
-PolKitPolicyDefault *libpolkit_policy_default_new   (GKeyFile *key_file, const char *action, GError **error);
-PolKitPolicyDefault *libpolkit_policy_default_ref   (PolKitPolicyDefault *policy_default);
+PolKitPolicyDefault    *libpolkit_policy_default_ref   (PolKitPolicyDefault *policy_default);
 void                    libpolkit_policy_default_unref (PolKitPolicyDefault *policy_default);
 void                    libpolkit_policy_default_debug (PolKitPolicyDefault *policy_default);
 
diff --git a/libpolkit/libpolkit-policy-file-entry.c b/libpolkit/libpolkit-policy-file-entry.c
index 5a042cb..e07f46e 100644
--- a/libpolkit/libpolkit-policy-file-entry.c
+++ b/libpolkit/libpolkit-policy-file-entry.c
@@ -62,20 +62,13 @@ struct PolKitPolicyFileEntry
         PolKitPolicyDefault *defaults;
 };
 
-/**
- * libpolkit_policy_file_entry_new:
- * @key_file: a #GKeyFile object
- * @action: action to look for in key_file
- * @error: return location for error
- * 
- * Create a new #PolKitPolicyFileEntry object. If the given
- * @key_file object does not contain the requisite sections, a human
- * readable explanation of why will be set in @error.
- * 
- * Returns: the new object or #NULL if error is set
- **/
 PolKitPolicyFileEntry *
-libpolkit_policy_file_entry_new (GKeyFile *key_file, const char *action, GError **error)
+_libpolkit_policy_file_entry_new (GKeyFile *key_file, const char *action, PolKitError **error);
+
+extern PolKitPolicyDefault *_libpolkit_policy_default_new (GKeyFile *key_file, const char *action, PolKitError **error);
+
+extern PolKitPolicyFileEntry *
+_libpolkit_policy_file_entry_new (GKeyFile *key_file, const char *action, PolKitError **error)
 {
         PolKitPolicyFileEntry *pfe;
 
@@ -83,7 +76,7 @@ libpolkit_policy_file_entry_new (GKeyFil
         pfe->refcount = 1;
         pfe->action = g_strdup (action);
 
-        pfe->defaults = libpolkit_policy_default_new (key_file, action, error);
+        pfe->defaults = _libpolkit_policy_default_new (key_file, action, error);
         if (pfe->defaults == NULL)
                 goto error;
 
diff --git a/libpolkit/libpolkit-policy-file-entry.h b/libpolkit/libpolkit-policy-file-entry.h
index f183c06..1d76f83 100644
--- a/libpolkit/libpolkit-policy-file-entry.h
+++ b/libpolkit/libpolkit-policy-file-entry.h
@@ -26,18 +26,12 @@
 #ifndef LIBPOLKIT_POLICY_FILE_ENTRY_H
 #define LIBPOLKIT_POLICY_FILE_ENTRY_H
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <glib.h>
-
 #include <libpolkit/libpolkit-result.h>
 #include <libpolkit/libpolkit-policy-default.h>
 
 struct PolKitPolicyFileEntry;
 typedef struct PolKitPolicyFileEntry PolKitPolicyFileEntry;
 
-PolKitPolicyFileEntry *libpolkit_policy_file_entry_new   (GKeyFile *key_file, const char *action, GError **error);
 PolKitPolicyFileEntry *libpolkit_policy_file_entry_ref   (PolKitPolicyFileEntry *policy_file_entry);
 void                   libpolkit_policy_file_entry_unref (PolKitPolicyFileEntry *policy_file_entry);
 void                   libpolkit_policy_file_entry_debug (PolKitPolicyFileEntry *policy_file_entry);
diff --git a/libpolkit/libpolkit-policy-file.c b/libpolkit/libpolkit-policy-file.c
index b739166..57b6bf8 100644
--- a/libpolkit/libpolkit-policy-file.c
+++ b/libpolkit/libpolkit-policy-file.c
@@ -40,10 +40,11 @@
 #include "libpolkit-error.h"
 #include "libpolkit-result.h"
 #include "libpolkit-policy-file.h"
+#include "libpolkit-policy-file-entry.h"
 
 /**
  * SECTION:libpolkit-policy-file
- * @short_description: Policys files.
+ * @short_description: Policy files.
  *
  * This class is used to represent a policy files.
  **/
@@ -60,6 +61,10 @@ struct PolKitPolicyFile
         GSList *entries;
 };
 
+extern PolKitPolicyFileEntry *_libpolkit_policy_file_entry_new   (GKeyFile *keyfile, 
+                                                                  const char *action, 
+                                                                  PolKitError **error);
+
 /**
  * libpolkit_policy_file_new:
  * @path: path to policy file
@@ -72,29 +77,36 @@ struct PolKitPolicyFile
  * Returns: the new object or #NULL if error is set
  **/
 PolKitPolicyFile *
-libpolkit_policy_file_new (const char *path, GError **error)
+libpolkit_policy_file_new (const char *path, PolKitError **error)
 {
         GKeyFile *key_file;
         PolKitPolicyFile *pf;
         char **groups;
         gsize groups_len;
         int n;
+        GError *g_error;
 
         pf = NULL;
         key_file = NULL;
         groups = NULL;
 
         if (!g_str_has_suffix (path, ".policy")) {
-                g_set_error (error, 
-                             POLKIT_ERROR, 
-                             POLKIT_ERROR_POLICY_FILE_INVALID,
-                             "Policy files must have extension .policy");
+                polkit_error_set_error (error, 
+                                        POLKIT_ERROR_POLICY_FILE_INVALID,
+                                        "Policy files must have extension .policy; file '%s' doesn't", path);
                 goto error;
         }
 
+        g_error = NULL;
         key_file = g_key_file_new ();
-        if (!g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, error))
+        if (!g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, &g_error)) {
+                polkit_error_set_error (error, POLKIT_ERROR_POLICY_FILE_INVALID,
+                                        "Cannot load PolicyKit policy file at '%s': %s",
+                                        path,
+                                        g_error->message);
+                g_error_free (g_error);
                 goto error;
+        }
 
         pf = g_new0 (PolKitPolicyFile, 1);
         pf->refcount = 1;
@@ -108,23 +120,21 @@ libpolkit_policy_file_new (const char *p
                 PolKitPolicyFileEntry *pfe;
 
                 if (!g_str_has_prefix (groups[n], "Action ")) {
-                        g_set_error (error, 
-                                     POLKIT_ERROR, 
-                                     POLKIT_ERROR_POLICY_FILE_INVALID,
-                                     "Unknown group of name '%s'", groups[n]);
+                        polkit_error_set_error (error, 
+                                                POLKIT_ERROR_POLICY_FILE_INVALID,
+                                                "Unknown group of name '%s'", groups[n]);
                         goto error;
                 }
 
                 action = groups[n] + 7; /* "Action " */
                 if (strlen (action) == 0) {
-                        g_set_error (error, 
-                                     POLKIT_ERROR, 
-                                     POLKIT_ERROR_POLICY_FILE_INVALID,
-                                     "Zero-length action name");
+                        polkit_error_set_error (error, 
+                                                POLKIT_ERROR_POLICY_FILE_INVALID,
+                                                "Zero-length action name");
                         goto error;
                 }
 
-                pfe = libpolkit_policy_file_entry_new (key_file, action, error);
+                pfe = _libpolkit_policy_file_entry_new (key_file, action, error);
                 if (pfe == NULL)
                         goto error;
                 pf->entries = g_slist_prepend (pf->entries, pfe);
@@ -184,17 +194,25 @@ libpolkit_policy_file_unref (PolKitPolic
 }
 
 /**
- * libpolkit_policy_file_get_entries:
+ * libpolkit_policy_file_entry_foreach:
  * @policy_file: the policy file object
+ * @cb: callback to invoke for each entry
+ * @user_data: user data
  * 
- * Get the entries stemming from the given file.
- * 
- * Returns: A #GSList of the entries.
+ * Visits all entries in a policy file.
  **/
-GSList *
-libpolkit_policy_file_get_entries (PolKitPolicyFile *policy_file)
+void
+libpolkit_policy_file_entry_foreach (PolKitPolicyFile                 *policy_file,
+                                     PolKitPolicyFileEntryForeachFunc  cb,
+                                     void                              *user_data)
 {
-        g_return_val_if_fail (policy_file != NULL, NULL);
-        return policy_file->entries;
-}
+        GSList *i;
 
+        g_return_if_fail (policy_file != NULL);
+        g_return_if_fail (cb != NULL);
+
+        for (i = policy_file->entries; i != NULL; i = g_slist_next (i)) {
+                PolKitPolicyFileEntry *pfe = i->data;
+                cb (policy_file, pfe, user_data);
+        }
+}
diff --git a/libpolkit/libpolkit-policy-file.h b/libpolkit/libpolkit-policy-file.h
index b77db76..b09f508 100644
--- a/libpolkit/libpolkit-policy-file.h
+++ b/libpolkit/libpolkit-policy-file.h
@@ -26,20 +26,30 @@
 #ifndef LIBPOLKIT_POLICY_FILE_H
 #define LIBPOLKIT_POLICY_FILE_H
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <glib.h>
-
+#include <libpolkit/libpolkit-error.h>
 #include <libpolkit/libpolkit-policy-file-entry.h>
 
 struct PolKitPolicyFile;
 typedef struct PolKitPolicyFile PolKitPolicyFile;
 
-PolKitPolicyFile *libpolkit_policy_file_new         (const char          *path, GError **error);
-PolKitPolicyFile *libpolkit_policy_file_ref         (PolKitPolicyFile *policy_file);
-GSList           *libpolkit_policy_file_get_entries (PolKitPolicyFile *policy_file);
-void              libpolkit_policy_file_unref       (PolKitPolicyFile *policy_file);
+/**
+ * PolKitPolicyFileEntryForeachFunc:
+ * @policy_file: the policy file
+ * @policy_file_entry: the entry
+ * @user_data: user data
+ *
+ * Type for function used in libpolkit_policy_file_entry_foreach().
+ **/
+typedef void (*PolKitPolicyFileEntryForeachFunc) (PolKitPolicyFile      *policy_file, 
+                                                  PolKitPolicyFileEntry *policy_file_entry,
+                                                  void                  *user_data);
+
+PolKitPolicyFile *libpolkit_policy_file_new           (const char       *path, PolKitError **error);
+PolKitPolicyFile *libpolkit_policy_file_ref           (PolKitPolicyFile *policy_file);
+void              libpolkit_policy_file_unref         (PolKitPolicyFile *policy_file);
+void              libpolkit_policy_file_entry_foreach (PolKitPolicyFile                 *policy_file,
+                                                       PolKitPolicyFileEntryForeachFunc  cb,
+                                                       void                              *user_data);
 
 #endif /* LIBPOLKIT_POLICY_FILE_H */
 
diff --git a/libpolkit/libpolkit-resource.c b/libpolkit/libpolkit-resource.c
index 24d4ff1..f401eb1 100644
--- a/libpolkit/libpolkit-resource.c
+++ b/libpolkit/libpolkit-resource.c
@@ -159,7 +159,7 @@ libpolkit_resource_set_resource_id (PolK
  * 
  * Returns: TRUE iff the value was returned.
  **/
-gboolean
+bool
 libpolkit_resource_get_resource_type (PolKitResource *resource, char **out_resource_type)
 {
         g_return_val_if_fail (resource != NULL, FALSE);
@@ -181,7 +181,7 @@ libpolkit_resource_get_resource_type (Po
  * 
  * Returns: TRUE iff the value was returned.
  **/
-gboolean 
+bool
 libpolkit_resource_get_resource_id (PolKitResource *resource, char **out_resource_id)
 {
         g_return_val_if_fail (resource != NULL, FALSE);
diff --git a/libpolkit/libpolkit-resource.h b/libpolkit/libpolkit-resource.h
index f50b7db..e050b86 100644
--- a/libpolkit/libpolkit-resource.h
+++ b/libpolkit/libpolkit-resource.h
@@ -26,10 +26,7 @@
 #ifndef LIBPOLKIT_RESOURCE_H
 #define LIBPOLKIT_RESOURCE_H
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <glib.h>
+#include <stdbool.h>
 
 struct PolKitResource;
 typedef struct PolKitResource PolKitResource;
@@ -39,8 +36,8 @@ PolKitResource *libpolkit_resource_ref  
 void            libpolkit_resource_unref             (PolKitResource *resource);
 void            libpolkit_resource_set_resource_type (PolKitResource *resource, const char  *resource_type);
 void            libpolkit_resource_set_resource_id   (PolKitResource *resource, const char  *resource_id);
-gboolean        libpolkit_resource_get_resource_type (PolKitResource *resource, char       **out_resource_type);
-gboolean        libpolkit_resource_get_resource_id   (PolKitResource *resource, char       **out_resource_id);
+bool            libpolkit_resource_get_resource_type (PolKitResource *resource, char       **out_resource_type);
+bool            libpolkit_resource_get_resource_id   (PolKitResource *resource, char       **out_resource_id);
 
 void            libpolkit_resource_debug             (PolKitResource *resource);
 
diff --git a/libpolkit/libpolkit-result.c b/libpolkit/libpolkit-result.c
index 2c81113..393c96d 100644
--- a/libpolkit/libpolkit-result.c
+++ b/libpolkit/libpolkit-result.c
@@ -94,7 +94,7 @@ libpolkit_result_to_string_representatio
  * 
  * Returns: TRUE if the textual representation was valid, otherwise FALSE
  **/
-gboolean
+bool
 libpolkit_result_from_string_representation (const char *string, PolKitResult *out_result)
 {
         int n;
@@ -110,7 +110,7 @@ libpolkit_result_from_string_representat
                 }
         }
 
-        return FALSE;
+        return false;
 found:
-        return TRUE;
+        return true;
 }
diff --git a/libpolkit/libpolkit-result.h b/libpolkit/libpolkit-result.h
index d4c5e3c..bb76b9b 100644
--- a/libpolkit/libpolkit-result.h
+++ b/libpolkit/libpolkit-result.h
@@ -26,7 +26,7 @@
 #ifndef LIBPOLKIT_RESULT_H
 #define LIBPOLKIT_RESULT_H
 
-#include <glib.h>
+#include <stdbool.h>
 
 /**
  * PolKitResult:
@@ -71,7 +71,7 @@ typedef enum
 const char *
 libpolkit_result_to_string_representation (PolKitResult result);
 
-gboolean
+bool
 libpolkit_result_from_string_representation (const char *string, PolKitResult *out_result);
 
 #endif /* LIBPOLKIT_RESULT_H */
diff --git a/libpolkit/libpolkit-seat.c b/libpolkit/libpolkit-seat.c
index aeb0aa3..0af95dc 100644
--- a/libpolkit/libpolkit-seat.c
+++ b/libpolkit/libpolkit-seat.c
@@ -135,13 +135,13 @@ libpolkit_seat_set_ck_objref (PolKitSeat
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
+bool
 libpolkit_seat_get_ck_objref (PolKitSeat *seat, char **out_ck_objref)
 {
-        g_return_val_if_fail (seat != NULL, FALSE);
-        g_return_val_if_fail (out_ck_objref != NULL, FALSE);
+        g_return_val_if_fail (seat != NULL, false);
+        g_return_val_if_fail (out_ck_objref != NULL, false);
         *out_ck_objref = seat->ck_objref;
-        return TRUE;
+        return true;
 }
 
 /**
diff --git a/libpolkit/libpolkit-seat.h b/libpolkit/libpolkit-seat.h
index 86f1bc7..046f9f6 100644
--- a/libpolkit/libpolkit-seat.h
+++ b/libpolkit/libpolkit-seat.h
@@ -26,10 +26,7 @@
 #ifndef LIBPOLKIT_SEAT_H
 #define LIBPOLKIT_SEAT_H
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <glib.h>
+#include <stdbool.h>
 
 struct PolKitSeat;
 typedef struct PolKitSeat PolKitSeat;
@@ -38,7 +35,7 @@ PolKitSeat *libpolkit_seat_new          
 PolKitSeat *libpolkit_seat_ref           (PolKitSeat *seat);
 void        libpolkit_seat_unref         (PolKitSeat *seat);
 void        libpolkit_seat_set_ck_objref (PolKitSeat *seat, const char  *ck_objref);
-gboolean    libpolkit_seat_get_ck_objref (PolKitSeat *seat, char       **out_ck_objref);
+bool        libpolkit_seat_get_ck_objref (PolKitSeat *seat, char       **out_ck_objref);
 
 void        libpolkit_seat_debug         (PolKitSeat *seat);
 
diff --git a/libpolkit/libpolkit-session.c b/libpolkit/libpolkit-session.c
index 9e758bb..a5d0a9f 100644
--- a/libpolkit/libpolkit-session.c
+++ b/libpolkit/libpolkit-session.c
@@ -60,8 +60,8 @@ struct PolKitSession
         uid_t uid;
         PolKitSeat *seat;
         char *ck_objref;
-        gboolean is_active;
-        gboolean is_local;
+        bool is_active;
+        bool is_local;
         char *remote_host;
 };
 
@@ -158,7 +158,7 @@ libpolkit_session_set_ck_objref (PolKitS
  * Set whether ConsoleKit regard the session as active.
  **/
 void 
-libpolkit_session_set_ck_is_active (PolKitSession *session, gboolean is_active)
+libpolkit_session_set_ck_is_active (PolKitSession *session, bool is_active)
 {
         g_return_if_fail (session != NULL);
         session->is_active = is_active;
@@ -172,7 +172,7 @@ libpolkit_session_set_ck_is_active (PolK
  * Set whether ConsoleKit regard the session as local.
  **/
 void 
-libpolkit_session_set_ck_is_local (PolKitSession *session, gboolean is_local)
+libpolkit_session_set_ck_is_local (PolKitSession *session, bool is_local)
 {
         g_return_if_fail (session != NULL);
         session->is_local = is_local;
@@ -224,7 +224,7 @@ libpolkit_session_set_seat (PolKitSessio
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
+bool
 libpolkit_session_get_uid (PolKitSession *session, uid_t *out_uid)
 {
         g_return_val_if_fail (session != NULL, FALSE);
@@ -242,7 +242,7 @@ libpolkit_session_get_uid (PolKitSession
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
+bool
 libpolkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref)
 {
         g_return_val_if_fail (session != NULL, FALSE);
@@ -260,8 +260,8 @@ libpolkit_session_get_ck_objref (PolKitS
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
-libpolkit_session_get_ck_is_active (PolKitSession *session, gboolean *out_is_active)
+bool
+libpolkit_session_get_ck_is_active (PolKitSession *session, bool *out_is_active)
 {
         g_return_val_if_fail (session != NULL, FALSE);
         g_return_val_if_fail (out_is_active != NULL, FALSE);
@@ -278,8 +278,8 @@ libpolkit_session_get_ck_is_active (PolK
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
-libpolkit_session_get_ck_is_local (PolKitSession *session, gboolean *out_is_local)
+bool
+libpolkit_session_get_ck_is_local (PolKitSession *session, bool *out_is_local)
 {
         g_return_val_if_fail (session != NULL, FALSE);
         g_return_val_if_fail (out_is_local != NULL, FALSE);
@@ -298,7 +298,7 @@ libpolkit_session_get_ck_is_local (PolKi
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
+bool
 libpolkit_session_get_ck_remote_host (PolKitSession *session, char **out_remote_host)
 {
         g_return_val_if_fail (session != NULL, FALSE);
@@ -317,7 +317,7 @@ libpolkit_session_get_ck_remote_host (Po
  * 
  * Returns: TRUE iff the value is returned
  **/
-gboolean
+bool
 libpolkit_session_get_seat (PolKitSession *session, PolKitSeat **out_seat)
 {
         g_return_val_if_fail (session != NULL, FALSE);
@@ -350,8 +350,8 @@ libpolkit_session_new_from_objpath (DBus
         DBusMessage *message;
         DBusMessage *reply;
         char *str;
-        gboolean is_active;
-        gboolean is_local;
+        bool is_active;
+        bool is_local;
         char *remote_host;
         char *seat_path;
 
diff --git a/libpolkit/libpolkit-session.h b/libpolkit/libpolkit-session.h
index 1cbafec..44821a9 100644
--- a/libpolkit/libpolkit-session.h
+++ b/libpolkit/libpolkit-session.h
@@ -26,10 +26,8 @@
 #ifndef LIBPOLKIT_SESSION_H
 #define LIBPOLKIT_SESSION_H
 
-#include <stdio.h>
-#include <unistd.h>
+#include <stdbool.h>
 #include <sys/types.h>
-#include <glib.h>
 #include <dbus/dbus.h>
 
 #include <libpolkit/libpolkit-seat.h>
@@ -45,15 +43,15 @@ void           libpolkit_session_unref  
 void           libpolkit_session_set_uid            (PolKitSession *session, uid_t           uid);
 void           libpolkit_session_set_seat           (PolKitSession *session, PolKitSeat     *seat);
 void           libpolkit_session_set_ck_objref      (PolKitSession *session, const char     *ck_objref);
-void           libpolkit_session_set_ck_is_active   (PolKitSession *session, gboolean        is_active);
-void           libpolkit_session_set_ck_is_local    (PolKitSession *session, gboolean        is_local);
+void           libpolkit_session_set_ck_is_active   (PolKitSession *session, bool            is_active);
+void           libpolkit_session_set_ck_is_local    (PolKitSession *session, bool            is_local);
 void           libpolkit_session_set_ck_remote_host (PolKitSession *session, const char     *remote_host);
-gboolean       libpolkit_session_get_uid            (PolKitSession *session, uid_t          *out_uid);
-gboolean       libpolkit_session_get_seat           (PolKitSession *session, PolKitSeat    **out_seat);
-gboolean       libpolkit_session_get_ck_objref      (PolKitSession *session, char          **out_ck_objref);
-gboolean       libpolkit_session_get_ck_is_active   (PolKitSession *session, gboolean       *out_is_active);
-gboolean       libpolkit_session_get_ck_is_local    (PolKitSession *session, gboolean       *out_is_local);
-gboolean       libpolkit_session_get_ck_remote_host (PolKitSession *session, char          **out_remote_host);
+bool           libpolkit_session_get_uid            (PolKitSession *session, uid_t          *out_uid);
+bool           libpolkit_session_get_seat           (PolKitSession *session, PolKitSeat    **out_seat);
+bool           libpolkit_session_get_ck_objref      (PolKitSession *session, char          **out_ck_objref);
+bool           libpolkit_session_get_ck_is_active   (PolKitSession *session, bool           *out_is_active);
+bool           libpolkit_session_get_ck_is_local    (PolKitSession *session, bool           *out_is_local);
+bool           libpolkit_session_get_ck_remote_host (PolKitSession *session, char          **out_remote_host);
 
 void           libpolkit_session_debug              (PolKitSession *session);
 
diff --git a/modules/allow-all/Makefile.am b/modules/allow-all/Makefile.am
index 8a09890..a833468 100644
--- a/modules/allow-all/Makefile.am
+++ b/modules/allow-all/Makefile.am
@@ -9,7 +9,7 @@ INCLUDES = \
 	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
 	-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
 	-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT	\
-	@GLIB_CFLAGS@ @DBUS_CFLAGS@
+	@DBUS_CFLAGS@
 
 polkitmoduledir = $(libdir)/PolicyKit/modules
 polkitmodule_LTLIBRARIES = 				\
@@ -19,7 +19,7 @@ polkitmodule_LTLIBRARIES = 				\
 
 polkit_module_allow_all_la_SOURCES = polkit-module-allow-all.c
 polkit_module_allow_all_la_LDFLAGS = -no-undefined -module -avoid-version
-polkit_module_allow_all_la_LIBADD = $(top_builddir)/libpolkit/libpolkit.la @GLIB_LIBS@
+polkit_module_allow_all_la_LIBADD = $(top_builddir)/libpolkit/libpolkit.la
 
 clean-local :
 	rm -f *~
diff --git a/modules/allow-all/polkit-module-allow-all.c b/modules/allow-all/polkit-module-allow-all.c
index e2b25f3..eddee16 100644
--- a/modules/allow-all/polkit-module-allow-all.c
+++ b/modules/allow-all/polkit-module-allow-all.c
@@ -27,24 +27,15 @@
 #  include <config.h>
 #endif
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <pwd.h>
-#include <grp.h>
-#include <unistd.h>
-#include <errno.h>
-
 #include <libpolkit/libpolkit-module.h>
 
 /* The symbol that libpolkit looks up when loading this module */
-gboolean libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
+bool libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
 
-static gboolean
+static bool
 _module_init (PolKitModuleInterface *module_interface, int argc, char *argv[])
 {
-        return TRUE;
+        return true;
 }
 
 static void
@@ -72,12 +63,12 @@ _module_can_caller_access_resource (PolK
         return LIBPOLKIT_RESULT_YES;
 }
 
-gboolean
+bool
 libpolkit_module_set_functions (PolKitModuleInterface *module_interface)
 {
-        gboolean ret;
+        bool ret;
 
-        ret = FALSE;
+        ret = false;
         if (module_interface == NULL)
                 goto out;
 
@@ -86,7 +77,7 @@ libpolkit_module_set_functions (PolKitMo
         libpolkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
         libpolkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
 
-        ret = TRUE;
+        ret = true;
 out:
         return ret;
 }
diff --git a/modules/default/Makefile.am b/modules/default/Makefile.am
index 6167cc4..91f49d4 100644
--- a/modules/default/Makefile.am
+++ b/modules/default/Makefile.am
@@ -9,7 +9,7 @@ INCLUDES = \
 	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
 	-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
 	-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT	\
-	@GLIB_CFLAGS@ @DBUS_CFLAGS@
+	@DBUS_CFLAGS@
 
 polkitmoduledir = $(libdir)/PolicyKit/modules
 polkitmodule_LTLIBRARIES = 				\
@@ -19,7 +19,7 @@ polkitmodule_LTLIBRARIES = 				\
 
 polkit_module_default_la_SOURCES = polkit-module-default.c
 polkit_module_default_la_LDFLAGS = -no-undefined -module -avoid-version
-polkit_module_default_la_LIBADD = $(top_builddir)/libpolkit/libpolkit.la @GLIB_LIBS@
+polkit_module_default_la_LIBADD = $(top_builddir)/libpolkit/libpolkit.la
 
 clean-local :
 	rm -f *~
diff --git a/modules/default/polkit-module-default.c b/modules/default/polkit-module-default.c
index 418c1d2..09b25e3 100644
--- a/modules/default/polkit-module-default.c
+++ b/modules/default/polkit-module-default.c
@@ -27,26 +27,17 @@
 #  include <config.h>
 #endif
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <pwd.h>
-#include <grp.h>
-#include <unistd.h>
-#include <errno.h>
-
 #include <libpolkit/libpolkit-module.h>
 
 /* The symbol that libpolkit looks up when loading this module */
-gboolean libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
+bool libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
 
-static gboolean
+static bool
 _module_init (PolKitModuleInterface *module_interface, 
               int argc, 
               char *argv[])
 {
-        return TRUE;
+        return true;
 }
 
 static void
@@ -96,12 +87,12 @@ _module_can_caller_access_resource (PolK
                 caller);
 }
 
-gboolean
+bool
 libpolkit_module_set_functions (PolKitModuleInterface *module_interface)
 {
-        gboolean ret;
+        bool ret;
 
-        ret = FALSE;
+        ret = false;
         if (module_interface == NULL)
                 goto out;
 
@@ -110,7 +101,7 @@ libpolkit_module_set_functions (PolKitMo
         libpolkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
         libpolkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
 
-        ret = TRUE;
+        ret = true;
 out:
         return ret;
 }
diff --git a/modules/deny-all/Makefile.am b/modules/deny-all/Makefile.am
index d6a134a..345dcf4 100644
--- a/modules/deny-all/Makefile.am
+++ b/modules/deny-all/Makefile.am
@@ -9,7 +9,7 @@ INCLUDES = \
 	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
 	-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
 	-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT	\
-	@GLIB_CFLAGS@ @DBUS_CFLAGS@
+	@DBUS_CFLAGS@
 
 polkitmoduledir = $(libdir)/PolicyKit/modules
 polkitmodule_LTLIBRARIES = 				\
@@ -19,7 +19,7 @@ polkitmodule_LTLIBRARIES = 				\
 
 polkit_module_deny_all_la_SOURCES = polkit-module-deny-all.c
 polkit_module_deny_all_la_LDFLAGS = -no-undefined -module -avoid-version
-polkit_module_deny_all_la_LIBADD = $(top_builddir)/libpolkit/libpolkit.la @GLIB_LIBS@
+polkit_module_deny_all_la_LIBADD = $(top_builddir)/libpolkit/libpolkit.la
 
 clean-local :
 	rm -f *~
diff --git a/modules/deny-all/polkit-module-deny-all.c b/modules/deny-all/polkit-module-deny-all.c
index e6206fc..7562312 100644
--- a/modules/deny-all/polkit-module-deny-all.c
+++ b/modules/deny-all/polkit-module-deny-all.c
@@ -27,24 +27,15 @@
 #  include <config.h>
 #endif
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <pwd.h>
-#include <grp.h>
-#include <unistd.h>
-#include <errno.h>
-
 #include <libpolkit/libpolkit-module.h>
 
 /* The symbol that libpolkit looks up when loading this module */
-gboolean libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
+bool libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
 
-static gboolean
+static bool
 _module_init (PolKitModuleInterface *module_interface, int argc, char *argv[])
 {
-        return TRUE;
+        return true;
 }
 
 static void
@@ -72,12 +63,12 @@ _module_can_caller_access_resource (PolK
         return LIBPOLKIT_RESULT_NO;
 }
 
-gboolean
+bool
 libpolkit_module_set_functions (PolKitModuleInterface *module_interface)
 {
-        gboolean ret;
+        bool ret;
 
-        ret = FALSE;
+        ret = false;
         if (module_interface == NULL)
                 goto out;
 
@@ -86,7 +77,7 @@ libpolkit_module_set_functions (PolKitMo
         libpolkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
         libpolkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
 
-        ret = TRUE;
+        ret = true;
 out:
         return ret;
 }
diff --git a/modules/run-program/polkit-module-run-program.c b/modules/run-program/polkit-module-run-program.c
index bd4738a..8f02e57 100644
--- a/modules/run-program/polkit-module-run-program.c
+++ b/modules/run-program/polkit-module-run-program.c
@@ -27,26 +27,18 @@
 #  include <config.h>
 #endif
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <pwd.h>
-#include <grp.h>
-#include <unistd.h>
-#include <errno.h>
-
 #include <libpolkit/libpolkit-module.h>
+#include <glib.h>
 
 /* The symbol that libpolkit looks up when loading this module */
-gboolean libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
+bool libpolkit_module_set_functions (PolKitModuleInterface *module_interface);
 
 typedef struct {
         int program_argc;
         char **program_argv;
 } UserData;
 
-static gboolean
+static bool
 _module_init (PolKitModuleInterface *module_interface, int argc, char *argv[])
 {
         int n;
@@ -61,18 +53,18 @@ _module_init (PolKitModuleInterface *mod
                         if (!g_shell_parse_argv (program, 
                                                  &user_data->program_argc, 
                                                  &user_data->program_argv, NULL)) {
-                                printf ("Cannot parse '%s' - skipping\n", program);
+                                g_warning ("Cannot parse '%s' - skipping", program);
                                 goto error;
                         }
 
                         if (!g_file_test (user_data->program_argv[0], 
                                           G_FILE_TEST_IS_EXECUTABLE|G_FILE_TEST_IS_REGULAR)) {
-                                printf ("Program '%s' is not an executable file - skipping\n",
-                                        user_data->program_argv[0]);
+                                g_warning ("Program '%s' is not an executable file - skipping",
+                                           user_data->program_argv[0]);
                                 goto error;
                         }
 
-                        printf ("program = '%s'\n", user_data->program_argv[0]);
+                        g_debug ("program = '%s'", user_data->program_argv[0]);
 
                         /* TODO:
                          * O_o o_O... we could monitor the executable file :-) and trigger config changes!
@@ -85,12 +77,12 @@ _module_init (PolKitModuleInterface *mod
 
         libpolkit_module_set_user_data (module_interface, user_data);
 
-        return TRUE;
+        return true;
 error:
         if (user_data->program_argv != NULL)
                 g_strfreev (user_data->program_argv);
         g_free (user_data);
-        return FALSE;
+        return false;
 }
 
 static void
@@ -128,7 +120,7 @@ _add_action_param_to_env (PolKitAction *
         g_free (upper);
 }
 
-static gboolean
+static bool
 _add_action_to_env (PolKitAction *action, GPtrArray *envp)
 {
         char *p_id;
@@ -137,12 +129,12 @@ _add_action_to_env (PolKitAction *action
         g_ptr_array_add (envp, g_strdup_printf ("POLKIT_ACTION_ID=%s", p_id));
 
         libpolkit_action_param_foreach (action, _add_action_param_to_env, envp);
-        return TRUE;
+        return true;
 error:
-        return FALSE;
+        return false;
 }
 
-static gboolean
+static bool
 _add_resource_to_env (PolKitResource *resource, GPtrArray *envp)
 {
         char *r_type;
@@ -153,30 +145,30 @@ _add_resource_to_env (PolKitResource *re
                 goto error;
         g_ptr_array_add (envp, g_strdup_printf ("POLKIT_RESOURCE_TYPE=%s", r_type));
         g_ptr_array_add (envp, g_strdup_printf ("POLKIT_RESOURCE_ID=%s", r_id));
-        return TRUE;
+        return true;
 error:
-        return FALSE;
+        return false;
 }
 
-static gboolean
+static bool
 _add_seat_to_env (PolKitSeat *seat, GPtrArray *envp)
 {
         char *s_ck_objref;
         if (!libpolkit_seat_get_ck_objref (seat, &s_ck_objref))
                 goto error;
         g_ptr_array_add (envp, g_strdup_printf ("POLKIT_SEAT_CK_OBJREF=%s", s_ck_objref));
-        return TRUE;
+        return true;
 error:
-        return FALSE;
+        return false;
 }
 
-static gboolean
+static bool
 _add_session_to_env (PolKitSession *session, GPtrArray *envp)
 {
         uid_t s_uid;
         char *s_ck_objref;
-        gboolean s_ck_is_active;
-        gboolean s_ck_is_local;
+        bool s_ck_is_active;
+        bool s_ck_is_local;
         char *s_ck_remote_host;
         PolKitSeat *s_seat;
 
@@ -202,12 +194,12 @@ _add_session_to_env (PolKitSession *sess
         g_ptr_array_add (envp, g_strdup_printf ("POLKIT_SESSION_CK_IS_LOCAL=%d", s_ck_is_local));
         if (!s_ck_is_local)
                 g_ptr_array_add (envp, g_strdup_printf ("POLKIT_SESSION_CK_REMOTE_HOST=%s", s_ck_remote_host));
-        return TRUE;
+        return true;
 error:
-        return FALSE;
+        return false;
 }
 
-static gboolean
+static bool
 _add_caller_to_env (PolKitCaller *caller, GPtrArray *envp)
 {
         uid_t c_uid;
@@ -235,23 +227,23 @@ _add_caller_to_env (PolKitCaller *caller
         g_ptr_array_add (envp, g_strdup_printf ("POLKIT_CALLER_DBUS_NAME=%s", c_dbus_name));
         if (c_selinux_context != NULL)
                 g_ptr_array_add (envp, g_strdup_printf ("POLKIT_CALLER_SELINUX_CONTEXT=%s", c_selinux_context));
-        return TRUE;
+        return true;
 error:
-        return FALSE;
+        return false;
 }
 
-static gboolean
+static bool
 _run_program (UserData *user_data, char **envp, PolKitResult *result)
 {
         int n;
         int exit_status;
         GError *g_error;
         char *prog_stdout;
-        gboolean ret;
+        bool ret;
 
         g_error = NULL;
         prog_stdout = NULL;
-        ret = FALSE;
+        ret = false;
 
         if (!g_spawn_sync ("/",
                            user_data->program_argv,
@@ -263,7 +255,7 @@ _run_program (UserData *user_data, char 
                            NULL,
                            &exit_status,
                            &g_error)) {
-                printf ("error spawning '%s': %s\n", user_data->program_argv[0], g_error->message);
+                g_warning ("error spawning '%s': %s", user_data->program_argv[0], g_error->message);
                 g_error_free (g_error);
                 goto error;
         }
@@ -278,11 +270,11 @@ _run_program (UserData *user_data, char 
         prog_stdout[n] = '\0';
 
         if (!libpolkit_result_from_string_representation (prog_stdout, result)) {
-                printf ("malformed result '%s' from program\n", prog_stdout);
+                g_warning ("malformed result '%s' from program", prog_stdout);
                 goto error;
         }
 
-        ret = TRUE;
+        ret = true;
 error:
         g_free (prog_stdout);
         return ret;
@@ -364,12 +356,12 @@ error:
         return result;
 }
 
-gboolean
+bool
 libpolkit_module_set_functions (PolKitModuleInterface *module_interface)
 {
-        gboolean ret;
+        bool ret;
 
-        ret = FALSE;
+        ret = false;
         if (module_interface == NULL)
                 goto out;
 
@@ -378,7 +370,7 @@ libpolkit_module_set_functions (PolKitMo
         libpolkit_module_set_func_can_session_access_resource (module_interface, _module_can_session_access_resource);
         libpolkit_module_set_func_can_caller_access_resource (module_interface, _module_can_caller_access_resource);
 
-        ret = TRUE;
+        ret = true;
 out:
         return ret;
 }
diff --git a/tools/Makefile.am b/tools/Makefile.am
index cef6336..8b8475b 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -20,7 +20,7 @@ polkit_check_session_SOURCES = polkit-ch
 polkit_check_session_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/libpolkit/libpolkit.la
 
 polkit_policy_file_validate_SOURCES = polkit-policy-file-validate.c
-polkit_policy_file_validate_LDADD = @GLIB_LIBS@ $(top_builddir)/libpolkit/libpolkit.la
+polkit_policy_file_validate_LDADD = $(top_builddir)/libpolkit/libpolkit.la
 
 clean-local :
 	rm -f *~
diff --git a/tools/polkit-check-caller.c b/tools/polkit-check-caller.c
index 874c7f2..49c6f03 100644
--- a/tools/polkit-check-caller.c
+++ b/tools/polkit-check-caller.c
@@ -37,6 +37,8 @@
 
 #include <libpolkit/libpolkit.h>
 
+#include <glib.h>
+
 static void
 usage (int argc, char *argv[])
 {
@@ -78,7 +80,7 @@ main (int argc, char *argv[])
         PolKitResource *resource;
         PolKitAction *action;
         gboolean allowed;
-        GError *g_error;
+        PolKitError *p_error;
         GPtrArray *params;
         int n;
         char *param_key;
@@ -166,11 +168,11 @@ main (int argc, char *argv[])
 		return 1;
 	}
 
-        g_error = NULL;
+        p_error = NULL;
         pol_ctx = libpolkit_context_new ();
-        if (!libpolkit_context_init (pol_ctx, &g_error)) {
-		fprintf (stderr, "error: libpolkit_context_init: %s\n", g_error->message);
-                g_error_free (g_error);
+        if (!libpolkit_context_init (pol_ctx, &p_error)) {
+		fprintf (stderr, "error: libpolkit_context_init: %s\n", polkit_error_get_error_message (p_error));
+                polkit_error_free (p_error);
                 return 1;
         }
 
diff --git a/tools/polkit-check-session.c b/tools/polkit-check-session.c
index da5ada9..cbde113 100644
--- a/tools/polkit-check-session.c
+++ b/tools/polkit-check-session.c
@@ -37,6 +37,8 @@
 
 #include <libpolkit/libpolkit.h>
 
+#include <glib.h>
+
 static void
 usage (int argc, char *argv[])
 {
@@ -79,7 +81,7 @@ main (int argc, char *argv[])
         PolKitResource *resource;
         PolKitAction *action;
         gboolean allowed;
-        GError *g_error;
+        PolKitError *p_error;
         GPtrArray *params;
         int n;
         char *param_key;
@@ -169,11 +171,11 @@ main (int argc, char *argv[])
 		return 1;
 	}
 
-        g_error = NULL;
+        p_error = NULL;
         pol_ctx = libpolkit_context_new ();
-        if (!libpolkit_context_init (pol_ctx, &g_error)) {
-		fprintf (stderr, "error: libpolkit_context_init: %s\n", g_error->message);
-                g_error_free (g_error);
+        if (!libpolkit_context_init (pol_ctx, &p_error)) {
+		fprintf (stderr, "error: libpolkit_context_init: %s\n", polkit_error_get_error_message (p_error));
+                polkit_error_free (p_error);
                 return 1;
         }
 
diff --git a/tools/polkit-policy-file-validate.c b/tools/polkit-policy-file-validate.c
index 07c59d0..604d7c4 100644
--- a/tools/polkit-policy-file-validate.c
+++ b/tools/polkit-policy-file-validate.c
@@ -25,6 +25,7 @@
 #  include <config.h>
 #endif
 
+#include <stdbool.h>
 #include <getopt.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -53,16 +54,17 @@ usage (int argc, char *argv[])
                  "If not, the program exits with a non-zero exit code.\n");
 }
 
-static gboolean
+static bool
 validate_file (const char *file)
 {
         PolKitPolicyFile *priv_file;
-        GError *error = NULL;
+        PolKitError *error;
 
+        error = NULL;
         priv_file = libpolkit_policy_file_new (file, &error);
         if (priv_file == NULL) {
-                printf ("%s did not validate: %s\n", file, error->message);
-                g_error_free (error);
+                printf ("%s did not validate: %s\n", file, polkit_error_get_error_message (error));
+                polkit_error_free (error);
                 return FALSE;
         }
         libpolkit_policy_file_unref (priv_file);


More information about the hal-commit mailing list