polkit-dbus

polkit-dbus — Helper library for obtaining seat, session and caller information via D-Bus and ConsoleKit.

Synopsis




PolKitSession*      polkit_session_new_from_objpath     (DBusConnection *con,
                                                         const char *objpath,
                                                         uid_t uid,
                                                         DBusError *error);
PolKitSession*      polkit_session_new_from_cookie      (DBusConnection *con,
                                                         const char *cookie,
                                                         DBusError *error);
PolKitCaller*       polkit_caller_new_from_dbus_name    (DBusConnection *con,
                                                         const char *dbus_name,
                                                         DBusError *error);
PolKitCaller*       polkit_caller_new_from_pid          (DBusConnection *con,
                                                         pid_t pid,
                                                         DBusError *error);

Description

Helper library for obtaining seat, session and caller information via D-Bus and ConsoleKit. This library is only useful when writing a mechanism. If the mechanism itself is a daemon exposing a remote services (via e.g. D-Bus) it's often a better idea, to reduce roundtrips, to track and cache caller information and construct PolKitCaller objects yourself based on this information (for an example of this, see the hald sources on how this can be done).

Details

polkit_session_new_from_objpath ()

PolKitSession*      polkit_session_new_from_objpath     (DBusConnection *con,
                                                         const char *objpath,
                                                         uid_t uid,
                                                         DBusError *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.

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

Returns :

the new object or NULL if an error occured (in which case error will be set)

polkit_session_new_from_cookie ()

PolKitSession*      polkit_session_new_from_cookie      (DBusConnection *con,
                                                         const char *cookie,
                                                         DBusError *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.

con :

D-Bus system bus connection

cookie :

a ConsoleKit XDG_SESSION_COOKIE

error :

D-Bus error

Returns :

the new object or NULL if an error occured (in which case error will be set)

polkit_caller_new_from_dbus_name ()

PolKitCaller*       polkit_caller_new_from_dbus_name    (DBusConnection *con,
                                                         const char *dbus_name,
                                                         DBusError *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.

con :

D-Bus system bus connection

dbus_name :

unique system bus connection name

error :

D-Bus error

Returns :

the new object or NULL if an error occured (in which case error will be set)

polkit_caller_new_from_pid ()

PolKitCaller*       polkit_caller_new_from_pid          (DBusConnection *con,
                                                         pid_t pid,
                                                         DBusError *error);

This function will construct a PolKitCaller object by querying both information in /proc (on Linux) and the ConsoleKit daemon for information about a given process. Note that this will do a lot of blocking IO so it is best avoided if your process already tracks/caches all the information.

con :

D-Bus system bus connection

pid :

process id

error :

D-Bus error

Returns :

the new object or NULL if an error occured (in which case error will be set)