PolicyKit: Branch 'master' - 6 commits

David Zeuthen david at kemper.freedesktop.org
Wed Mar 28 21:51:53 PDT 2007


 configure.in                         |    6 
 doc/api/libpolkit/libpolkit-docs.xml |    6 
 doc/man/Makefile.am                  |    4 
 doc/man/polkit-check-caller.1.in     |   65 ++++
 doc/man/polkit-check-session.1.in    |   65 ++++
 gtk-doc.make                         |    3 
 libpolkit.pc.in                      |    4 
 libpolkit/Makefile.am                |   28 +
 libpolkit/libpolkit-caller.c         |  437 +++++++++++++++++++++++++++
 libpolkit/libpolkit-caller.h         |   57 +++
 libpolkit/libpolkit-context.c        |  130 ++++++++
 libpolkit/libpolkit-context.h        |   57 +++
 libpolkit/libpolkit-privilege.c      |  146 +++++++++
 libpolkit/libpolkit-privilege.h      |   45 ++
 libpolkit/libpolkit-resource.c       |  194 ++++++++++++
 libpolkit/libpolkit-resource.h       |   47 ++
 libpolkit/libpolkit-seat.c           |  144 ++++++++
 libpolkit/libpolkit-seat.h           |   45 ++
 libpolkit/libpolkit-session.c        |  565 +++++++++++++++++++++++++++++++++++
 libpolkit/libpolkit-session.h        |   58 +++
 libpolkit/libpolkit.c                |   95 +++++
 libpolkit/libpolkit.h                |   45 ++
 tools/Makefile.am                    |    9 
 tools/polkit-check-caller.c          |  172 ++++++++++
 tools/polkit-check-session.c         |  180 +++++++++++
 25 files changed, 2592 insertions(+), 15 deletions(-)

New commits:
diff-tree 416921898aa80a0135855bd7a790053d460cf111 (from 5dabca219d230f8c66050467d6df7f392db5bcd8)
Author: David Zeuthen <davidz at redhat.com>
Date:   Thu Mar 29 00:46:42 2007 -0400

    add two tools polkit-check-caller and polkit-check-session

diff --git a/configure.in b/configure.in
index 4cde2d3..9e12a93 100644
--- a/configure.in
+++ b/configure.in
@@ -121,6 +121,10 @@ PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.6
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 
+PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.0])
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
+
 AC_CHECK_FUNCS(getgrouplist)
 
 # DocBook Documentation
@@ -187,6 +191,8 @@ doc/api/libpolkit/version.xml
 doc/spec/Makefile
 doc/spec/polkit-spec.xml.in
 doc/man/Makefile
+doc/man/polkit-check-caller.1
+doc/man/polkit-check-session.1
 ])
 
 dnl ==========================================================================
diff --git a/doc/api/libpolkit/libpolkit-docs.xml b/doc/api/libpolkit/libpolkit-docs.xml
index 318d7bb..d8f2c63 100644
--- a/doc/api/libpolkit/libpolkit-docs.xml
+++ b/doc/api/libpolkit/libpolkit-docs.xml
@@ -64,9 +64,7 @@
 	PolicyKit library.
       </para>
     </partintro>
-    <title>
-      <xi:include href="xml/libpolkit.xml"/>
-    </title>
+    <xi:include href="xml/libpolkit.xml"/>
     <xi:include href="xml/libpolkit-context.xml"/>
     <xi:include href="xml/libpolkit-privilege.xml"/>
     <xi:include href="xml/libpolkit-resource.xml"/>
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
index 56847f8..1786b5d 100644
--- a/doc/man/Makefile.am
+++ b/doc/man/Makefile.am
@@ -1,9 +1,9 @@
 
 if MAN_PAGES_ENABLED
 
-MAN_IN_FILES = 
+MAN_IN_FILES = polkit-check-caller.1.in polkit-check-session.1.in
 
-man_MANS = 
+man_MANS = polkit-check-caller.1 polkit-check-session.1
 
 endif # MAN_PAGES_ENABLED
 
diff --git a/doc/man/polkit-check-caller.1.in b/doc/man/polkit-check-caller.1.in
new file mode 100644
index 0000000..952801e
--- /dev/null
+++ b/doc/man/polkit-check-caller.1.in
@@ -0,0 +1,65 @@
+.\" 
+.\" polkit-check-caller manual page.
+.\" Copyright (C) 2007 David Zeuthen <david at fubar.dk>
+.\"
+.TH POLKIT-CHECK-CALLER 1
+.SH NAME
+polkit-check-caller \- check access
+.SH SYNOPSIS
+.PP
+.B polkit-check-caller
+[options]
+
+.SH DESCRIPTION
+
+\fIpolkit-check-caller\fP can be used to determine if a given caller
+can access a given resource in a given way. For more information about
+the big picture refer to the \fIPolicyKit spec\fP which can be found
+in
+.I "/usr/share/doc/PolicyKit- at VERSION@/spec/polkit-spec.html"
+depending on the distribution.
+
+.SH OPTIONS
+The following options are supported:
+.TP
+.I "--resource-type"
+Type of resource.
+.TP
+.I "--resource"
+Identifier of resource.
+.TP
+.I "--privilege"
+The privilege to check.
+.TP
+.I "--caller"
+The caller to check for. Must be the callers unique name on the D-Bus
+system message bus.
+.TP
+.I "--help"
+Print out usage.
+.TP
+.I "--version"
+Print the version.
+
+.SH RETURN VALUE
+.PP
+If access is allowed, this
+program exits with exit code 0. If no access is allowed or an error
+occurs, the program exits with a non-zero exit code.
+
+.SH BUGS
+.PP
+Please send bug reports to either the distribution or the HAL
+mailing list, see 
+.I "http://lists.freedesktop.org/mailman/listinfo/hal"
+on how to subscribe.
+
+.SH SEE ALSO
+.PP
+\&\fIdbus-daemon\fR\|(1),
+\&\fIpolkit-check-session\fR\|(1)
+
+.SH AUTHOR
+Written by David Zeuthen <david at fubar.dk> with a lot of help from many
+others.
+
diff --git a/doc/man/polkit-check-session.1.in b/doc/man/polkit-check-session.1.in
new file mode 100644
index 0000000..44671d3
--- /dev/null
+++ b/doc/man/polkit-check-session.1.in
@@ -0,0 +1,65 @@
+.\" 
+.\" polkit-check-session manual page.
+.\" Copyright (C) 2007 David Zeuthen <david at fubar.dk>
+.\"
+.TH POLKIT-CHECK-SESSION 1
+.SH NAME
+polkit-check-session \- check access
+.SH SYNOPSIS
+.PP
+.B polkit-check-session
+[options]
+
+.SH DESCRIPTION
+
+\fIpolkit-check-session\fP can be used to determine if a given session
+can access a given resource in a given way. For more information about
+the big picture refer to the \fIPolicyKit spec\fP which can be found
+in
+.I "/usr/share/doc/PolicyKit- at VERSION@/spec/polkit-spec.html"
+depending on the distribution.
+
+.SH OPTIONS
+The following options are supported:
+.TP
+.I "--resource-type"
+Type of resource.
+.TP
+.I "--resource"
+Identifier of resource.
+.TP
+.I "--privilege"
+The privilege to check.
+.TP
+.I "--session"
+The session to check for. Must be a ConsoleKit object path. If
+ommitted the current session is used.
+.TP
+.I "--help"
+Print out usage.
+.TP
+.I "--version"
+Print the version.
+
+.SH RETURN VALUE
+.PP
+If access is allowed, this
+program exits with exit code 0. If no access is allowed or an error
+occurs, the program exits with a non-zero exit code.
+
+.SH BUGS
+.PP
+Please send bug reports to either the distribution or the HAL
+mailing list, see 
+.I "http://lists.freedesktop.org/mailman/listinfo/hal"
+on how to subscribe.
+
+.SH SEE ALSO
+.PP
+\&\fIdbus-daemon\fR\|(1),
+\&\fIpolkit-check-caller\fR\|(1)
+
+.SH AUTHOR
+Written by David Zeuthen <david at fubar.dk> with a lot of help from many
+others.
+
diff --git a/libpolkit.pc.in b/libpolkit.pc.in
index 3f36d2d..20a2f77 100644
--- a/libpolkit.pc.in
+++ b/libpolkit.pc.in
@@ -6,6 +6,6 @@ includedir=@includedir@
 Name: libpolkit
 Description: library for querying system-wide policy
 Version: @VERSION@
-Requires: glib-2.0
+Requires: glib-2.0 dbus-1
 Libs: -L${libdir} -lpolkit
 Cflags: -I${includedir}/PolicyKit
diff --git a/libpolkit/Makefile.am b/libpolkit/Makefile.am
index 55408c1..4d1dee0 100644
--- a/libpolkit/Makefile.am
+++ b/libpolkit/Makefile.am
@@ -8,7 +8,7 @@ INCLUDES = \
 	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
 	-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT	\
-	@GLIB_CFLAGS@
+	@GLIB_CFLAGS@ @DBUS_CFLAGS@
 
 lib_LTLIBRARIES=libpolkit.la
 
@@ -32,7 +32,7 @@ libpolkit_la_SOURCES =                  
 	libpolkit-session.h	libpolkit-session.c	\
 	libpolkit-caller.h	libpolkit-caller.c
 
-libpolkit_la_LIBADD = @GLIB_LIBS@
+libpolkit_la_LIBADD = @GLIB_LIBS@ @DBUS_LIBS@
 
 libpolkit_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
 
diff --git a/libpolkit/libpolkit-caller.c b/libpolkit/libpolkit-caller.c
index 4b59c36..2982508 100644
--- a/libpolkit/libpolkit-caller.c
+++ b/libpolkit/libpolkit-caller.c
@@ -128,17 +128,17 @@ void
 libpolkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name)
 {
         g_return_if_fail (caller != NULL);
-        if (caller->dbus_name == NULL)
+        if (caller->dbus_name != NULL)
                 g_free (caller->dbus_name);
         caller->dbus_name = g_strdup (dbus_name);
 }
 
 /**
- * libpolkit_caller_set_pid:
+ * libpolkit_caller_set_uid:
  * @caller: The caller object 
- * @pid: UNIX process id
+ * @uid: UNIX user id
  * 
- * Set the callers UNIX process id.
+ * Set the callers UNIX user id.
  **/
 void
 libpolkit_caller_set_uid (PolKitCaller *caller, uid_t uid)
@@ -172,7 +172,7 @@ void
 libpolkit_caller_set_selinux_context (PolKitCaller *caller, const char *selinux_context)
 {
         g_return_if_fail (caller != NULL);
-        if (caller->selinux_context == NULL)
+        if (caller->selinux_context != NULL)
                 g_free (caller->selinux_context);
         caller->selinux_context = g_strdup (selinux_context);
 }
@@ -190,7 +190,7 @@ void
 libpolkit_caller_set_ck_session (PolKitCaller *caller, PolKitSession *session)
 {
         g_return_if_fail (caller != NULL);
-        if (caller->session == NULL)
+        if (caller->session != NULL)
                 libpolkit_session_unref (caller->session);
         caller->session = session != NULL ? libpolkit_session_ref (session) : NULL;
 }
@@ -214,11 +214,11 @@ libpolkit_caller_get_dbus_name (PolKitCa
 }
 
 /**
- * libpolkit_caller_get_pid:
+ * libpolkit_caller_get_uid:
  * @caller: The caller object 
- * @out_pid: Returns the UNIX process id
+ * @out_uid: Returns the UNIX user id
  * 
- * Get the callers UNIX process id.
+ * Get the callers UNIX user id.
  * 
  * Returns: TRUE iff the value is returned
  **/
@@ -254,7 +254,8 @@ libpolkit_caller_get_pid (PolKitCaller *
  * @caller: The caller object 
  * @out_selinux_context: Returns the SELinux security context. The caller shall not free this string.
  * 
- * Get the callers SELinux security context.
+ * Get the callers SELinux security context. Note that this may be
+ * #NULL if SELinux is not available on the system.
  * 
  * Returns: TRUE iff the value is returned
  **/
@@ -272,7 +273,8 @@ libpolkit_caller_get_selinux_context (Po
  * @caller: The caller object 
  * @out_session: Returns the session object. Caller shall not unref it.
  * 
- * Get the callers session.
+ * Get the callers session. Note that this may be #NULL if the caller
+ * is not in any session.
  * 
  * Returns: TRUE iff the value is returned
  **/
@@ -284,3 +286,152 @@ libpolkit_caller_get_ck_session (PolKitC
         *out_session = caller->session;
         return TRUE;
 }
+
+/**
+ * libpolkit_caller_new_from_dbus_name:
+ * @con: D-Bus system bus connection
+ * @dbus_name: unique system bus connection name
+ * @error: D-Bus error
+ * 
+ * This function will construct a #PolKitCaller object by querying
+ * both the system bus daemon and the ConsoleKit daemon for
+ * information. Note that this will do a lot of blocking IO so it is
+ * best avoided if your process already tracks/caches all the
+ * information.
+ * 
+ * Returns: the new object or #NULL if an error occured (in which case
+ * @error will be set)
+ **/
+PolKitCaller *
+libpolkit_caller_new_from_dbus_name (DBusConnection *con, const char *dbus_name, DBusError *error)
+{
+        PolKitCaller *caller;
+        pid_t pid;
+        uid_t uid;
+        char *selinux_context;
+        char *ck_session_objpath;
+        PolKitSession *session;
+        DBusMessage *message;
+        DBusMessage *reply;
+        DBusMessageIter iter;
+        DBusMessageIter sub_iter;
+        char *str;
+        int num_elems;
+
+        g_return_val_if_fail (con != NULL, NULL);
+        g_return_val_if_fail (dbus_name != NULL, NULL);
+        g_return_val_if_fail (error != NULL, NULL);
+        g_return_val_if_fail (! dbus_error_is_set (error), NULL);
+
+        selinux_context = NULL;
+        ck_session_objpath = NULL;
+
+        caller = NULL;
+        session = NULL;
+
+	uid = dbus_bus_get_unix_user (con, dbus_name, error);
+	if (uid == ((unsigned long) -1) || dbus_error_is_set (error)) {
+		g_warning ("Could not get uid for connection: %s %s", error->name, error->message);
+		goto out;
+	}
+
+	message = dbus_message_new_method_call ("org.freedesktop.DBus", 
+						"/org/freedesktop/DBus/Bus",
+						"org.freedesktop.DBus",
+						"GetConnectionUnixProcessID");
+	dbus_message_iter_init_append (message, &iter);
+	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &dbus_name);
+	reply = dbus_connection_send_with_reply_and_block (con, message, -1, error);
+	if (reply == NULL || dbus_error_is_set (error)) {
+		g_warning ("Error doing GetConnectionUnixProcessID on Bus: %s: %s", error->name, error->message);
+		dbus_message_unref (message);
+		if (reply != NULL)
+			dbus_message_unref (reply);
+		goto out;
+	}
+	dbus_message_iter_init (reply, &iter);
+	dbus_message_iter_get_basic (&iter, &pid);
+	dbus_message_unref (message);
+	dbus_message_unref (reply);
+
+	message = dbus_message_new_method_call ("org.freedesktop.DBus", 
+						"/org/freedesktop/DBus/Bus",
+						"org.freedesktop.DBus",
+						"GetConnectionSELinuxSecurityContext");
+	dbus_message_iter_init_append (message, &iter);
+	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &dbus_name);
+	reply = dbus_connection_send_with_reply_and_block (con, message, -1, error);
+        /* SELinux might not be enabled */
+        if (dbus_error_is_set (error) && 
+            strcmp (error->name, "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown") == 0) {
+                dbus_message_unref (message);
+		if (reply != NULL)
+			dbus_message_unref (reply);
+                dbus_error_init (error);
+        } else if (reply == NULL || dbus_error_is_set (error)) {
+                g_warning ("Error doing GetConnectionSELinuxSecurityContext on Bus: %s: %s", error->name, error->message);
+                dbus_message_unref (message);
+                if (reply != NULL)
+                        dbus_message_unref (reply);
+                goto out;
+        } else {
+                /* TODO: verify signature */
+                dbus_message_iter_init (reply, &iter);
+                dbus_message_iter_recurse (&iter, &sub_iter);
+                dbus_message_iter_get_fixed_array (&sub_iter, (void *) &str, &num_elems);
+                if (str != NULL && num_elems > 0)
+                        selinux_context = g_strndup (str, num_elems);
+                dbus_message_unref (message);
+                dbus_message_unref (reply);
+        }
+
+	message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
+						"/org/freedesktop/ConsoleKit/Manager",
+						"org.freedesktop.ConsoleKit.Manager",
+						"GetSessionForUnixProcess");
+	dbus_message_iter_init_append (message, &iter);
+	dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &pid);
+	reply = dbus_connection_send_with_reply_and_block (con, message, -1, error);
+	if (reply == NULL || dbus_error_is_set (error)) {
+		g_warning ("Error doing GetSessionForUnixProcess on ConsoleKit: %s: %s", error->name, error->message);
+		dbus_message_unref (message);
+		if (reply != NULL)
+			dbus_message_unref (reply);
+		/* OK, this is not a catastrophe; just means the caller is not a 
+                 * member of any session or that ConsoleKit is not available.. 
+                 */
+		goto not_in_session;
+	}
+	dbus_message_iter_init (reply, &iter);
+	dbus_message_iter_get_basic (&iter, &str);
+	ck_session_objpath = g_strdup (str);
+	dbus_message_unref (message);
+	dbus_message_unref (reply);
+
+        session = libpolkit_session_new_from_objpath (con, ck_session_objpath, uid, error);
+        if (session == NULL) {
+                g_warning ("Got a session objpath but couldn't construct session object!");
+        }
+
+not_in_session:
+        g_debug ("uid %d", uid);
+        g_debug ("pid %d", pid);
+        g_debug ("selinux context '%s'", selinux_context != NULL ? selinux_context : "(not set)");
+        g_debug ("ck session '%s'", ck_session_objpath != NULL ? ck_session_objpath : "(not in a session)");
+
+        caller = libpolkit_caller_new ();
+        libpolkit_caller_set_dbus_name (caller, dbus_name);
+        libpolkit_caller_set_uid (caller, uid);
+        libpolkit_caller_set_pid (caller, pid);
+        libpolkit_caller_set_selinux_context (caller, selinux_context);
+        if (session != NULL) {
+                libpolkit_caller_set_ck_session (caller, session);
+                libpolkit_session_unref (session); /* we own this session object */
+        }
+
+out:
+        g_free (selinux_context);
+        g_free (ck_session_objpath);
+        return caller;
+}
+
diff --git a/libpolkit/libpolkit-caller.h b/libpolkit/libpolkit-caller.h
index ddf0037..b2cfd11 100644
--- a/libpolkit/libpolkit-caller.h
+++ b/libpolkit/libpolkit-caller.h
@@ -30,6 +30,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <glib.h>
+#include <dbus/dbus.h>
 
 #include <libpolkit/libpolkit-session.h>
 
@@ -37,18 +38,19 @@ struct PolKitCaller;
 typedef struct PolKitCaller PolKitCaller;
 
 PolKitCaller     *libpolkit_caller_new                 (void);
-PolKitCaller     *libpolkit_caller_ref                 (PolKitCaller *caller);
-void              libpolkit_caller_unref               (PolKitCaller *caller);
-void              libpolkit_caller_set_dbus_name       (PolKitCaller *caller, const char     *dbus_name);
-void              libpolkit_caller_set_uid             (PolKitCaller *caller, uid_t           uid);
-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);
+PolKitCaller     *libpolkit_caller_new_from_dbus_name  (DBusConnection *con, const char *dbus_name, DBusError *error);
+PolKitCaller     *libpolkit_caller_ref                 (PolKitCaller   *caller);
+void              libpolkit_caller_unref               (PolKitCaller   *caller);
+void              libpolkit_caller_set_dbus_name       (PolKitCaller   *caller, const char     *dbus_name);
+void              libpolkit_caller_set_uid             (PolKitCaller   *caller, uid_t           uid);
+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);
 
 #endif /* LIBPOLKIT_H */
 
diff --git a/libpolkit/libpolkit-privilege.c b/libpolkit/libpolkit-privilege.c
index f6a4634..bc18b55 100644
--- a/libpolkit/libpolkit-privilege.c
+++ b/libpolkit/libpolkit-privilege.c
@@ -120,7 +120,7 @@ void
 libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char  *privilege_id)
 {
         g_return_if_fail (privilege != NULL);
-        if (privilege->id == NULL)
+        if (privilege->id != NULL)
                 g_free (privilege->id);
         privilege->id = g_strdup (privilege_id);
 }
diff --git a/libpolkit/libpolkit-resource.c b/libpolkit/libpolkit-resource.c
index 8e53e84..44f6fa2 100644
--- a/libpolkit/libpolkit-resource.c
+++ b/libpolkit/libpolkit-resource.c
@@ -127,7 +127,7 @@ libpolkit_resource_set_resource_type (Po
 {
         g_return_if_fail (resource != NULL);
 
-        if (resource->type == NULL)
+        if (resource->type != NULL)
                 g_free (resource->type);
         resource->type = g_strdup (resource_type);
 }
@@ -144,7 +144,7 @@ libpolkit_resource_set_resource_id (PolK
 {
         g_return_if_fail (resource != NULL);
 
-        if (resource->id == NULL)
+        if (resource->id != NULL)
                 g_free (resource->id);
         resource->id = g_strdup (resource_id);
 }
diff --git a/libpolkit/libpolkit-seat.c b/libpolkit/libpolkit-seat.c
index 0530468..4bbadf9 100644
--- a/libpolkit/libpolkit-seat.c
+++ b/libpolkit/libpolkit-seat.c
@@ -120,7 +120,7 @@ void 
 libpolkit_seat_set_ck_objref (PolKitSeat *seat, const char *ck_objref)
 {
         g_return_if_fail (seat != NULL);
-        if (seat->ck_objref == NULL)
+        if (seat->ck_objref != NULL)
                 g_free (seat->ck_objref);
         seat->ck_objref = g_strdup (ck_objref);
 }
diff --git a/libpolkit/libpolkit-session.c b/libpolkit/libpolkit-session.c
index 34ee2b8..268faf1 100644
--- a/libpolkit/libpolkit-session.c
+++ b/libpolkit/libpolkit-session.c
@@ -144,7 +144,7 @@ void 
 libpolkit_session_set_ck_objref (PolKitSession *session, const char *ck_objref)
 {
         g_return_if_fail (session != NULL);
-        if (session->ck_objref == NULL)
+        if (session->ck_objref != NULL)
                 g_free (session->ck_objref);
         session->ck_objref = g_strdup (ck_objref);
 }
@@ -190,7 +190,7 @@ void 
 libpolkit_session_set_ck_remote_host (PolKitSession *session, const char *remote_host)
 {
         g_return_if_fail (session != NULL);
-        if (session->remote_host == NULL)
+        if (session->remote_host != NULL)
                 g_free (session->remote_host);
         session->remote_host = g_strdup (remote_host);
 }
@@ -209,7 +209,7 @@ void 
 libpolkit_session_set_seat (PolKitSession *session, PolKitSeat *seat)
 {
         g_return_if_fail (session != NULL);
-        if (session->seat == NULL)
+        if (session->seat != NULL)
                 libpolkit_seat_unref (session->seat);
         session->seat = seat != NULL ? libpolkit_seat_ref (seat) : NULL;
 }
@@ -324,3 +324,242 @@ libpolkit_session_get_seat (PolKitSessio
         *out_seat = session->seat;
         return TRUE;
 }
+
+/**
+ * libpolkit_session_new_from_objpath:
+ * @con: D-Bus system bus connection
+ * @objpath: object path of ConsoleKit session object
+ * @uid: the user owning the session or -1 if unknown
+ * @error: D-Bus error
+ * 
+ * This function will construct a #PolKitSession object by querying
+ * the ConsoleKit daemon for information. Note that this will do a lot
+ * of blocking IO so it is best avoided if your process already
+ * tracks/caches all the information. If you pass in @uid as a
+ * non-negative number, a round trip can be saved.
+ * 
+ * Returns: the new object or #NULL if an error occured (in which case
+ * @error will be set)
+ **/
+PolKitSession *
+libpolkit_session_new_from_objpath (DBusConnection *con, const char *objpath, uid_t uid, DBusError *error)
+{
+        PolKitSeat *seat;
+        PolKitSession *session;
+        DBusMessage *message;
+        DBusMessage *reply;
+        char *str;
+        gboolean is_active;
+        gboolean is_local;
+        char *remote_host;
+        char *seat_path;
+
+        g_return_val_if_fail (con != NULL, NULL);
+        g_return_val_if_fail (objpath != NULL, NULL);
+        g_return_val_if_fail (error != NULL, NULL);
+        g_return_val_if_fail (! dbus_error_is_set (error), NULL);
+
+        session = NULL;
+        remote_host = NULL;
+        seat_path = NULL;
+
+	message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
+						objpath,
+						"org.freedesktop.ConsoleKit.Session",
+						"IsActive");
+	reply = dbus_connection_send_with_reply_and_block (con, message, -1, error);
+	if (reply == NULL || dbus_error_is_set (error)) {
+		g_warning ("Error doing Session.IsActive on ConsoleKit: %s: %s", error->name, error->message);
+		dbus_message_unref (message);
+		if (reply != NULL)
+			dbus_message_unref (reply);
+		goto out;
+	}
+	if (!dbus_message_get_args (reply, NULL,
+				    DBUS_TYPE_BOOLEAN, &is_active,
+                                    DBUS_TYPE_INVALID)) {
+                g_warning ("Invalid IsActive reply from CK");
+		goto out;
+	}
+	dbus_message_unref (message);
+	dbus_message_unref (reply);
+
+	message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
+						objpath,
+						"org.freedesktop.ConsoleKit.Session",
+						"IsLocal");
+	reply = dbus_connection_send_with_reply_and_block (con, message, -1, error);
+	if (reply == NULL || dbus_error_is_set (error)) {
+		g_warning ("Error doing Session.IsLocal on ConsoleKit: %s: %s", error->name, error->message);
+		dbus_message_unref (message);
+		if (reply != NULL)
+			dbus_message_unref (reply);
+		goto out;
+	}
+	if (!dbus_message_get_args (reply, NULL,
+				    DBUS_TYPE_BOOLEAN, &is_local,
+				    DBUS_TYPE_INVALID)) {
+		g_warning ("Invalid IsLocal reply from CK");
+		goto out;
+	}
+	dbus_message_unref (message);
+	dbus_message_unref (reply);
+
+        if (!is_local) {
+                message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
+                                                        objpath,
+                                                        "org.freedesktop.ConsoleKit.Session",
+                                                        "GetRemoteHostName");
+                reply = dbus_connection_send_with_reply_and_block (con, message, -1, error);
+                if (reply == NULL || dbus_error_is_set (error)) {
+                        g_warning ("Error doing Session.GetRemoteHostName on ConsoleKit: %s: %s", 
+                                   error->name, error->message);
+                        dbus_message_unref (message);
+                        if (reply != NULL)
+                                dbus_message_unref (reply);
+                        goto out;
+                }
+                if (!dbus_message_get_args (reply, NULL,
+                                            DBUS_TYPE_STRING, &str,
+                                            DBUS_TYPE_INVALID)) {
+                        g_warning ("Invalid GetRemoteHostName reply from CK");
+                        goto out;
+                }
+                remote_host = g_strdup (str);
+                dbus_message_unref (message);
+                dbus_message_unref (reply);
+        }
+
+        message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
+                                                objpath,
+                                                "org.freedesktop.ConsoleKit.Session",
+                                                "GetSeatId");
+        reply = dbus_connection_send_with_reply_and_block (con, message, -1, error);
+        if (reply == NULL || dbus_error_is_set (error)) {
+                g_warning ("Error doing Session.GetSeatId on ConsoleKit: %s: %s", 
+                           error->name, error->message);
+                dbus_message_unref (message);
+                if (reply != NULL)
+                        dbus_message_unref (reply);
+                goto out;
+        }
+        if (!dbus_message_get_args (reply, NULL,
+                                    DBUS_TYPE_OBJECT_PATH, &str,
+                                    DBUS_TYPE_INVALID)) {
+                g_warning ("Invalid GetSeatId reply from CK");
+                goto out;
+        }
+        seat_path = g_strdup (str);
+        dbus_message_unref (message);
+        dbus_message_unref (reply);
+
+        if ((int) uid == -1) {
+                message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
+                                                        objpath,
+                                                        "org.freedesktop.ConsoleKit.Session",
+                                                        "GetUnixUser");
+                reply = dbus_connection_send_with_reply_and_block (con, message, -1, error);
+                if (reply == NULL || dbus_error_is_set (error)) {
+                        g_warning ("Error doing Session.GetUnixUser on ConsoleKit: %s: %s",error->name, error->message);
+                        dbus_message_unref (message);
+                        if (reply != NULL)
+                                dbus_message_unref (reply);
+                        goto out;
+                }
+                if (!dbus_message_get_args (reply, NULL,
+                                            DBUS_TYPE_INT32, &uid,
+                                            DBUS_TYPE_INVALID)) {
+                        g_warning ("Invalid GetUnixUser reply from CK");
+                        goto out;
+                }
+                dbus_message_unref (message);
+                dbus_message_unref (reply);
+        }
+
+        g_debug ("is_active %d", is_active);
+        g_debug ("is_local %d", is_local);
+        g_debug ("uid %d", uid);
+        if (!is_local) {
+                g_debug ("remote host '%s'", remote_host);
+        }
+        g_debug ("ck seat '%s'", seat_path);
+
+        session = libpolkit_session_new ();
+        libpolkit_session_set_ck_is_active (session, is_active);
+        libpolkit_session_set_ck_is_local (session, is_local);
+        if (!is_local) {
+                libpolkit_session_set_ck_remote_host (session, remote_host);
+        }
+        seat = libpolkit_seat_new ();
+        libpolkit_seat_set_ck_objref (seat, seat_path);
+        libpolkit_session_set_seat (session, seat);
+        libpolkit_seat_unref (seat); /* we own this now */
+
+out:
+        g_free (remote_host);
+        g_free (seat_path);
+        return session;
+}
+
+/**
+ * libpolkit_session_new_from_cookie:
+ * @con: D-Bus system bus connection
+ * @cookie: a ConsoleKit XDG_SESSION_COOKIE
+ * @error: D-Bus error
+ * 
+ * This function will construct a #PolKitSession object by querying
+ * the ConsoleKit daemon for information. Note that this will do a lot
+ * of blocking IO so it is best avoided if your process already
+ * tracks/caches all the information.
+ * 
+ * Returns: the new object or #NULL if an error occured (in which case
+ * @error will be set)
+ **/
+PolKitSession *
+libpolkit_session_new_from_cookie (DBusConnection *con, const char *cookie, DBusError *error)
+{
+        PolKitSession *session;
+        DBusMessage *message;
+        DBusMessage *reply;
+        char *str;
+        char *objpath;
+
+        g_return_val_if_fail (con != NULL, NULL);
+        g_return_val_if_fail (cookie != NULL, NULL);
+        g_return_val_if_fail (error != NULL, NULL);
+        g_return_val_if_fail (! dbus_error_is_set (error), NULL);
+
+        objpath = NULL;
+        session = NULL;
+
+	message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", 
+						"/org/freedesktop/ConsoleKit/Manager",
+						"org.freedesktop.ConsoleKit.Manager",
+						"GetSessionForCookie");
+	dbus_message_append_args (message, DBUS_TYPE_STRING, &cookie, DBUS_TYPE_INVALID);
+	reply = dbus_connection_send_with_reply_and_block (con, message, -1, error);
+	if (reply == NULL || dbus_error_is_set (error)) {
+		g_warning ("Error doing Manager.GetSessionForCookie on ConsoleKit: %s: %s", 
+                           error->name, error->message);
+		dbus_message_unref (message);
+		if (reply != NULL)
+			dbus_message_unref (reply);
+		goto out;
+	}
+	if (!dbus_message_get_args (reply, NULL,
+				    DBUS_TYPE_OBJECT_PATH, &str,
+                                    DBUS_TYPE_INVALID)) {
+                g_warning ("Invalid GetSessionForCookie reply from CK");
+		goto out;
+	}
+        objpath = g_strdup (str);
+	dbus_message_unref (message);
+	dbus_message_unref (reply);
+
+        session = libpolkit_session_new_from_objpath (con, objpath, -1, error);
+
+out:
+        g_free (objpath);
+        return session;
+}
+
diff --git a/libpolkit/libpolkit-session.h b/libpolkit/libpolkit-session.h
index ee91ec0..08000bd 100644
--- a/libpolkit/libpolkit-session.h
+++ b/libpolkit/libpolkit-session.h
@@ -30,6 +30,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <glib.h>
+#include <dbus/dbus.h>
 
 #include <libpolkit/libpolkit-seat.h>
 
@@ -37,6 +38,8 @@ struct PolKitSession;
 typedef struct PolKitSession PolKitSession;
 
 PolKitSession *libpolkit_session_new                (void);
+PolKitSession *libpolkit_session_new_from_objpath   (DBusConnection *con, const char *objpath, uid_t uid, DBusError *error);
+PolKitSession *libpolkit_session_new_from_cookie    (DBusConnection *con, const char *cookie, DBusError *error);
 PolKitSession *libpolkit_session_ref                (PolKitSession *session);
 void           libpolkit_session_unref              (PolKitSession *session);
 void           libpolkit_session_set_uid            (PolKitSession *session, uid_t           uid);
@@ -53,5 +56,3 @@ gboolean       libpolkit_session_get_ck_
 gboolean       libpolkit_session_get_ck_remote_host (PolKitSession *session, char          **out_remote_host);
 
 #endif /* LIBPOLKIT_SESSION_H */
-
-
diff --git a/libpolkit/libpolkit.c b/libpolkit/libpolkit.c
index ae4e017..87ac370 100644
--- a/libpolkit/libpolkit.c
+++ b/libpolkit/libpolkit.c
@@ -23,6 +23,13 @@
  *
  **************************************************************************/
 
+/**
+ * SECTION:libpolkit
+ * @short_description: Policy functions.
+ *
+ * These functions are used to query system policy.
+ **/
+
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
diff --git a/libpolkit/libpolkit.h b/libpolkit/libpolkit.h
index a5aedab..59c0352 100644
--- a/libpolkit/libpolkit.h
+++ b/libpolkit/libpolkit.h
@@ -38,6 +38,8 @@
 #include <libpolkit/libpolkit-session.h>
 #include <libpolkit/libpolkit-caller.h>
 
+
+
 /**
  * PolKitSeatVisitorCB:
  * @seat: the seat
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 3f2f794..49eec4f 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -8,11 +8,16 @@ INCLUDES = \
 	-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
 	-I$(top_srcdir) \
-	-DDBUS_API_SUBJECT_TO_CHANGE \
 	@GLIB_CFLAGS@ \
 	@DBUS_CFLAGS@
 
-bin_PROGRAMS =
+bin_PROGRAMS = polkit-check-caller polkit-check-session
+
+polkit_check_caller_SOURCES = polkit-check-caller.c
+polkit_check_caller_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/libpolkit/libpolkit.la
+
+polkit_check_session_SOURCES = polkit-check-session.c
+polkit_check_session_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/libpolkit/libpolkit.la
 
 clean-local :
 	rm -f *~
diff --git a/tools/polkit-check-caller.c b/tools/polkit-check-caller.c
new file mode 100644
index 0000000..abaa53c
--- /dev/null
+++ b/tools/polkit-check-caller.c
@@ -0,0 +1,172 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * polkit-check-caller.c : check if a caller is privileged
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <getopt.h>
+#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.h>
+
+static void
+usage (int argc, char *argv[])
+{
+	fprintf (stderr,
+                 "\n"
+                 "usage : polkit-check-caller\n"
+                 "          --resource-type <type> --resource-id <id>\n"
+                 "          --privilege <privilege> --caller <dbus-name>\n"
+                 "          [--version] [--help]\n");
+	fprintf (stderr,
+                 "\n"
+                 "        --resource-type  Type of resource\n"
+                 "        --resource-id    Identifier of resource\n"
+                 "        --privilege      Requested privilege\n"
+                 "        --caller         Unique name of caller on the system bus\n"
+                 "        --version        Show version and exit\n"
+                 "        --help           Show this information and exit\n"
+                 "\n"
+                 "Determine if a given caller can access a given resource in a given\n"
+                 "way. If access is allowed, this program exits with exit code 0. If\n"
+                 "no access is allowed or an error occurs, the program exits with\n"
+                 "a non-zero exit code.\n");
+}
+
+int
+main (int argc, char *argv[])
+{
+        char *resource_type = NULL;
+        char *resource_id = NULL;
+        char *privilege_id = NULL;
+        char *dbus_name = NULL;
+        gboolean is_version = FALSE;
+        DBusConnection *bus;
+	DBusError error;
+        PolKitContext *pol_ctx;
+        PolKitCaller *caller;
+        PolKitResource *resource;
+        PolKitPrivilege *privilege;
+        gboolean allowed;
+
+	if (argc <= 1) {
+		usage (argc, argv);
+		return 1;
+	}
+
+	while (1) {
+		int c;
+		int option_index = 0;
+		const char *opt;
+		static struct option long_options[] = {
+			{"resource-type", 1, NULL, 0},
+			{"resource-id", 1, NULL, 0},
+			{"privilege", 1, NULL, 0},
+			{"caller", 1, NULL, 0},
+			{"version", 0, NULL, 0},
+			{"help", 0, NULL, 0},
+			{NULL, 0, NULL, 0}
+		};
+
+		c = getopt_long (argc, argv, "",
+				 long_options, &option_index);
+		if (c == -1)
+			break;
+
+		switch (c) {
+		case 0:
+			opt = long_options[option_index].name;
+
+			if (strcmp (opt, "help") == 0) {
+				usage (argc, argv);
+				return 0;
+			} else if (strcmp (opt, "version") == 0) {
+				is_version = TRUE;
+			} else if (strcmp (opt, "resource-type") == 0) {
+				resource_type = strdup (optarg);
+			} else if (strcmp (opt, "resource-id") == 0) {
+				resource_id = strdup (optarg);
+			} else if (strcmp (opt, "privilege") == 0) {
+				privilege_id = strdup (optarg);
+			} else if (strcmp (opt, "caller") == 0) {
+				dbus_name = strdup (optarg);
+			}
+			break;
+
+		default:
+			usage (argc, argv);
+			return 1;
+			break;
+		}
+	}
+
+	if (is_version) {
+		printf ("pk-can-caller-access-resource " PACKAGE_VERSION "\n");
+		return 0;
+	}
+
+	if (resource_type == NULL || resource_id == NULL || privilege_id == NULL || dbus_name == NULL) {
+		usage (argc, argv);
+		return 1;
+	}
+
+        dbus_error_init (&error);
+        bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+        if (bus == NULL) {
+		fprintf (stderr, "error: dbus_bus_get(): %s: %s\n", error.name, error.message);
+		return 1;
+	}
+
+        pol_ctx = libpolkit_context_new ();
+
+        privilege = libpolkit_privilege_new ();
+        libpolkit_privilege_set_privilege_id (privilege, privilege_id);
+
+        resource = libpolkit_resource_new ();
+        libpolkit_resource_set_resource_type (resource, resource_type);
+        libpolkit_resource_set_resource_id (resource, resource_id);
+
+        caller = libpolkit_caller_new_from_dbus_name (bus, dbus_name, &error);
+        if (caller == NULL) {
+                if (dbus_error_is_set (&error)) {
+                        fprintf (stderr, "error: libpolkit_caller_new_from_dbus_name(): %s: %s\n", 
+                                 error.name, error.message);
+                        return 1;
+                }
+        }
+
+        allowed = libpolkit_can_caller_access_resource (pol_ctx, privilege, resource, caller);
+
+        if (allowed)
+                return 0;
+        else
+                return 1;
+}
diff --git a/tools/polkit-check-session.c b/tools/polkit-check-session.c
new file mode 100644
index 0000000..81b2b24
--- /dev/null
+++ b/tools/polkit-check-session.c
@@ -0,0 +1,180 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * polkit-check-session.c : check if a session is privileged
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <getopt.h>
+#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.h>
+
+static void
+usage (int argc, char *argv[])
+{
+	fprintf (stderr,
+                 "\n"
+                 "usage : polkit-check-session\n"
+                 "          --resource-type <type> --resource-id <id>\n"
+                 "          --privilege <privilege> [--session <session>]\n"
+                 "          [--version] [--help]\n");
+	fprintf (stderr,
+                 "\n"
+                 "        --resource-type  Type of resource\n"
+                 "        --resource-id    Identifier of resource\n"
+                 "        --privilege      Requested privilege\n"
+                 "        --session        ConsoleKit object path of session\n"
+                 "        --version        Show version and exit\n"
+                 "        --help           Show this information and exit\n"
+                 "\n"
+                 "Determine if a given session can access a given resource in a given\n"
+                 "way. If no session is given, the current session is used. If access\n"
+                 "is allowed, this program exits with exit code 0. If no access is allowed\n"
+                 "or an error occurs, the program exits with a non-zero exit code.\n");
+}
+
+int
+main (int argc, char *argv[])
+{
+        char *resource_type = NULL;
+        char *resource_id = NULL;
+        char *privilege_id = NULL;
+        char *session_id = NULL;
+        char *cookie = NULL;
+        gboolean is_version = FALSE;
+        DBusConnection *bus;
+	DBusError error;
+        PolKitContext *pol_ctx;
+        PolKitSession *session;
+        PolKitResource *resource;
+        PolKitPrivilege *privilege;
+        gboolean allowed;
+
+	if (argc <= 1) {
+		usage (argc, argv);
+		return 1;
+	}
+
+        cookie = getenv ("XDG_SESSION_COOKIE");
+
+	while (1) {
+		int c;
+		int option_index = 0;
+		const char *opt;
+		static struct option long_options[] = {
+			{"resource-type", 1, NULL, 0},
+			{"resource-id", 1, NULL, 0},
+			{"privilege", 1, NULL, 0},
+			{"session", 1, NULL, 0},
+			{"version", 0, NULL, 0},
+			{"help", 0, NULL, 0},
+			{NULL, 0, NULL, 0}
+		};
+
+		c = getopt_long (argc, argv, "",
+				 long_options, &option_index);
+		if (c == -1)
+			break;
+
+		switch (c) {
+		case 0:
+			opt = long_options[option_index].name;
+
+			if (strcmp (opt, "help") == 0) {
+				usage (argc, argv);
+				return 0;
+			} else if (strcmp (opt, "version") == 0) {
+				is_version = TRUE;
+			} else if (strcmp (opt, "resource-type") == 0) {
+				resource_type = strdup (optarg);
+			} else if (strcmp (opt, "resource-id") == 0) {
+				resource_id = strdup (optarg);
+			} else if (strcmp (opt, "privilege") == 0) {
+				privilege_id = strdup (optarg);
+			} else if (strcmp (opt, "session") == 0) {
+				session_id = strdup (optarg);
+			}
+			break;
+
+		default:
+			usage (argc, argv);
+			return 1;
+			break;
+		}
+	}
+
+	if (is_version) {
+		printf ("pk-can-caller-access-resource " PACKAGE_VERSION "\n");
+		return 0;
+	}
+
+	if (resource_type == NULL || resource_id == NULL || privilege_id == NULL) {
+		usage (argc, argv);
+		return 1;
+	}
+
+        dbus_error_init (&error);
+        bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+        if (bus == NULL) {
+		fprintf (stderr, "error: dbus_bus_get(): %s: %s\n", error.name, error.message);
+		return 1;
+	}
+
+        pol_ctx = libpolkit_context_new ();
+
+        if (session_id != NULL) {
+                session = libpolkit_session_new_from_objpath (bus, session_id, -1, &error);
+        } else {
+                if (cookie == NULL) {
+                        fprintf (stderr, "Not part of a session. Try --session instead.\n");
+                        return 1;
+                }
+                session = libpolkit_session_new_from_cookie (bus, cookie, &error);
+        }
+        if (session == NULL) {
+		fprintf (stderr, "error: libpolkit_session_new_from_objpath: %s: %s\n", error.name, error.message);
+		return 1;
+        }
+
+        privilege = libpolkit_privilege_new ();
+        libpolkit_privilege_set_privilege_id (privilege, privilege_id);
+
+        resource = libpolkit_resource_new ();
+        libpolkit_resource_set_resource_type (resource, resource_type);
+        libpolkit_resource_set_resource_id (resource, resource_id);
+
+        allowed = libpolkit_can_session_access_resource (pol_ctx, privilege, resource, session);
+
+        if (allowed)
+                return 0;
+        else
+                return 1;
+}
diff-tree 5dabca219d230f8c66050467d6df7f392db5bcd8 (from a2974bdaadef0f06c3f8dd5d2c76170a53fe4b86)
Author: David Zeuthen <davidz at redhat.com>
Date:   Wed Mar 28 20:10:52 2007 -0400

    implement the classes carrying data

diff --git a/libpolkit/libpolkit-caller.c b/libpolkit/libpolkit-caller.c
index 6c40fde..4b59c36 100644
--- a/libpolkit/libpolkit-caller.c
+++ b/libpolkit/libpolkit-caller.c
@@ -54,6 +54,12 @@
  **/
 struct PolKitCaller
 {
+        int refcount;
+        char *dbus_name;
+        pid_t uid;
+        pid_t pid;
+        char *selinux_context;
+        PolKitSession *session;
 };
 
 /**
@@ -66,7 +72,10 @@ struct PolKitCaller
 PolKitCaller *
 libpolkit_caller_new (void)
 {
-        return NULL;
+        PolKitCaller *caller;
+        caller = g_new0 (PolKitCaller, 1);
+        caller->refcount = 1;
+        return caller;
 }
 
 /**
@@ -80,9 +89,34 @@ libpolkit_caller_new (void)
 PolKitCaller *
 libpolkit_caller_ref (PolKitCaller *caller)
 {
+        g_return_val_if_fail (caller != NULL, caller);
+        caller->refcount++;
         return caller;
 }
 
+
+/**
+ * libpolkit_caller_unref:
+ * @caller: The caller object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
+void
+libpolkit_caller_unref (PolKitCaller *caller)
+{
+        g_return_if_fail (caller != NULL);
+        caller->refcount--;
+        if (caller->refcount > 0) 
+                return;
+        g_free (caller->dbus_name);
+        g_free (caller->selinux_context);
+        if (caller->session != NULL)
+                libpolkit_session_unref (caller->session);
+        g_free (caller);
+}
+
 /**
  * libpolkit_caller_set_dbus_name:
  * @caller: The caller object
@@ -93,18 +127,24 @@ libpolkit_caller_ref (PolKitCaller *call
 void
 libpolkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name)
 {
+        g_return_if_fail (caller != NULL);
+        if (caller->dbus_name == NULL)
+                g_free (caller->dbus_name);
+        caller->dbus_name = g_strdup (dbus_name);
 }
 
 /**
- * libpolkit_caller_set_uid:
- * @caller: The caller object
- * @uid: UNIX user id
+ * libpolkit_caller_set_pid:
+ * @caller: The caller object 
+ * @pid: UNIX process id
  * 
- * Set the callers UNIX user id.
+ * Set the callers UNIX process id.
  **/
 void
 libpolkit_caller_set_uid (PolKitCaller *caller, uid_t uid)
 {
+        g_return_if_fail (caller != NULL);
+        caller->uid = uid;
 }
 
 /**
@@ -117,6 +157,8 @@ libpolkit_caller_set_uid (PolKitCaller *
 void
 libpolkit_caller_set_pid (PolKitCaller *caller, pid_t pid)
 {
+        g_return_if_fail (caller != NULL);
+        caller->pid = pid;
 }
 
 /**
@@ -129,6 +171,10 @@ libpolkit_caller_set_pid (PolKitCaller *
 void
 libpolkit_caller_set_selinux_context (PolKitCaller *caller, const char *selinux_context)
 {
+        g_return_if_fail (caller != NULL);
+        if (caller->selinux_context == NULL)
+                g_free (caller->selinux_context);
+        caller->selinux_context = g_strdup (selinux_context);
 }
 
 /**
@@ -143,6 +189,10 @@ libpolkit_caller_set_selinux_context (Po
 void
 libpolkit_caller_set_ck_session (PolKitCaller *caller, PolKitSession *session)
 {
+        g_return_if_fail (caller != NULL);
+        if (caller->session == NULL)
+                libpolkit_session_unref (caller->session);
+        caller->session = session != NULL ? libpolkit_session_ref (session) : NULL;
 }
 
 /**
@@ -157,22 +207,28 @@ libpolkit_caller_set_ck_session (PolKitC
 gboolean
 libpolkit_caller_get_dbus_name (PolKitCaller *caller, char **out_dbus_name)
 {
-        return FALSE;
+        g_return_val_if_fail (caller != NULL, FALSE);
+        g_return_val_if_fail (out_dbus_name != NULL, FALSE);
+        *out_dbus_name = caller->dbus_name;
+        return TRUE;
 }
 
 /**
- * libpolkit_caller_get_uid:
+ * libpolkit_caller_get_pid:
  * @caller: The caller object 
- * @out_uid: Returns the UNIX user id
+ * @out_pid: Returns the UNIX process id
  * 
- * Get the callers UNIX user id.
+ * Get the callers UNIX process id.
  * 
  * Returns: TRUE iff the value is returned
  **/
 gboolean
 libpolkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid)
 {
-        return FALSE;
+        g_return_val_if_fail (caller != NULL, FALSE);
+        g_return_val_if_fail (out_uid != NULL, FALSE);
+        *out_uid = caller->uid;
+        return TRUE;
 }
 
 /**
@@ -185,9 +241,12 @@ libpolkit_caller_get_uid (PolKitCaller *
  * Returns: TRUE iff the value is returned
  **/
 gboolean
-libpolkit_caller_get_pid (PolKitCaller *caller, uid_t *out_pid)
+libpolkit_caller_get_pid (PolKitCaller *caller, pid_t *out_pid)
 {
-        return FALSE;
+        g_return_val_if_fail (caller != NULL, FALSE);
+        g_return_val_if_fail (out_pid != NULL, FALSE);
+        *out_pid = caller->pid;
+        return TRUE;
 }
 
 /**
@@ -200,9 +259,12 @@ libpolkit_caller_get_pid (PolKitCaller *
  * Returns: TRUE iff the value is returned
  **/
 gboolean
-libpolkit_caller_get_selinux_context (PolKitCaller *caller, char *out_selinux_context)
+libpolkit_caller_get_selinux_context (PolKitCaller *caller, char **out_selinux_context)
 {
-        return FALSE;
+        g_return_val_if_fail (caller != NULL, FALSE);
+        g_return_val_if_fail (out_selinux_context != NULL, FALSE);
+        *out_selinux_context = caller->selinux_context;
+        return TRUE;
 }
 
 /**
@@ -217,18 +279,8 @@ libpolkit_caller_get_selinux_context (Po
 gboolean
 libpolkit_caller_get_ck_session (PolKitCaller *caller, PolKitSession **out_session)
 {
-        return FALSE;
-}
-
-/**
- * libpolkit_caller_unref:
- * @caller: The caller object
- * 
- * Decreases the reference count of the object. If it becomes zero,
- * the object is freed. Before freeing, reference counts on embedded
- * objects are decresed by one.
- **/
-void
-libpolkit_caller_unref (PolKitCaller *caller)
-{
+        g_return_val_if_fail (caller != NULL, FALSE);
+        g_return_val_if_fail (out_session != NULL, FALSE);
+        *out_session = caller->session;
+        return TRUE;
 }
diff --git a/libpolkit/libpolkit-caller.h b/libpolkit/libpolkit-caller.h
index a083a29..ddf0037 100644
--- a/libpolkit/libpolkit-caller.h
+++ b/libpolkit/libpolkit-caller.h
@@ -46,8 +46,8 @@ void              libpolkit_caller_set_s
 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, uid_t          *out_pid);
-gboolean          libpolkit_caller_get_selinux_context (PolKitCaller *caller, char           *out_selinux_context);
+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);
 
 #endif /* LIBPOLKIT_H */
diff --git a/libpolkit/libpolkit-context.c b/libpolkit/libpolkit-context.c
index be8cb25..2243af3 100644
--- a/libpolkit/libpolkit-context.c
+++ b/libpolkit/libpolkit-context.c
@@ -53,6 +53,9 @@
  **/
 struct PolKitContext
 {
+        int refcount;
+        PolKitContextConfigChangedCB config_changed_cb;
+        gpointer config_changed_user_data;
 };
 
 /**
@@ -65,7 +68,10 @@ struct PolKitContext
 PolKitContext *
 libpolkit_context_new (void)
 {
-        return FALSE;
+        PolKitContext *pk_context;
+        pk_context = g_new0 (PolKitContext, 1);
+        pk_context->refcount = 1;
+        return pk_context;
 }
 
 /**
@@ -79,10 +85,30 @@ libpolkit_context_new (void)
 PolKitContext *
 libpolkit_context_ref (PolKitContext *pk_context)
 {
+        g_return_val_if_fail (pk_context != NULL, pk_context);
+        pk_context->refcount++;
         return pk_context;
 }
 
 /**
+ * libpolkit_context_unref:
+ * @pk_context: the context object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
+void
+libpolkit_context_unref (PolKitContext *pk_context)
+{
+        g_return_if_fail (pk_context != NULL);
+        pk_context->refcount--;
+        if (pk_context->refcount > 0) 
+                return;
+        g_free (pk_context);
+}
+
+/**
  * libpolkit_context_set_config_changed:
  * @pk_context: the context object
  * @cb: the callback to invoke
@@ -98,18 +124,7 @@ libpolkit_context_set_config_changed (Po
                                       PolKitContextConfigChangedCB cb, 
                                       gpointer                     user_data)
 {
+        g_return_if_fail (pk_context != NULL);
+        pk_context->config_changed_cb = cb;
+        pk_context->config_changed_user_data = user_data;
 }
-
-/**
- * libpolkit_context_unref:
- * @pk_context: the context object
- * 
- * Decreases the reference count of the object. If it becomes zero,
- * the object is freed. Before freeing, reference counts on embedded
- * objects are decresed by one.
- **/
-void
-libpolkit_context_unref (PolKitContext *pk_context)
-{
-}
-
diff --git a/libpolkit/libpolkit-privilege.c b/libpolkit/libpolkit-privilege.c
index 2a7ce8a..f6a4634 100644
--- a/libpolkit/libpolkit-privilege.c
+++ b/libpolkit/libpolkit-privilege.c
@@ -54,6 +54,8 @@
  **/
 struct PolKitPrivilege
 {
+        int refcount;
+        char *id;
 };
 
 /**
@@ -66,7 +68,10 @@ struct PolKitPrivilege
 PolKitPrivilege *
 libpolkit_privilege_new (void)
 {
-        return NULL;
+        PolKitPrivilege *privilege;
+        privilege = g_new0 (PolKitPrivilege, 1);
+        privilege->refcount = 1;
+        return privilege;
 }
 
 /**
@@ -80,10 +85,31 @@ libpolkit_privilege_new (void)
 PolKitPrivilege *
 libpolkit_privilege_ref (PolKitPrivilege *privilege)
 {
+        g_return_val_if_fail (privilege != NULL, privilege);
+        privilege->refcount++;
         return privilege;
 }
 
 /**
+ * libpolkit_privilege_unref:
+ * @privilege: the privilege object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
+void
+libpolkit_privilege_unref (PolKitPrivilege *privilege)
+{
+        g_return_if_fail (privilege != NULL);
+        privilege->refcount--;
+        if (privilege->refcount > 0) 
+                return;
+        g_free (privilege->id);
+        g_free (privilege);
+}
+
+/**
  * libpolkit_privilege_set_privilege_id:
  * @privilege: the privilege object
  * @privilege_id: privilege identifier
@@ -93,6 +119,10 @@ libpolkit_privilege_ref (PolKitPrivilege
 void
 libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char  *privilege_id)
 {
+        g_return_if_fail (privilege != NULL);
+        if (privilege->id == NULL)
+                g_free (privilege->id);
+        privilege->id = g_strdup (privilege_id);
 }
 
 /**
@@ -107,18 +137,10 @@ libpolkit_privilege_set_privilege_id (Po
 gboolean
 libpolkit_privilege_get_privilege_id (PolKitPrivilege *privilege, char **out_privilege_id)
 {
-        return FALSE;
-}
-
-/**
- * libpolkit_privilege_unref:
- * @privilege: the privilege object
- * 
- * Decreases the reference count of the object. If it becomes zero,
- * the object is freed. Before freeing, reference counts on embedded
- * objects are decresed by one.
- **/
-void
-libpolkit_privilege_unref (PolKitPrivilege *privilege)
-{
+        g_return_val_if_fail (privilege != NULL, FALSE);
+        g_return_val_if_fail (out_privilege_id != NULL, FALSE);
+        if (privilege->id == NULL)
+                return FALSE;
+        *out_privilege_id = privilege->id;
+        return TRUE;
 }
diff --git a/libpolkit/libpolkit-resource.c b/libpolkit/libpolkit-resource.c
index 48315a4..8e53e84 100644
--- a/libpolkit/libpolkit-resource.c
+++ b/libpolkit/libpolkit-resource.c
@@ -54,6 +54,9 @@
  **/
 struct PolKitResource
 {
+        int refcount;
+        char *type;
+        char *id;
 };
 
 /**
@@ -66,7 +69,10 @@ struct PolKitResource
 PolKitResource *
 libpolkit_resource_new (void)
 {
-        return NULL;
+        PolKitResource *resource;
+        resource = g_new0 (PolKitResource, 1);
+        resource->refcount = 1;
+        return resource;
 }
 
 /**
@@ -80,9 +86,35 @@ libpolkit_resource_new (void)
 PolKitResource *
 libpolkit_resource_ref (PolKitResource *resource)
 {
+        g_return_val_if_fail (resource != NULL, resource);
+        resource->refcount++;
         return resource;
 }
 
+
+/**
+ * libpolkit_resource_unref:
+ * @resource: the resource object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
+void 
+libpolkit_resource_unref (PolKitResource *resource)
+{
+        g_return_if_fail (resource != NULL);
+
+        resource->refcount--;
+        if (resource->refcount > 0) 
+                return;
+
+        g_free (resource->type);
+        g_free (resource->id);
+        g_free (resource);
+}
+
+
 /**
  * libpolkit_resource_set_resource_type:
  * @resource: the resource object
@@ -93,6 +125,11 @@ libpolkit_resource_ref (PolKitResource *
 void
 libpolkit_resource_set_resource_type (PolKitResource *resource, const char  *resource_type)
 {
+        g_return_if_fail (resource != NULL);
+
+        if (resource->type == NULL)
+                g_free (resource->type);
+        resource->type = g_strdup (resource_type);
 }
 
 /**
@@ -105,6 +142,11 @@ libpolkit_resource_set_resource_type (Po
 void
 libpolkit_resource_set_resource_id (PolKitResource *resource, const char  *resource_id)
 {
+        g_return_if_fail (resource != NULL);
+
+        if (resource->id == NULL)
+                g_free (resource->id);
+        resource->id = g_strdup (resource_id);
 }
 
 /**
@@ -119,7 +161,14 @@ libpolkit_resource_set_resource_id (PolK
 gboolean
 libpolkit_resource_get_resource_type (PolKitResource *resource, char **out_resource_type)
 {
-        return FALSE;
+        g_return_val_if_fail (resource != NULL, FALSE);
+        g_return_val_if_fail (out_resource_type != NULL, FALSE);
+
+        if (resource->type == NULL)
+                return FALSE;
+
+        *out_resource_type = resource->type;
+        return TRUE;
 }
 
 /**
@@ -134,18 +183,12 @@ libpolkit_resource_get_resource_type (Po
 gboolean 
 libpolkit_resource_get_resource_id (PolKitResource *resource, char **out_resource_id)
 {
-        return FALSE;
-}
+        g_return_val_if_fail (resource != NULL, FALSE);
+        g_return_val_if_fail (out_resource_id != NULL, FALSE);
 
-/**
- * libpolkit_resource_unref:
- * @resource: the resource object
- * 
- * Decreases the reference count of the object. If it becomes zero,
- * the object is freed. Before freeing, reference counts on embedded
- * objects are decresed by one.
- **/
-void 
-libpolkit_resource_unref (PolKitResource *resource)
-{
+        if (resource->id == NULL)
+                return FALSE;
+
+        *out_resource_id = resource->id;
+        return TRUE;
 }
diff --git a/libpolkit/libpolkit-seat.c b/libpolkit/libpolkit-seat.c
index c2be5aa..0530468 100644
--- a/libpolkit/libpolkit-seat.c
+++ b/libpolkit/libpolkit-seat.c
@@ -54,6 +54,8 @@
  **/
 struct PolKitSeat
 {
+        int refcount;
+        char *ck_objref;
 };
 
 /**
@@ -66,7 +68,10 @@ struct PolKitSeat
 PolKitSeat *
 libpolkit_seat_new (void)
 {
-        return NULL;
+        PolKitSeat *seat;
+        seat = g_new0 (PolKitSeat, 1);
+        seat->refcount = 1;
+        return seat;
 }
 
 /**
@@ -80,10 +85,31 @@ libpolkit_seat_new (void)
 PolKitSeat *
 libpolkit_seat_ref (PolKitSeat *seat)
 {
+        g_return_val_if_fail (seat != NULL, seat);
+        seat->refcount++;
         return seat;
 }
 
 /**
+ * libpolkit_seat_unref:
+ * @seat: the seat object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
+void
+libpolkit_seat_unref (PolKitSeat *seat)
+{
+        g_return_if_fail (seat != NULL);
+        seat->refcount--;
+        if (seat->refcount > 0) 
+                return;
+        g_free (seat->ck_objref);
+        g_free (seat);
+}
+
+/**
  * libpolkit_seat_set_ck_objref:
  * @seat: the seat object
  * @ck_objref: the D-Bus object path to the ConsoleKit seat object
@@ -93,6 +119,10 @@ libpolkit_seat_ref (PolKitSeat *seat)
 void 
 libpolkit_seat_set_ck_objref (PolKitSeat *seat, const char *ck_objref)
 {
+        g_return_if_fail (seat != NULL);
+        if (seat->ck_objref == NULL)
+                g_free (seat->ck_objref);
+        seat->ck_objref = g_strdup (ck_objref);
 }
 
 /**
@@ -107,18 +137,8 @@ libpolkit_seat_set_ck_objref (PolKitSeat
 gboolean
 libpolkit_seat_get_ck_objref (PolKitSeat *seat, char **out_ck_objref)
 {
-        return FALSE;
-}
-
-/**
- * libpolkit_seat_unref:
- * @seat: the seat object
- * 
- * Decreases the reference count of the object. If it becomes zero,
- * the object is freed. Before freeing, reference counts on embedded
- * objects are decresed by one.
- **/
-void
-libpolkit_seat_unref (PolKitSeat *seat)
-{
+        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;
 }
diff --git a/libpolkit/libpolkit-session.c b/libpolkit/libpolkit-session.c
index 2c47d9a..34ee2b8 100644
--- a/libpolkit/libpolkit-session.c
+++ b/libpolkit/libpolkit-session.c
@@ -55,6 +55,13 @@
  **/
 struct PolKitSession
 {
+        int refcount;
+        uid_t uid;
+        PolKitSeat *seat;
+        char *ck_objref;
+        gboolean is_active;
+        gboolean is_local;
+        char *remote_host;
 };
 
 /**
@@ -67,7 +74,10 @@ struct PolKitSession
 PolKitSession *
 libpolkit_session_new (void)
 {
-        return NULL;
+        PolKitSession *session;
+        session = g_new0 (PolKitSession, 1);
+        session->refcount = 1;
+        return session;
 }
 
 /**
@@ -81,7 +91,32 @@ libpolkit_session_new (void)
 PolKitSession *
 libpolkit_session_ref (PolKitSession *session)
 {
-        return NULL;
+        g_return_val_if_fail (session != NULL, session);
+        session->refcount++;
+        return session;
+}
+
+
+/**
+ * libpolkit_session_unref:
+ * @session: The session object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
+void 
+libpolkit_session_unref (PolKitSession *session)
+{
+        g_return_if_fail (session != NULL);
+        session->refcount--;
+        if (session->refcount > 0) 
+                return;
+        g_free (session->ck_objref);
+        g_free (session->remote_host);
+        if (session->seat != NULL)
+                libpolkit_seat_unref (session->seat);
+        g_free (session);
 }
 
 /**
@@ -94,6 +129,8 @@ libpolkit_session_ref (PolKitSession *se
 void 
 libpolkit_session_set_uid (PolKitSession *session, uid_t uid)
 {
+        g_return_if_fail (session != NULL);
+        session->uid = uid;
 }
 
 /**
@@ -106,6 +143,10 @@ libpolkit_session_set_uid (PolKitSession
 void 
 libpolkit_session_set_ck_objref (PolKitSession *session, const char *ck_objref)
 {
+        g_return_if_fail (session != NULL);
+        if (session->ck_objref == NULL)
+                g_free (session->ck_objref);
+        session->ck_objref = g_strdup (ck_objref);
 }
 
 /**
@@ -118,6 +159,8 @@ libpolkit_session_set_ck_objref (PolKitS
 void 
 libpolkit_session_set_ck_is_active (PolKitSession *session, gboolean is_active)
 {
+        g_return_if_fail (session != NULL);
+        session->is_active = is_active;
 }
 
 /**
@@ -130,6 +173,8 @@ libpolkit_session_set_ck_is_active (PolK
 void 
 libpolkit_session_set_ck_is_local (PolKitSession *session, gboolean is_local)
 {
+        g_return_if_fail (session != NULL);
+        session->is_local = is_local;
 }
 
 /**
@@ -144,6 +189,10 @@ libpolkit_session_set_ck_is_local (PolKi
 void 
 libpolkit_session_set_ck_remote_host (PolKitSession *session, const char *remote_host)
 {
+        g_return_if_fail (session != NULL);
+        if (session->remote_host == NULL)
+                g_free (session->remote_host);
+        session->remote_host = g_strdup (remote_host);
 }
 
 /**
@@ -159,6 +208,10 @@ libpolkit_session_set_ck_remote_host (Po
 void 
 libpolkit_session_set_seat (PolKitSession *session, PolKitSeat *seat)
 {
+        g_return_if_fail (session != NULL);
+        if (session->seat == NULL)
+                libpolkit_seat_unref (session->seat);
+        session->seat = seat != NULL ? libpolkit_seat_ref (seat) : NULL;
 }
 
 /**
@@ -173,7 +226,10 @@ libpolkit_session_set_seat (PolKitSessio
 gboolean
 libpolkit_session_get_uid (PolKitSession *session, uid_t *out_uid)
 {
-        return FALSE;
+        g_return_val_if_fail (session != NULL, FALSE);
+        g_return_val_if_fail (out_uid != NULL, FALSE);
+        *out_uid = session->uid;
+        return TRUE;
 }
 
 /**
@@ -188,7 +244,10 @@ libpolkit_session_get_uid (PolKitSession
 gboolean
 libpolkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref)
 {
-        return FALSE;
+        g_return_val_if_fail (session != NULL, FALSE);
+        g_return_val_if_fail (out_ck_objref != NULL, FALSE);
+        *out_ck_objref = session->ck_objref;
+        return TRUE;
 }
 
 /**
@@ -203,7 +262,10 @@ libpolkit_session_get_ck_objref (PolKitS
 gboolean
 libpolkit_session_get_ck_is_active (PolKitSession *session, gboolean *out_is_active)
 {
-        return FALSE;
+        g_return_val_if_fail (session != NULL, FALSE);
+        g_return_val_if_fail (out_is_active != NULL, FALSE);
+        *out_is_active = session->is_active;
+        return TRUE;
 }
 
 /**
@@ -218,7 +280,10 @@ libpolkit_session_get_ck_is_active (PolK
 gboolean
 libpolkit_session_get_ck_is_local (PolKitSession *session, gboolean *out_is_local)
 {
-        return FALSE;
+        g_return_val_if_fail (session != NULL, FALSE);
+        g_return_val_if_fail (out_is_local != NULL, FALSE);
+        *out_is_local = session->is_local;
+        return TRUE;
 }
 
 /**
@@ -233,9 +298,12 @@ libpolkit_session_get_ck_is_local (PolKi
  * Returns: TRUE iff the value is returned
  **/
 gboolean
-libpolkit_session_get_ck_remote_host (PolKitSession *session, char *out_remote_host)
+libpolkit_session_get_ck_remote_host (PolKitSession *session, char **out_remote_host)
 {
-        return FALSE;
+        g_return_val_if_fail (session != NULL, FALSE);
+        g_return_val_if_fail (out_remote_host != NULL, FALSE);
+        *out_remote_host = session->remote_host;
+        return TRUE;
 }
 
 /**
@@ -251,18 +319,8 @@ libpolkit_session_get_ck_remote_host (Po
 gboolean
 libpolkit_session_get_seat (PolKitSession *session, PolKitSeat **out_seat)
 {
-        return FALSE;
-}
-
-/**
- * libpolkit_session_unref:
- * @session: The session object
- * 
- * Decreases the reference count of the object. If it becomes zero,
- * the object is freed. Before freeing, reference counts on embedded
- * objects are decresed by one.
- **/
-void 
-libpolkit_session_unref (PolKitSession *session)
-{
+        g_return_val_if_fail (session != NULL, FALSE);
+        g_return_val_if_fail (out_seat != NULL, FALSE);
+        *out_seat = session->seat;
+        return TRUE;
 }
diff --git a/libpolkit/libpolkit-session.h b/libpolkit/libpolkit-session.h
index 46fcc97..ee91ec0 100644
--- a/libpolkit/libpolkit-session.h
+++ b/libpolkit/libpolkit-session.h
@@ -50,7 +50,7 @@ gboolean       libpolkit_session_get_sea
 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);
+gboolean       libpolkit_session_get_ck_remote_host (PolKitSession *session, char          **out_remote_host);
 
 #endif /* LIBPOLKIT_SESSION_H */
 
diff-tree a2974bdaadef0f06c3f8dd5d2c76170a53fe4b86 (from 96e73f52582e3517d0925fa402bb4bb349123b10)
Author: David Zeuthen <davidz at redhat.com>
Date:   Wed Mar 28 18:08:50 2007 -0400

    document the API
    
    Now I only need to implement it...

diff --git a/doc/api/libpolkit/libpolkit-docs.xml b/doc/api/libpolkit/libpolkit-docs.xml
index 10f3fcf..318d7bb 100644
--- a/doc/api/libpolkit/libpolkit-docs.xml
+++ b/doc/api/libpolkit/libpolkit-docs.xml
@@ -64,7 +64,15 @@
 	PolicyKit library.
       </para>
     </partintro>
-    <xi:include href="xml/libpolkit.xml"/>
+    <title>
+      <xi:include href="xml/libpolkit.xml"/>
+    </title>
+    <xi:include href="xml/libpolkit-context.xml"/>
+    <xi:include href="xml/libpolkit-privilege.xml"/>
+    <xi:include href="xml/libpolkit-resource.xml"/>
+    <xi:include href="xml/libpolkit-seat.xml"/>
+    <xi:include href="xml/libpolkit-session.xml"/>
+    <xi:include href="xml/libpolkit-caller.xml"/>
   </reference>
 
   <index>
diff --git a/libpolkit/libpolkit-caller.c b/libpolkit/libpolkit-caller.c
index 0801378..6c40fde 100644
--- a/libpolkit/libpolkit-caller.c
+++ b/libpolkit/libpolkit-caller.c
@@ -23,6 +23,13 @@
  *
  **************************************************************************/
 
+/**
+ * SECTION:libpolkit-caller
+ * @short_description: Callers on the system message bus.
+ *
+ * This class is used to represent a caller in another process connected to the system message bus.
+ **/
+
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
@@ -39,77 +46,188 @@
 #include <glib.h>
 #include "libpolkit-caller.h"
 
-struct PolKitCaller_s
+/**
+ * PolKitCaller:
+ *
+ * Objects of this class are used to record information about a caller
+ * on the system bus.
+ **/
+struct PolKitCaller
 {
 };
 
+/**
+ * libpolkit_caller_new:
+ *
+ * Creates a new #PolKitCaller object.
+ *
+ * Returns: the new object
+ **/
 PolKitCaller *
 libpolkit_caller_new (void)
 {
         return NULL;
 }
 
+/**
+ * libpolkit_caller_ref:
+ * @caller: The caller object
+ * 
+ * Increase reference count.
+ * 
+ * Returns: the object
+ **/
 PolKitCaller *
 libpolkit_caller_ref (PolKitCaller *caller)
 {
         return caller;
 }
 
+/**
+ * libpolkit_caller_set_dbus_name:
+ * @caller: The caller object
+ * @dbus_name: unique system bus connection name
+ * 
+ * Set the callers unique system bus connection name.
+ **/
 void
 libpolkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name)
 {
 }
 
+/**
+ * libpolkit_caller_set_uid:
+ * @caller: The caller object
+ * @uid: UNIX user id
+ * 
+ * Set the callers UNIX user id.
+ **/
 void
 libpolkit_caller_set_uid (PolKitCaller *caller, uid_t uid)
 {
 }
 
+/**
+ * libpolkit_caller_set_pid:
+ * @caller: The caller object 
+ * @pid: UNIX process id
+ * 
+ * Set the callers UNIX process id.
+ **/
 void
 libpolkit_caller_set_pid (PolKitCaller *caller, pid_t pid)
 {
 }
 
+/**
+ * libpolkit_caller_set_selinux_context:
+ * @caller: The caller object 
+ * @selinux_context: SELinux security context
+ * 
+ * Set the callers SELinux security context.
+ **/
 void
 libpolkit_caller_set_selinux_context (PolKitCaller *caller, const char *selinux_context)
 {
 }
 
+/**
+ * libpolkit_caller_set_ck_session:
+ * @caller: The caller object 
+ * @session: a session object
+ * 
+ * Set the callers session. The reference count on the given object
+ * will be increased by one. If an existing session object was set
+ * already, the reference count on that one will be decreased by one.
+ **/
 void
 libpolkit_caller_set_ck_session (PolKitCaller *caller, PolKitSession *session)
 {
 }
 
+/**
+ * libpolkit_caller_get_dbus_name:
+ * @caller: The caller object 
+ * @out_dbus_name: Returns the unique system bus connection name. The caller shall not free this string.
+ * 
+ * Get the callers unique system bus connection name.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
 gboolean
 libpolkit_caller_get_dbus_name (PolKitCaller *caller, char **out_dbus_name)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_caller_get_uid:
+ * @caller: The caller object 
+ * @out_uid: Returns the UNIX user id
+ * 
+ * Get the callers UNIX user id.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
 gboolean
 libpolkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_caller_get_pid:
+ * @caller: The caller object 
+ * @out_pid: Returns the UNIX process id
+ * 
+ * Get the callers UNIX process id.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
 gboolean
 libpolkit_caller_get_pid (PolKitCaller *caller, uid_t *out_pid)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_caller_get_selinux_context:
+ * @caller: The caller object 
+ * @out_selinux_context: Returns the SELinux security context. The caller shall not free this string.
+ * 
+ * Get the callers SELinux security context.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
 gboolean
 libpolkit_caller_get_selinux_context (PolKitCaller *caller, char *out_selinux_context)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_caller_get_ck_session:
+ * @caller: The caller object 
+ * @out_session: Returns the session object. Caller shall not unref it.
+ * 
+ * Get the callers session.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
 gboolean
 libpolkit_caller_get_ck_session (PolKitCaller *caller, PolKitSession **out_session)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_caller_unref:
+ * @caller: The caller object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
 void
 libpolkit_caller_unref (PolKitCaller *caller)
 {
diff --git a/libpolkit/libpolkit-caller.h b/libpolkit/libpolkit-caller.h
index d8928eb..a083a29 100644
--- a/libpolkit/libpolkit-caller.h
+++ b/libpolkit/libpolkit-caller.h
@@ -33,22 +33,22 @@
 
 #include <libpolkit/libpolkit-session.h>
 
-struct PolKitCaller_s;
-typedef struct PolKitCaller_s PolKitCaller;
+struct PolKitCaller;
+typedef struct PolKitCaller PolKitCaller;
 
 PolKitCaller     *libpolkit_caller_new                 (void);
 PolKitCaller     *libpolkit_caller_ref                 (PolKitCaller *caller);
-void              libpolkit_caller_set_dbus_name       (PolKitCaller *caller, const char *dbus_name);
-void              libpolkit_caller_set_uid             (PolKitCaller *caller, uid_t       uid);
-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_unref               (PolKitCaller *caller);
+void              libpolkit_caller_set_dbus_name       (PolKitCaller *caller, const char     *dbus_name);
+void              libpolkit_caller_set_uid             (PolKitCaller *caller, uid_t           uid);
+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, uid_t      *out_pid);
-gboolean          libpolkit_caller_get_selinux_context (PolKitCaller *caller, char       *out_selinux_context);
+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, uid_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);
-void              libpolkit_caller_unref               (PolKitCaller *caller);
 
 #endif /* LIBPOLKIT_H */
 
diff --git a/libpolkit/libpolkit-context.c b/libpolkit/libpolkit-context.c
index 4f42b79..be8cb25 100644
--- a/libpolkit/libpolkit-context.c
+++ b/libpolkit/libpolkit-context.c
@@ -39,22 +39,60 @@
 #include <glib.h>
 #include "libpolkit-context.h"
 
-struct PolKitContext_s
+/**
+ * SECTION:libpolkit-context
+ * @short_description: Context.
+ *
+ * This class is used to represent the interface to PolicyKit.
+ **/
+
+/**
+ * PolKitContext:
+ *
+ * Context object for users of PolicyKit.
+ **/
+struct PolKitContext
 {
 };
 
+/**
+ * libpolkit_context_new:
+ * 
+ * Create a new context.
+ * 
+ * Returns: the new context object
+ **/
 PolKitContext *
 libpolkit_context_new (void)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_context_ref:
+ * @pk_context: the context object
+ * 
+ * Increase reference count.
+ * 
+ * Returns: the object
+ **/
 PolKitContext *
 libpolkit_context_ref (PolKitContext *pk_context)
 {
         return pk_context;
 }
 
+/**
+ * libpolkit_context_set_config_changed:
+ * @pk_context: the context object
+ * @cb: the callback to invoke
+ * @user_data: user data to pass to the callback
+ * 
+ * Register the callback function for when configuration changes.
+ * Mechanisms should use this callback to e.g. reconfigure all
+ * permissions / acl's they have set in response to policy decisions
+ * made from information provided by PolicyKit.
+ **/
 void
 libpolkit_context_set_config_changed (PolKitContext                *pk_context, 
                                       PolKitContextConfigChangedCB cb, 
@@ -62,6 +100,14 @@ libpolkit_context_set_config_changed (Po
 {
 }
 
+/**
+ * libpolkit_context_unref:
+ * @pk_context: the context object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
 void
 libpolkit_context_unref (PolKitContext *pk_context)
 {
diff --git a/libpolkit/libpolkit-context.h b/libpolkit/libpolkit-context.h
index 2a228e1..dffb5f5 100644
--- a/libpolkit/libpolkit-context.h
+++ b/libpolkit/libpolkit-context.h
@@ -31,19 +31,15 @@
 #include <sys/types.h>
 #include <glib.h>
 
-struct PolKitContext_s;
-
-typedef struct PolKitContext_s PolKitContext;
+struct PolKitContext;
+typedef struct PolKitContext PolKitContext;
 
 /**
  * PolKitContextConfigChangedCB:
  * @pk_context: PolicyKit context
  * @user_data: user data
  *
- * Called when configuration changes. Mechanisms should listen on this
- * signal and e.g. reconfigure all permissions / acl's they have set
- * in response to policy decisions made from information provided by
- * PolicyKit.
+ * See libpolkit_context_set_config_changed() for details.
  */
 typedef void (*PolKitContextConfigChangedCB) (PolKitContext  *pk_context,
                                               gpointer        user_data);
diff --git a/libpolkit/libpolkit-privilege.c b/libpolkit/libpolkit-privilege.c
index 80d9b67..2a7ce8a 100644
--- a/libpolkit/libpolkit-privilege.c
+++ b/libpolkit/libpolkit-privilege.c
@@ -39,33 +39,85 @@
 #include <glib.h>
 #include "libpolkit-privilege.h"
 
-struct PolKitPrivilege_s
+/**
+ * SECTION:libpolkit-privilege
+ * @short_description: Privileges.
+ *
+ * This class is used to represent a privilege. TODO: describe what a privilege really is.
+ **/
+
+/**
+ * PolKitPrivilege:
+ *
+ * Objects of this class are used to record information about a
+ * privilege.
+ **/
+struct PolKitPrivilege
 {
 };
 
+/**
+ * libpolkit_privilege_new:
+ * 
+ * Create a new #PolKitPrivilege object.
+ * 
+ * Returns: the new object
+ **/
 PolKitPrivilege *
 libpolkit_privilege_new (void)
 {
         return NULL;
 }
 
+/**
+ * libpolkit_privilege_ref:
+ * @privilege: the privilege object
+ * 
+ * Increase reference count.
+ * 
+ * Returns: the object
+ **/
 PolKitPrivilege *
 libpolkit_privilege_ref (PolKitPrivilege *privilege)
 {
         return privilege;
 }
 
+/**
+ * libpolkit_privilege_set_privilege_id:
+ * @privilege: the privilege object
+ * @privilege_id: privilege identifier
+ * 
+ * Set the privilege identifier
+ **/
 void
 libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char  *privilege_id)
 {
 }
 
+/**
+ * libpolkit_privilege_get_privilege_id:
+ * @privilege: the privilege object
+ * @out_privilege_id: Returns the privilege identifier. The caller shall not free this string.
+ * 
+ * Get the privilege identifier.
+ * 
+ * Returns: TRUE iff the value was returned.
+ **/
 gboolean
 libpolkit_privilege_get_privilege_id (PolKitPrivilege *privilege, char **out_privilege_id)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_privilege_unref:
+ * @privilege: the privilege object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
 void
 libpolkit_privilege_unref (PolKitPrivilege *privilege)
 {
diff --git a/libpolkit/libpolkit-privilege.h b/libpolkit/libpolkit-privilege.h
index 549a846..092f565 100644
--- a/libpolkit/libpolkit-privilege.h
+++ b/libpolkit/libpolkit-privilege.h
@@ -31,14 +31,14 @@
 #include <sys/types.h>
 #include <glib.h>
 
-struct PolKitPrivilege_s;
-typedef struct PolKitPrivilege_s PolKitPrivilege;
+struct PolKitPrivilege;
+typedef struct PolKitPrivilege PolKitPrivilege;
 
 PolKitPrivilege *libpolkit_privilege_new              (void);
 PolKitPrivilege *libpolkit_privilege_ref              (PolKitPrivilege *privilege);
+void             libpolkit_privilege_unref            (PolKitPrivilege *privilege);
 void             libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char  *privilege_id);
 gboolean         libpolkit_privilege_get_privilege_id (PolKitPrivilege *privilege, char       **out_privilege_id);
-void             libpolkit_privilege_unref            (PolKitPrivilege *privilege);
 
 #endif /* LIBPOLKIT_PRIVILEGE_H */
 
diff --git a/libpolkit/libpolkit-resource.c b/libpolkit/libpolkit-resource.c
index 15b62c6..48315a4 100644
--- a/libpolkit/libpolkit-resource.c
+++ b/libpolkit/libpolkit-resource.c
@@ -39,44 +39,112 @@
 #include <glib.h>
 #include "libpolkit-resource.h"
 
-struct PolKitResource_s
+/**
+ * SECTION:libpolkit-resource
+ * @short_description: Resources.
+ *
+ * This class is used to represent a resource. TODO: describe what a resource really is.
+ **/
+
+/**
+ * PolKitResource:
+ *
+ * Objects of this class are used to record information about a
+ * resource. TODO: describe what a resource really is.
+ **/
+struct PolKitResource
 {
 };
 
+/**
+ * libpolkit_resource_new:
+ * 
+ * Create a new #PolKitResource object.
+ * 
+ * Returns: the new object
+ **/
 PolKitResource *
 libpolkit_resource_new (void)
 {
         return NULL;
 }
 
+/**
+ * libpolkit_resource_ref:
+ * @resource: the resource object
+ * 
+ * Increase reference count
+ * 
+ * Returns: the object
+ **/
 PolKitResource *
 libpolkit_resource_ref (PolKitResource *resource)
 {
         return resource;
 }
 
+/**
+ * libpolkit_resource_set_resource_type:
+ * @resource: the resource object
+ * @resource_type: type of resource
+ * 
+ * Set the type of the resource. TODO: link to wtf this is.
+ **/
 void
 libpolkit_resource_set_resource_type (PolKitResource *resource, const char  *resource_type)
 {
 }
 
+/**
+ * libpolkit_resource_set_resource_id:
+ * @resource: the resource object
+ * @resource_id: identifier of resource
+ * 
+ * set the identifier of the resource. TODO: link to wtf this is.
+ **/
 void
 libpolkit_resource_set_resource_id (PolKitResource *resource, const char  *resource_id)
 {
 }
 
+/**
+ * libpolkit_resource_get_resource_type:
+ * @resource: the resource object
+ * @out_resource_type: Returns the resource type. The caller shall not free this string.
+ * 
+ * Get the type of the resource.
+ * 
+ * Returns: TRUE iff the value was returned.
+ **/
 gboolean
 libpolkit_resource_get_resource_type (PolKitResource *resource, char **out_resource_type)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_resource_get_resource_id:
+ * @resource: the resource object
+ * @out_resource_id: Returns the resource identifier. The caller shall not free this string.
+ * 
+ * Get the identifier of the resource
+ * 
+ * Returns: TRUE iff the value was returned.
+ **/
 gboolean 
 libpolkit_resource_get_resource_id (PolKitResource *resource, char **out_resource_id)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_resource_unref:
+ * @resource: the resource object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
 void 
 libpolkit_resource_unref (PolKitResource *resource)
 {
diff --git a/libpolkit/libpolkit-resource.h b/libpolkit/libpolkit-resource.h
index 4751f59..91e0a7e 100644
--- a/libpolkit/libpolkit-resource.h
+++ b/libpolkit/libpolkit-resource.h
@@ -31,16 +31,16 @@
 #include <sys/types.h>
 #include <glib.h>
 
-struct PolKitResource_s;
-typedef struct PolKitResource_s PolKitResource;
+struct PolKitResource;
+typedef struct PolKitResource PolKitResource;
 
 PolKitResource *libpolkit_resource_new               (void);
 PolKitResource *libpolkit_resource_ref               (PolKitResource *resource);
+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);
-void            libpolkit_resource_unref             (PolKitResource *resource);
 
 #endif /* LIBPOLKIT_RESOURCE_H */
 
diff --git a/libpolkit/libpolkit-seat.c b/libpolkit/libpolkit-seat.c
index adaa45f..c2be5aa 100644
--- a/libpolkit/libpolkit-seat.c
+++ b/libpolkit/libpolkit-seat.c
@@ -39,33 +39,85 @@
 #include <glib.h>
 #include "libpolkit-seat.h"
 
-struct PolKitSeat_s
+/**
+ * SECTION:libpolkit-seat
+ * @short_description: Seats.
+ *
+ * This class is used to represent a seat. TODO: describe seat.
+ **/
+
+/**
+ * PolKitSeat:
+ *
+ * Objects of this class are used to record information about a
+ * seat.
+ **/
+struct PolKitSeat
 {
 };
 
+/**
+ * libpolkit_seat_new:
+ * 
+ * Creates a new #PolKitSeat object.
+ * 
+ * Returns: the new object
+ **/
 PolKitSeat *
 libpolkit_seat_new (void)
 {
         return NULL;
 }
 
+/**
+ * libpolkit_seat_ref:
+ * @seat: the seat object
+ * 
+ * Increase reference count.
+ * 
+ * Returns: the object
+ **/
 PolKitSeat *
 libpolkit_seat_ref (PolKitSeat *seat)
 {
         return seat;
 }
 
+/**
+ * libpolkit_seat_set_ck_objref:
+ * @seat: the seat object
+ * @ck_objref: the D-Bus object path to the ConsoleKit seat object
+ * 
+ * Set the D-Bus object path to the ConsoleKit seat object.
+ **/
 void 
 libpolkit_seat_set_ck_objref (PolKitSeat *seat, const char *ck_objref)
 {
 }
 
+/**
+ * libpolkit_seat_get_ck_objref:
+ * @seat: the seat object
+ * @out_ck_objref: Returns the D-Bus object path to the ConsoleKit seat object. The caller shall not free this string.
+ * 
+ * Get the D-Bus object path to the ConsoleKit seat object.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
 gboolean
 libpolkit_seat_get_ck_objref (PolKitSeat *seat, char **out_ck_objref)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_seat_unref:
+ * @seat: the seat object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
 void
 libpolkit_seat_unref (PolKitSeat *seat)
 {
diff --git a/libpolkit/libpolkit-seat.h b/libpolkit/libpolkit-seat.h
index aeeaebc..27be25b 100644
--- a/libpolkit/libpolkit-seat.h
+++ b/libpolkit/libpolkit-seat.h
@@ -31,14 +31,14 @@
 #include <sys/types.h>
 #include <glib.h>
 
-struct PolKitSeat_s;
-typedef struct PolKitSeat_s PolKitSeat;
+struct PolKitSeat;
+typedef struct PolKitSeat PolKitSeat;
 
-PolKitSeat     *libpolkit_seat_new             (void);
-PolKitSeat     *libpolkit_seat_ref             (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);
-void            libpolkit_seat_unref           (PolKitSeat *seat);
+PolKitSeat *libpolkit_seat_new           (void);
+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);
 
 #endif /* LIBPOLKIT_SEAT_H */
 
diff --git a/libpolkit/libpolkit-session.c b/libpolkit/libpolkit-session.c
index 13971ea..2c47d9a 100644
--- a/libpolkit/libpolkit-session.c
+++ b/libpolkit/libpolkit-session.c
@@ -39,89 +39,229 @@
 #include <glib.h>
 #include "libpolkit-session.h"
 
-struct PolKitSession_s
+
+/**
+ * SECTION:libpolkit-session
+ * @short_description: Sessions.
+ *
+ * This class is used to represent a session. TODO: describe session.
+ **/
+
+/**
+ * PolKitSession:
+ *
+ * Objects of this class are used to record information about a
+ * session.
+ **/
+struct PolKitSession
 {
 };
 
+/**
+ * libpolkit_session_new:
+ * 
+ * Creates a new #PolKitSession object.
+ * 
+ * Returns: the new object
+ **/
 PolKitSession *
 libpolkit_session_new (void)
 {
         return NULL;
 }
 
+/**
+ * libpolkit_session_ref:
+ * @session: The session object
+ * 
+ * Increase reference count.
+ * 
+ * Returns: the object
+ **/
 PolKitSession *
 libpolkit_session_ref (PolKitSession *session)
 {
         return NULL;
 }
 
+/**
+ * libpolkit_session_set_uid:
+ * @session: The session object
+ * @uid: UNIX user id
+ * 
+ * Set the UNIX user id of the user owning the session.
+ **/
 void 
 libpolkit_session_set_uid (PolKitSession *session, uid_t uid)
 {
 }
 
+/**
+ * libpolkit_session_set_ck_objref:
+ * @session: The session object
+ * @ck_objref: D-Bus object path
+ * 
+ * Set the D-Bus object path to the ConsoleKit session object.
+ **/
 void 
 libpolkit_session_set_ck_objref (PolKitSession *session, const char *ck_objref)
 {
 }
 
+/**
+ * libpolkit_session_set_ck_is_active:
+ * @session: The session object
+ * @is_active: whether ConsoleKit reports the session as active
+ * 
+ * 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_local:
+ * @session: The session object
+ * @is_local: whether ConsoleKit reports the session as local
+ * 
+ * Set whether ConsoleKit regard the session as local.
+ **/
 void 
 libpolkit_session_set_ck_is_local (PolKitSession *session, gboolean is_local)
 {
 }
 
+/**
+ * libpolkit_session_set_ck_remote_host:
+ * @session: The session object
+ * @remote_host: hostname of the host/display that ConsoleKit reports
+ * the session to occur at
+ * 
+ * Set the remote host/display that ConsoleKit reports the session to
+ * occur at.
+ **/
 void 
 libpolkit_session_set_ck_remote_host (PolKitSession *session, const char *remote_host)
 {
 }
 
-void 
-libpolkit_session_set_ck_seat (PolKitSession *session, PolKitSeat *seat)
+/**
+ * libpolkit_session_set_seat:
+ * @session: The session object
+ * @seat: a #PolKitSeat object
+ * 
+ * Set the seat that the session belongs to. The reference count on
+ * the given object will be increased by one. If an existing seat
+ * object was set already, the reference count on that one will be
+ * decreased by one.
+ **/
+void 
+libpolkit_session_set_seat (PolKitSession *session, PolKitSeat *seat)
 {
 }
 
+/**
+ * libpolkit_session_get_uid:
+ * @session: The session object
+ * @out_uid: UNIX user id
+ * 
+ * Get the UNIX user id of the user owning the session.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
 gboolean
 libpolkit_session_get_uid (PolKitSession *session, uid_t *out_uid)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_session_get_ck_objref:
+ * @session: The session object
+ * @out_ck_objref: D-Bus object path. Shall not be freed by the caller.
+ * 
+ * Get the D-Bus object path to the ConsoleKit session object.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
 gboolean
 libpolkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_session_get_ck_is_active:
+ * @session: The session object
+ * @out_is_active: whether ConsoleKit reports the session as active
+ * 
+ * Get whether ConsoleKit regard the session as active.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
 gboolean
 libpolkit_session_get_ck_is_active (PolKitSession *session, gboolean *out_is_active)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_session_get_ck_is_local:
+ * @session: The session object
+ * @out_is_local: whether ConsoleKit reports the session as local
+ * 
+ * Set whether ConsoleKit regard the session as local.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
 gboolean
 libpolkit_session_get_ck_is_local (PolKitSession *session, gboolean *out_is_local)
 {
         return FALSE;
 }
 
+/**
+ * libpolkit_session_get_ck_remote_host:
+ * @session: The session object
+ * @out_remote_host: hostname of the host/display that ConsoleKit
+ * reports the session to occur at. Shall not be freed by the caller.
+ * 
+ * Get the remote host/display that ConsoleKit reports the session to
+ * occur at.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
 gboolean
 libpolkit_session_get_ck_remote_host (PolKitSession *session, char *out_remote_host)
 {
         return FALSE;
 }
 
-gboolean
-libpolkit_session_get_ck_seat (PolKitSession *session, PolKitSeat **out_seat)
+/**
+ * libpolkit_session_get_seat:
+ * @session: The session object
+ * @out_seat: Returns the seat the session belongs to. Shall not
+ * be unreffed by the caller.
+ * 
+ * Get the seat that the session belongs to.
+ * 
+ * Returns: TRUE iff the value is returned
+ **/
+gboolean
+libpolkit_session_get_seat (PolKitSession *session, PolKitSeat **out_seat)
 {
         return FALSE;
 }
 
-
+/**
+ * libpolkit_session_unref:
+ * @session: The session object
+ * 
+ * Decreases the reference count of the object. If it becomes zero,
+ * the object is freed. Before freeing, reference counts on embedded
+ * objects are decresed by one.
+ **/
 void 
 libpolkit_session_unref (PolKitSession *session)
 {
diff --git a/libpolkit/libpolkit-session.h b/libpolkit/libpolkit-session.h
index 2356e2d..46fcc97 100644
--- a/libpolkit/libpolkit-session.h
+++ b/libpolkit/libpolkit-session.h
@@ -33,24 +33,24 @@
 
 #include <libpolkit/libpolkit-seat.h>
 
-struct PolKitSession_s;
-typedef struct PolKitSession_s PolKitSession;
+struct PolKitSession;
+typedef struct PolKitSession PolKitSession;
 
-PolKitSession     *libpolkit_session_new                (void);
-PolKitSession     *libpolkit_session_ref                (PolKitSession *session);
-void               libpolkit_session_set_uid            (PolKitSession *session, uid_t       uid);
-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_remote_host (PolKitSession *session, const char *remote_host);
-void               libpolkit_session_set_ck_seat        (PolKitSession *session, PolKitSeat     *seat);
-gboolean           libpolkit_session_get_uid            (PolKitSession *session, uid_t      *out_uid);
-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);
-gboolean           libpolkit_session_get_ck_seat        (PolKitSession *session, PolKitSeat    **out_seat);
-void               libpolkit_session_unref              (PolKitSession *session);
+PolKitSession *libpolkit_session_new                (void);
+PolKitSession *libpolkit_session_ref                (PolKitSession *session);
+void           libpolkit_session_unref              (PolKitSession *session);
+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_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);
 
 #endif /* LIBPOLKIT_SESSION_H */
 
diff-tree 96e73f52582e3517d0925fa402bb4bb349123b10 (from 9a0ad18906cddce8e6a0d0d784bad3493dbfac71)
Author: David Zeuthen <davidz at redhat.com>
Date:   Wed Mar 28 14:50:02 2007 -0400

    split libpolkit into more source/header files

diff --git a/libpolkit.pc.in b/libpolkit.pc.in
index 1d8d60a..3f36d2d 100644
--- a/libpolkit.pc.in
+++ b/libpolkit.pc.in
@@ -8,4 +8,4 @@ Description: library for querying system
 Version: @VERSION@
 Requires: glib-2.0
 Libs: -L${libdir} -lpolkit
-Cflags: -I${includedir}/libpolkit
+Cflags: -I${includedir}/PolicyKit
diff --git a/libpolkit/Makefile.am b/libpolkit/Makefile.am
index 68338b8..55408c1 100644
--- a/libpolkit/Makefile.am
+++ b/libpolkit/Makefile.am
@@ -12,13 +12,25 @@ INCLUDES = \
 
 lib_LTLIBRARIES=libpolkit.la
 
-libpolkitincludedir=$(includedir)/libpolkit
+libpolkitincludedir=$(includedir)/PolicyKit/libpolkit
 
-libpolkitinclude_HEADERS =                            \
-	libpolkit.h
-
-libpolkit_la_SOURCES =                                \
-	libpolkit.c           libpolkit.h
+libpolkitinclude_HEADERS =              		\
+	libpolkit.h					\
+	libpolkit-context.h				\
+	libpolkit-privilege.h				\
+	libpolkit-resource.h				\
+	libpolkit-seat.h				\
+	libpolkit-session.h				\
+	libpolkit-caller.h
+
+libpolkit_la_SOURCES =                                	\
+	libpolkit.h		libpolkit.c		\
+	libpolkit-context.h	libpolkit-context.c	\
+	libpolkit-privilege.h	libpolkit-privilege.c	\
+	libpolkit-resource.h	libpolkit-resource.c	\
+	libpolkit-seat.h	libpolkit-seat.c	\
+	libpolkit-session.h	libpolkit-session.c	\
+	libpolkit-caller.h	libpolkit-caller.c
 
 libpolkit_la_LIBADD = @GLIB_LIBS@
 
diff --git a/libpolkit/libpolkit-caller.c b/libpolkit/libpolkit-caller.c
new file mode 100644
index 0000000..0801378
--- /dev/null
+++ b/libpolkit/libpolkit-caller.c
@@ -0,0 +1,116 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-caller.c : callers
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <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 <glib.h>
+#include "libpolkit-caller.h"
+
+struct PolKitCaller_s
+{
+};
+
+PolKitCaller *
+libpolkit_caller_new (void)
+{
+        return NULL;
+}
+
+PolKitCaller *
+libpolkit_caller_ref (PolKitCaller *caller)
+{
+        return caller;
+}
+
+void
+libpolkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name)
+{
+}
+
+void
+libpolkit_caller_set_uid (PolKitCaller *caller, uid_t uid)
+{
+}
+
+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)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_caller_get_pid (PolKitCaller *caller, uid_t *out_pid)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_caller_get_selinux_context (PolKitCaller *caller, char *out_selinux_context)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_caller_get_ck_session (PolKitCaller *caller, PolKitSession **out_session)
+{
+        return FALSE;
+}
+
+void
+libpolkit_caller_unref (PolKitCaller *caller)
+{
+}
diff --git a/libpolkit/libpolkit-caller.h b/libpolkit/libpolkit-caller.h
new file mode 100644
index 0000000..d8928eb
--- /dev/null
+++ b/libpolkit/libpolkit-caller.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-caller.h : callers
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#ifndef LIBPOLKIT_CALLER_H
+#define LIBPOLKIT_CALLER_H
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <glib.h>
+
+#include <libpolkit/libpolkit-session.h>
+
+struct PolKitCaller_s;
+typedef struct PolKitCaller_s PolKitCaller;
+
+PolKitCaller     *libpolkit_caller_new                 (void);
+PolKitCaller     *libpolkit_caller_ref                 (PolKitCaller *caller);
+void              libpolkit_caller_set_dbus_name       (PolKitCaller *caller, const char *dbus_name);
+void              libpolkit_caller_set_uid             (PolKitCaller *caller, uid_t       uid);
+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, uid_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);
+void              libpolkit_caller_unref               (PolKitCaller *caller);
+
+#endif /* LIBPOLKIT_H */
+
+
diff --git a/libpolkit/libpolkit-context.c b/libpolkit/libpolkit-context.c
new file mode 100644
index 0000000..4f42b79
--- /dev/null
+++ b/libpolkit/libpolkit-context.c
@@ -0,0 +1,69 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-context.c : context for PolicyKit
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <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 <glib.h>
+#include "libpolkit-context.h"
+
+struct PolKitContext_s
+{
+};
+
+PolKitContext *
+libpolkit_context_new (void)
+{
+        return FALSE;
+}
+
+PolKitContext *
+libpolkit_context_ref (PolKitContext *pk_context)
+{
+        return pk_context;
+}
+
+void
+libpolkit_context_set_config_changed (PolKitContext                *pk_context, 
+                                      PolKitContextConfigChangedCB cb, 
+                                      gpointer                     user_data)
+{
+}
+
+void
+libpolkit_context_unref (PolKitContext *pk_context)
+{
+}
+
diff --git a/libpolkit/libpolkit-context.h b/libpolkit/libpolkit-context.h
new file mode 100644
index 0000000..2a228e1
--- /dev/null
+++ b/libpolkit/libpolkit-context.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-context.h : PolicyKit context
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#ifndef LIBPOLKIT_CONTEXT_H
+#define LIBPOLKIT_CONTEXT_H
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <glib.h>
+
+struct PolKitContext_s;
+
+typedef struct PolKitContext_s PolKitContext;
+
+/**
+ * PolKitContextConfigChangedCB:
+ * @pk_context: PolicyKit context
+ * @user_data: user data
+ *
+ * Called when configuration changes. Mechanisms should listen on this
+ * signal and e.g. reconfigure all permissions / acl's they have set
+ * in response to policy decisions made from information provided by
+ * PolicyKit.
+ */
+typedef void (*PolKitContextConfigChangedCB) (PolKitContext  *pk_context,
+                                              gpointer        user_data);
+
+PolKitContext *libpolkit_context_new                (void);
+PolKitContext *libpolkit_context_ref                (PolKitContext                *pk_context);
+void           libpolkit_context_set_config_changed (PolKitContext                *pk_context, 
+                                                     PolKitContextConfigChangedCB  cb, 
+                                                     gpointer                      user_data);
+void           libpolkit_context_unref              (PolKitContext                *pk_context);
+
+
+#endif /* LIBPOLKIT_CONTEXT_H */
+
+
diff --git a/libpolkit/libpolkit-privilege.c b/libpolkit/libpolkit-privilege.c
new file mode 100644
index 0000000..80d9b67
--- /dev/null
+++ b/libpolkit/libpolkit-privilege.c
@@ -0,0 +1,72 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-privilege.c : privilege
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <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 <glib.h>
+#include "libpolkit-privilege.h"
+
+struct PolKitPrivilege_s
+{
+};
+
+PolKitPrivilege *
+libpolkit_privilege_new (void)
+{
+        return NULL;
+}
+
+PolKitPrivilege *
+libpolkit_privilege_ref (PolKitPrivilege *privilege)
+{
+        return privilege;
+}
+
+void
+libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char  *privilege_id)
+{
+}
+
+gboolean
+libpolkit_privilege_get_privilege_id (PolKitPrivilege *privilege, char **out_privilege_id)
+{
+        return FALSE;
+}
+
+void
+libpolkit_privilege_unref (PolKitPrivilege *privilege)
+{
+}
diff --git a/libpolkit/libpolkit-privilege.h b/libpolkit/libpolkit-privilege.h
new file mode 100644
index 0000000..549a846
--- /dev/null
+++ b/libpolkit/libpolkit-privilege.h
@@ -0,0 +1,45 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-privilege.h : privileges
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#ifndef LIBPOLKIT_PRIVILEGE_H
+#define LIBPOLKIT_PRIVILEGE_H
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <glib.h>
+
+struct PolKitPrivilege_s;
+typedef struct PolKitPrivilege_s PolKitPrivilege;
+
+PolKitPrivilege *libpolkit_privilege_new              (void);
+PolKitPrivilege *libpolkit_privilege_ref              (PolKitPrivilege *privilege);
+void             libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char  *privilege_id);
+gboolean         libpolkit_privilege_get_privilege_id (PolKitPrivilege *privilege, char       **out_privilege_id);
+void             libpolkit_privilege_unref            (PolKitPrivilege *privilege);
+
+#endif /* LIBPOLKIT_PRIVILEGE_H */
+
+
diff --git a/libpolkit/libpolkit-resource.c b/libpolkit/libpolkit-resource.c
new file mode 100644
index 0000000..15b62c6
--- /dev/null
+++ b/libpolkit/libpolkit-resource.c
@@ -0,0 +1,83 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-resource.c : resources
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <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 <glib.h>
+#include "libpolkit-resource.h"
+
+struct PolKitResource_s
+{
+};
+
+PolKitResource *
+libpolkit_resource_new (void)
+{
+        return NULL;
+}
+
+PolKitResource *
+libpolkit_resource_ref (PolKitResource *resource)
+{
+        return 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)
+{
+        return FALSE;
+}
+
+gboolean 
+libpolkit_resource_get_resource_id (PolKitResource *resource, char **out_resource_id)
+{
+        return FALSE;
+}
+
+void 
+libpolkit_resource_unref (PolKitResource *resource)
+{
+}
diff --git a/libpolkit/libpolkit-resource.h b/libpolkit/libpolkit-resource.h
new file mode 100644
index 0000000..4751f59
--- /dev/null
+++ b/libpolkit/libpolkit-resource.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-resource.h : resources
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#ifndef LIBPOLKIT_RESOURCE_H
+#define LIBPOLKIT_RESOURCE_H
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <glib.h>
+
+struct PolKitResource_s;
+typedef struct PolKitResource_s PolKitResource;
+
+PolKitResource *libpolkit_resource_new               (void);
+PolKitResource *libpolkit_resource_ref               (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);
+void            libpolkit_resource_unref             (PolKitResource *resource);
+
+#endif /* LIBPOLKIT_RESOURCE_H */
+
+
diff --git a/libpolkit/libpolkit-seat.c b/libpolkit/libpolkit-seat.c
new file mode 100644
index 0000000..adaa45f
--- /dev/null
+++ b/libpolkit/libpolkit-seat.c
@@ -0,0 +1,72 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-seat.c : seat
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <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 <glib.h>
+#include "libpolkit-seat.h"
+
+struct PolKitSeat_s
+{
+};
+
+PolKitSeat *
+libpolkit_seat_new (void)
+{
+        return NULL;
+}
+
+PolKitSeat *
+libpolkit_seat_ref (PolKitSeat *seat)
+{
+        return 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)
+{
+        return FALSE;
+}
+
+void
+libpolkit_seat_unref (PolKitSeat *seat)
+{
+}
diff --git a/libpolkit/libpolkit-seat.h b/libpolkit/libpolkit-seat.h
new file mode 100644
index 0000000..aeeaebc
--- /dev/null
+++ b/libpolkit/libpolkit-seat.h
@@ -0,0 +1,45 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-seat.h : seats
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#ifndef LIBPOLKIT_SEAT_H
+#define LIBPOLKIT_SEAT_H
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <glib.h>
+
+struct PolKitSeat_s;
+typedef struct PolKitSeat_s PolKitSeat;
+
+PolKitSeat     *libpolkit_seat_new             (void);
+PolKitSeat     *libpolkit_seat_ref             (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);
+void            libpolkit_seat_unref           (PolKitSeat *seat);
+
+#endif /* LIBPOLKIT_SEAT_H */
+
+
diff --git a/libpolkit/libpolkit-session.c b/libpolkit/libpolkit-session.c
new file mode 100644
index 0000000..13971ea
--- /dev/null
+++ b/libpolkit/libpolkit-session.c
@@ -0,0 +1,128 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-session.c : sessions
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <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 <glib.h>
+#include "libpolkit-session.h"
+
+struct PolKitSession_s
+{
+};
+
+PolKitSession *
+libpolkit_session_new (void)
+{
+        return NULL;
+}
+
+PolKitSession *
+libpolkit_session_ref (PolKitSession *session)
+{
+        return NULL;
+}
+
+void 
+libpolkit_session_set_uid (PolKitSession *session, uid_t uid)
+{
+}
+
+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_remote_host (PolKitSession *session, const char *remote_host)
+{
+}
+
+void 
+libpolkit_session_set_ck_seat (PolKitSession *session, PolKitSeat *seat)
+{
+}
+
+gboolean
+libpolkit_session_get_uid (PolKitSession *session, uid_t *out_uid)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_session_get_ck_is_active (PolKitSession *session, gboolean *out_is_active)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_session_get_ck_is_local (PolKitSession *session, gboolean *out_is_local)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_session_get_ck_remote_host (PolKitSession *session, char *out_remote_host)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_session_get_ck_seat (PolKitSession *session, PolKitSeat **out_seat)
+{
+        return FALSE;
+}
+
+
+void 
+libpolkit_session_unref (PolKitSession *session)
+{
+}
diff --git a/libpolkit/libpolkit-session.h b/libpolkit/libpolkit-session.h
new file mode 100644
index 0000000..2356e2d
--- /dev/null
+++ b/libpolkit/libpolkit-session.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/***************************************************************************
+ *
+ * libpolkit-session.h : sessions
+ *
+ * Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#ifndef LIBPOLKIT_SESSION_H
+#define LIBPOLKIT_SESSION_H
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <glib.h>
+
+#include <libpolkit/libpolkit-seat.h>
+
+struct PolKitSession_s;
+typedef struct PolKitSession_s PolKitSession;
+
+PolKitSession     *libpolkit_session_new                (void);
+PolKitSession     *libpolkit_session_ref                (PolKitSession *session);
+void               libpolkit_session_set_uid            (PolKitSession *session, uid_t       uid);
+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_remote_host (PolKitSession *session, const char *remote_host);
+void               libpolkit_session_set_ck_seat        (PolKitSession *session, PolKitSeat     *seat);
+gboolean           libpolkit_session_get_uid            (PolKitSession *session, uid_t      *out_uid);
+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);
+gboolean           libpolkit_session_get_ck_seat        (PolKitSession *session, PolKitSeat    **out_seat);
+void               libpolkit_session_unref              (PolKitSession *session);
+
+#endif /* LIBPOLKIT_SESSION_H */
+
+
diff --git a/libpolkit/libpolkit.c b/libpolkit/libpolkit.c
index df53d7c..ae4e017 100644
--- a/libpolkit/libpolkit.c
+++ b/libpolkit/libpolkit.c
@@ -39,318 +39,6 @@
 #include <glib.h>
 #include "libpolkit.h"
 
-struct PolKitContext_s
-{
-};
-
-PolKitContext *
-libpolkit_context_new (void)
-{
-        return FALSE;
-}
-
-PolKitContext *
-libpolkit_context_ref (PolKitContext *pk_context)
-{
-        return pk_context;
-}
-
-void
-libpolkit_context_set_config_changed (PolKitContext                *pk_context, 
-                                      PolKitContextConfigChangedCB cb, 
-                                      gpointer                     user_data)
-{
-}
-
-void
-libpolkit_context_unref (PolKitContext *pk_context)
-{
-}
-
-/******************************************************************************************************/
-
-struct PolKitPrivilege_s
-{
-};
-
-PolKitPrivilege *
-libpolkit_privilege_new (void)
-{
-        return NULL;
-}
-
-PolKitPrivilege *
-libpolkit_privilege_ref (PolKitPrivilege *privilege)
-{
-        return privilege;
-}
-
-void
-libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char  *privilege_id)
-{
-}
-
-gboolean
-libpolkit_privilege_get_privilege_id (PolKitPrivilege *privilege, char **out_privilege_id)
-{
-        return FALSE;
-}
-
-void
-libpolkit_privilege_unref (PolKitPrivilege *privilege)
-{
-}
-
-/******************************************************************************************************/
-
-struct PolKitResource_s
-{
-};
-
-PolKitResource *
-libpolkit_resource_new (void)
-{
-        return NULL;
-}
-
-PolKitResource *
-libpolkit_resource_ref (PolKitResource *resource)
-{
-        return 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)
-{
-        return FALSE;
-}
-
-gboolean 
-libpolkit_resource_get_resource_id (PolKitResource *resource, char **out_resource_id)
-{
-        return FALSE;
-}
-
-void 
-libpolkit_resource_unref (PolKitResource *resource)
-{
-}
-
-/******************************************************************************************************/
-
-struct PolKitSeat_s
-{
-};
-
-PolKitSeat *
-libpolkit_seat_new (void)
-{
-        return NULL;
-}
-
-PolKitSeat *
-libpolkit_seat_ref (PolKitSeat *seat)
-{
-        return 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)
-{
-        return FALSE;
-}
-
-void
-libpolkit_seat_unref (PolKitSeat *seat)
-{
-}
-
-/******************************************************************************************************/
-
-struct PolKitSession_s
-{
-};
-
-PolKitSession *
-libpolkit_session_new (void)
-{
-        return NULL;
-}
-
-PolKitSession *
-libpolkit_session_ref (PolKitSession *session)
-{
-        return NULL;
-}
-
-void 
-libpolkit_session_set_uid (PolKitSession *session, uid_t uid)
-{
-}
-
-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_remote_host (PolKitSession *session, const char *remote_host)
-{
-}
-
-void 
-libpolkit_session_set_ck_seat (PolKitSession *session, PolKitSeat *seat)
-{
-}
-
-gboolean
-libpolkit_session_get_uid (PolKitSession *session, uid_t *out_uid)
-{
-        return FALSE;
-}
-
-gboolean
-libpolkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref)
-{
-        return FALSE;
-}
-
-gboolean
-libpolkit_session_get_ck_is_active (PolKitSession *session, gboolean *out_is_active)
-{
-        return FALSE;
-}
-
-gboolean
-libpolkit_session_get_ck_is_local (PolKitSession *session, gboolean *out_is_local)
-{
-        return FALSE;
-}
-
-gboolean
-libpolkit_session_get_ck_remote_host (PolKitSession *session, char *out_remote_host)
-{
-        return FALSE;
-}
-
-gboolean
-libpolkit_session_get_ck_seat (PolKitSession *session, PolKitSeat **out_seat)
-{
-        return FALSE;
-}
-
-
-void 
-libpolkit_session_unref (PolKitSession *session)
-{
-}
-
-/******************************************************************************************************/
-
-struct PolKitCaller_s
-{
-};
-
-PolKitCaller *
-libpolkit_caller_new (void)
-{
-        return NULL;
-}
-
-PolKitCaller *
-libpolkit_caller_ref (PolKitCaller *caller)
-{
-        return caller;
-}
-
-void
-libpolkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name)
-{
-}
-
-void
-libpolkit_caller_set_uid (PolKitCaller *caller, uid_t uid)
-{
-}
-
-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)
-{
-        return FALSE;
-}
-
-gboolean
-libpolkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid)
-{
-        return FALSE;
-}
-
-gboolean
-libpolkit_caller_get_pid (PolKitCaller *caller, uid_t *out_pid)
-{
-        return FALSE;
-}
-
-gboolean
-libpolkit_caller_get_selinux_context (PolKitCaller *caller, char *out_selinux_context)
-{
-        return FALSE;
-}
-
-gboolean
-libpolkit_caller_get_ck_session (PolKitCaller *caller, PolKitSession **out_session)
-{
-        return FALSE;
-}
-
-void
-libpolkit_caller_unref (PolKitCaller *caller)
-{
-}
-
-/******************************************************************************************************/
-
-
 /**
  * libpolkit_get_seat_resource_association:
  * @pk_context: the PolicyKit context
diff --git a/libpolkit/libpolkit.h b/libpolkit/libpolkit.h
index ff96fc0..a5aedab 100644
--- a/libpolkit/libpolkit.h
+++ b/libpolkit/libpolkit.h
@@ -31,98 +31,12 @@
 #include <sys/types.h>
 #include <glib.h>
 
-struct PolKitContext_s;
-typedef struct PolKitContext_s PolKitContext;
-
-/**
- * PolKitContextConfigChangedCB:
- * @pk_context: PolicyKit context
- * @resources_associated_with_seat: A NULL terminated array of resources associated with the seat
- * @user_data: user data
- *
- * Called when configuration changes. Mechanisms should listen on this
- * signal and e.g. reconfigure all permissions / acl's they have set
- * in response to policy decisions made from information provided by
- * PolicyKit.
- */
-typedef void (*PolKitContextConfigChangedCB) (PolKitContext  *pk_context,
-                                              gpointer        user_data);
-
-PolKitContext *libpolkit_context_new                (void);
-PolKitContext *libpolkit_context_ref                (PolKitContext                *pk_context);
-void           libpolkit_context_set_config_changed (PolKitContext                *pk_context, 
-                                                     PolKitContextConfigChangedCB  cb, 
-                                                     gpointer                      user_data);
-void           libpolkit_context_unref              (PolKitContext                *pk_context);
-
-
-struct PolKitPrivilege_s;
-typedef struct PolKitPrivilege_s PolKitPrivilege;
-
-PolKitPrivilege *libpolkit_privilege_new              (void);
-PolKitPrivilege *libpolkit_privilege_ref              (PolKitPrivilege *privilege);
-void             libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char  *privilege_id);
-gboolean         libpolkit_privilege_get_privilege_id (PolKitPrivilege *privilege, char       **out_privilege_id);
-void             libpolkit_privilege_unref            (PolKitPrivilege *privilege);
-
-struct PolKitResource_s;
-typedef struct PolKitResource_s PolKitResource;
-
-PolKitResource *libpolkit_resource_new               (void);
-PolKitResource *libpolkit_resource_ref               (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);
-void            libpolkit_resource_unref             (PolKitResource *resource);
-
-
-struct PolKitSeat_s;
-typedef struct PolKitSeat_s PolKitSeat;
-
-PolKitSeat     *libpolkit_seat_new             (void);
-PolKitSeat     *libpolkit_seat_ref             (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);
-void            libpolkit_seat_unref           (PolKitSeat *seat);
-
-
-struct PolKitSession_s;
-typedef struct PolKitSession_s PolKitSession;
-
-PolKitSession     *libpolkit_session_new                (void);
-PolKitSession     *libpolkit_session_ref                (PolKitSession *session);
-void               libpolkit_session_set_uid            (PolKitSession *session, uid_t       uid);
-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_remote_host (PolKitSession *session, const char *remote_host);
-void               libpolkit_session_set_ck_seat        (PolKitSession *session, PolKitSeat     *seat);
-gboolean           libpolkit_session_get_uid            (PolKitSession *session, uid_t      *out_uid);
-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);
-gboolean           libpolkit_session_get_ck_seat        (PolKitSession *session, PolKitSeat    **out_seat);
-void               libpolkit_session_unref              (PolKitSession *session);
-
-
-struct PolKitCaller_s;
-typedef struct PolKitCaller_s PolKitCaller;
-
-PolKitCaller     *libpolkit_caller_new                 (void);
-PolKitCaller     *libpolkit_caller_ref                 (PolKitCaller *caller);
-void              libpolkit_caller_set_dbus_name       (PolKitCaller *caller, const char *dbus_name);
-void              libpolkit_caller_set_uid             (PolKitCaller *caller, uid_t       uid);
-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, uid_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);
-void              libpolkit_caller_unref               (PolKitCaller *caller);
+#include <libpolkit/libpolkit-context.h>
+#include <libpolkit/libpolkit-privilege.h>
+#include <libpolkit/libpolkit-resource.h>
+#include <libpolkit/libpolkit-seat.h>
+#include <libpolkit/libpolkit-session.h>
+#include <libpolkit/libpolkit-caller.h>
 
 /**
  * PolKitSeatVisitorCB:
diff-tree 9a0ad18906cddce8e6a0d0d784bad3493dbfac71 (from e90a077762f58b825008864f1facb8462269b7b2)
Author: David Zeuthen <davidz at redhat.com>
Date:   Wed Mar 28 14:11:56 2007 -0400

    proposed API

diff --git a/libpolkit/libpolkit.c b/libpolkit/libpolkit.c
index a2bb93f..df53d7c 100644
--- a/libpolkit/libpolkit.c
+++ b/libpolkit/libpolkit.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
 /***************************************************************************
  *
  * libpolkit.c : library for querying system-wide policy
@@ -38,3 +39,402 @@
 #include <glib.h>
 #include "libpolkit.h"
 
+struct PolKitContext_s
+{
+};
+
+PolKitContext *
+libpolkit_context_new (void)
+{
+        return FALSE;
+}
+
+PolKitContext *
+libpolkit_context_ref (PolKitContext *pk_context)
+{
+        return pk_context;
+}
+
+void
+libpolkit_context_set_config_changed (PolKitContext                *pk_context, 
+                                      PolKitContextConfigChangedCB cb, 
+                                      gpointer                     user_data)
+{
+}
+
+void
+libpolkit_context_unref (PolKitContext *pk_context)
+{
+}
+
+/******************************************************************************************************/
+
+struct PolKitPrivilege_s
+{
+};
+
+PolKitPrivilege *
+libpolkit_privilege_new (void)
+{
+        return NULL;
+}
+
+PolKitPrivilege *
+libpolkit_privilege_ref (PolKitPrivilege *privilege)
+{
+        return privilege;
+}
+
+void
+libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char  *privilege_id)
+{
+}
+
+gboolean
+libpolkit_privilege_get_privilege_id (PolKitPrivilege *privilege, char **out_privilege_id)
+{
+        return FALSE;
+}
+
+void
+libpolkit_privilege_unref (PolKitPrivilege *privilege)
+{
+}
+
+/******************************************************************************************************/
+
+struct PolKitResource_s
+{
+};
+
+PolKitResource *
+libpolkit_resource_new (void)
+{
+        return NULL;
+}
+
+PolKitResource *
+libpolkit_resource_ref (PolKitResource *resource)
+{
+        return 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)
+{
+        return FALSE;
+}
+
+gboolean 
+libpolkit_resource_get_resource_id (PolKitResource *resource, char **out_resource_id)
+{
+        return FALSE;
+}
+
+void 
+libpolkit_resource_unref (PolKitResource *resource)
+{
+}
+
+/******************************************************************************************************/
+
+struct PolKitSeat_s
+{
+};
+
+PolKitSeat *
+libpolkit_seat_new (void)
+{
+        return NULL;
+}
+
+PolKitSeat *
+libpolkit_seat_ref (PolKitSeat *seat)
+{
+        return 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)
+{
+        return FALSE;
+}
+
+void
+libpolkit_seat_unref (PolKitSeat *seat)
+{
+}
+
+/******************************************************************************************************/
+
+struct PolKitSession_s
+{
+};
+
+PolKitSession *
+libpolkit_session_new (void)
+{
+        return NULL;
+}
+
+PolKitSession *
+libpolkit_session_ref (PolKitSession *session)
+{
+        return NULL;
+}
+
+void 
+libpolkit_session_set_uid (PolKitSession *session, uid_t uid)
+{
+}
+
+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_remote_host (PolKitSession *session, const char *remote_host)
+{
+}
+
+void 
+libpolkit_session_set_ck_seat (PolKitSession *session, PolKitSeat *seat)
+{
+}
+
+gboolean
+libpolkit_session_get_uid (PolKitSession *session, uid_t *out_uid)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_session_get_ck_objref (PolKitSession *session, char **out_ck_objref)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_session_get_ck_is_active (PolKitSession *session, gboolean *out_is_active)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_session_get_ck_is_local (PolKitSession *session, gboolean *out_is_local)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_session_get_ck_remote_host (PolKitSession *session, char *out_remote_host)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_session_get_ck_seat (PolKitSession *session, PolKitSeat **out_seat)
+{
+        return FALSE;
+}
+
+
+void 
+libpolkit_session_unref (PolKitSession *session)
+{
+}
+
+/******************************************************************************************************/
+
+struct PolKitCaller_s
+{
+};
+
+PolKitCaller *
+libpolkit_caller_new (void)
+{
+        return NULL;
+}
+
+PolKitCaller *
+libpolkit_caller_ref (PolKitCaller *caller)
+{
+        return caller;
+}
+
+void
+libpolkit_caller_set_dbus_name (PolKitCaller *caller, const char *dbus_name)
+{
+}
+
+void
+libpolkit_caller_set_uid (PolKitCaller *caller, uid_t uid)
+{
+}
+
+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)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_caller_get_uid (PolKitCaller *caller, uid_t *out_uid)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_caller_get_pid (PolKitCaller *caller, uid_t *out_pid)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_caller_get_selinux_context (PolKitCaller *caller, char *out_selinux_context)
+{
+        return FALSE;
+}
+
+gboolean
+libpolkit_caller_get_ck_session (PolKitCaller *caller, PolKitSession **out_session)
+{
+        return FALSE;
+}
+
+void
+libpolkit_caller_unref (PolKitCaller *caller)
+{
+}
+
+/******************************************************************************************************/
+
+
+/**
+ * libpolkit_get_seat_resource_association:
+ * @pk_context: the PolicyKit context
+ * @visitor: visitor function
+ * @user_data: user data
+ *
+ * Retrieve information about what resources are associated to what
+ * seats. Note that a resource may be associated to more than one
+ * seat. This information stems from user configuration and consumers
+ * of this information that know better (e.g. HAL) may choose to
+ * override it. 
+ *
+ * Typically, this information is used to e.g. bootstrap the system
+ * insofar that it can be used to start login greeters on the given
+ * video hardware (e.g. resources) on the given user-configured seats.
+ */
+void
+libpolkit_get_seat_resource_association (PolKitContext       *pk_context,
+                                         PolKitSeatVisitorCB  visitor,
+                                         gpointer            *user_data)
+{
+}
+
+/**
+ * libpolkit_is_resource_associated_with_seat:
+ * @pk_context: the PolicyKit context
+ * @resource: the resource in question
+ * @seat: the seat
+ *
+ * Determine if a given resource is associated with a given seat. The
+ * same comments noted in libpolkit_get_seat_resource_association() about the
+ * source purely being user configuration applies here as well.
+ *
+ * Returns: TRUE if, and only if, the given resource is
+ * associated with the given seat.
+ */
+gboolean
+libpolkit_is_resource_associated_with_seat (PolKitContext   *pk_context,
+                                            PolKitResource  *resource,
+                                            PolKitSeat      *seat)
+{
+        return FALSE;
+}
+
+/**
+ * libpolkit_can_session_access_resource:
+ * @pk_context: the PolicyKit context
+ * @privilege: the type of access to check for
+ * @resource: the resource in question
+ * @session: the session in question
+ *
+ * Determine if a given session can access a given resource in a given way.
+ *
+ * Returns: TRUE if, and only if, the given session can access the
+ * given resource in the given way.
+ */
+gboolean
+libpolkit_can_session_access_resource (PolKitContext   *pk_context,
+                                       PolKitPrivilege *privilege,
+                                       PolKitResource  *resource,
+                                       PolKitSession   *session)
+{
+        return FALSE;
+}
+
+/**
+ * libpolkit_can_caller_access_resource:
+ * @pk_context: the PolicyKit context
+ * @privilege: the type of access to check for
+ * @resource: the resource in question
+ * @caller: the resource in question
+ *
+ * Determine if a given caller can access a given resource in a given way.
+ *
+ * Returns: TRUE if, and only if, the given caller can access the given interface
+ * of the given resource in the given way.
+ */
+
+gboolean
+libpolkit_can_caller_access_resource (PolKitContext   *pk_context,
+                                      PolKitPrivilege *privilege,
+                                      PolKitResource  *resource,
+                                      PolKitCaller    *caller)
+{
+        return FALSE;
+}
+
diff --git a/libpolkit/libpolkit.h b/libpolkit/libpolkit.h
index c322489..ff96fc0 100644
--- a/libpolkit/libpolkit.h
+++ b/libpolkit/libpolkit.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
 /***************************************************************************
  *
  * libpolkit.h : library for querying system-wide policy
@@ -30,6 +31,134 @@
 #include <sys/types.h>
 #include <glib.h>
 
+struct PolKitContext_s;
+typedef struct PolKitContext_s PolKitContext;
+
+/**
+ * PolKitContextConfigChangedCB:
+ * @pk_context: PolicyKit context
+ * @resources_associated_with_seat: A NULL terminated array of resources associated with the seat
+ * @user_data: user data
+ *
+ * Called when configuration changes. Mechanisms should listen on this
+ * signal and e.g. reconfigure all permissions / acl's they have set
+ * in response to policy decisions made from information provided by
+ * PolicyKit.
+ */
+typedef void (*PolKitContextConfigChangedCB) (PolKitContext  *pk_context,
+                                              gpointer        user_data);
+
+PolKitContext *libpolkit_context_new                (void);
+PolKitContext *libpolkit_context_ref                (PolKitContext                *pk_context);
+void           libpolkit_context_set_config_changed (PolKitContext                *pk_context, 
+                                                     PolKitContextConfigChangedCB  cb, 
+                                                     gpointer                      user_data);
+void           libpolkit_context_unref              (PolKitContext                *pk_context);
+
+
+struct PolKitPrivilege_s;
+typedef struct PolKitPrivilege_s PolKitPrivilege;
+
+PolKitPrivilege *libpolkit_privilege_new              (void);
+PolKitPrivilege *libpolkit_privilege_ref              (PolKitPrivilege *privilege);
+void             libpolkit_privilege_set_privilege_id (PolKitPrivilege *privilege, const char  *privilege_id);
+gboolean         libpolkit_privilege_get_privilege_id (PolKitPrivilege *privilege, char       **out_privilege_id);
+void             libpolkit_privilege_unref            (PolKitPrivilege *privilege);
+
+struct PolKitResource_s;
+typedef struct PolKitResource_s PolKitResource;
+
+PolKitResource *libpolkit_resource_new               (void);
+PolKitResource *libpolkit_resource_ref               (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);
+void            libpolkit_resource_unref             (PolKitResource *resource);
+
+
+struct PolKitSeat_s;
+typedef struct PolKitSeat_s PolKitSeat;
+
+PolKitSeat     *libpolkit_seat_new             (void);
+PolKitSeat     *libpolkit_seat_ref             (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);
+void            libpolkit_seat_unref           (PolKitSeat *seat);
+
+
+struct PolKitSession_s;
+typedef struct PolKitSession_s PolKitSession;
+
+PolKitSession     *libpolkit_session_new                (void);
+PolKitSession     *libpolkit_session_ref                (PolKitSession *session);
+void               libpolkit_session_set_uid            (PolKitSession *session, uid_t       uid);
+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_remote_host (PolKitSession *session, const char *remote_host);
+void               libpolkit_session_set_ck_seat        (PolKitSession *session, PolKitSeat     *seat);
+gboolean           libpolkit_session_get_uid            (PolKitSession *session, uid_t      *out_uid);
+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);
+gboolean           libpolkit_session_get_ck_seat        (PolKitSession *session, PolKitSeat    **out_seat);
+void               libpolkit_session_unref              (PolKitSession *session);
+
+
+struct PolKitCaller_s;
+typedef struct PolKitCaller_s PolKitCaller;
+
+PolKitCaller     *libpolkit_caller_new                 (void);
+PolKitCaller     *libpolkit_caller_ref                 (PolKitCaller *caller);
+void              libpolkit_caller_set_dbus_name       (PolKitCaller *caller, const char *dbus_name);
+void              libpolkit_caller_set_uid             (PolKitCaller *caller, uid_t       uid);
+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, uid_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);
+void              libpolkit_caller_unref               (PolKitCaller *caller);
+
+/**
+ * PolKitSeatVisitorCB:
+ * @seat: the seat
+ * @resources_associated_with_seat: A NULL terminated array of resources associated with the seat
+ * @user_data: user data
+ *
+ * Visitor function for libpolkit_get_seat_resource_association(). The caller should _not_ unref the passed objects.
+ *
+ */
+typedef void (*PolKitSeatVisitorCB) (PolKitSeat      *seat,
+                                     PolKitResource **resources_associated_with_seat,
+                                     gpointer         user_data);
+
+void
+libpolkit_get_seat_resource_association (PolKitContext       *pk_context,
+                                         PolKitSeatVisitorCB  visitor,
+                                         gpointer            *user_data);
+
+gboolean
+libpolkit_is_resource_associated_with_seat (PolKitContext   *pk_context,
+                                            PolKitResource  *resource,
+                                            PolKitSeat      *seat);
+
+gboolean
+libpolkit_can_session_access_resource (PolKitContext   *pk_context,
+                                       PolKitPrivilege *privilege,
+                                       PolKitResource  *resource,
+                                       PolKitSession   *session);
+
+gboolean
+libpolkit_can_caller_access_resource (PolKitContext   *pk_context,
+                                      PolKitPrivilege *privilege,
+                                      PolKitResource  *resource,
+                                      PolKitCaller    *caller);
+
 #endif /* LIBPOLKIT_H */
 
 
diff-tree e90a077762f58b825008864f1facb8462269b7b2 (from 5e55b4a226590b18bebc65b864ba323e69769939)
Author: David Zeuthen <davidz at redhat.com>
Date:   Wed Mar 28 14:11:00 2007 -0400

    update to the gtk-doc.make from the HAL project

diff --git a/gtk-doc.make b/gtk-doc.make
index d50629a..3e5e560 100644
--- a/gtk-doc.make
+++ b/gtk-doc.make
@@ -76,7 +76,7 @@ tmpl.stamp: tmpl-build.stamp
 
 #### xml ####
 
-sgml-build.stamp: tmpl.stamp $(CFILE_GLOB) $(srcdir)/tmpl/*.sgml $(expand_content_files)
+sgml-build.stamp: tmpl.stamp $(CFILE_GLOB) $(expand_content_files)
 	@echo 'gtk-doc: Building XML'
 	@-chmod -R u+w $(srcdir)
 	cd $(srcdir) && \
@@ -107,6 +107,7 @@ endif
 clean-local:
 	rm -f *~ *.bak
 	rm -rf .libs
+	rm -rf tmpl
 
 maintainer-clean-local: clean
 	cd $(srcdir) && rm -rf xml html $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt


More information about the hal-commit mailing list