Table of Contents
Table of Contents
Table of Contents
ConsoleKit is a framework for keeping track of the various users, sessions, and seats present on a system. It provides a mechanism for software to react to changes of any of these items or of any of the metadata associated with them.
Table of Contents
A session is a collection of all processes that share knowledge of a secret. In the typical (or ideal) case, these processes all originate from a single common ancestor.
As an implementation detail, for now, this secret should be stored in the process environment by the session leader under the name XDG_SESSION_COOKIE. When and if we are able to take advantage of a mechanism in the underlying system to store session registration information - we will. However, such a mechanism is not known at the present time.
Using an environment variable does have certain advantages. For one, it is quite easy for a process to opt-out of a Session by simply unsetting the XDG_SESSION_COOKIE variable.
Limitations of using an environment variable implementation include not being able to strictly limit visibility of the secret to a particular process ancestry. So, it is not possible to enforce session boundaries other than on a per-user basis. For example, we don't yet have a way to prevent a process from moving between sessions owned by the same user.
The session leader is the process that requests that a new session be opened. It does this by connecting to the D-Bus system bus and using either org.freedesktop.ConsoleKit.Manager.OpenSession() or org.freedesktop.ConsoleKit.Manager.OpenSessionWithParameters(). The session that it registers will remain open until the connection to the system bus is lost or it calls org.freedesktop.ConsoleKit.Manager.CloseSession().
The session leader is the only process for which CloseSession() will be allowed.
A seat is a collection of sessions and a set of hardware (usually at least a keyboard and mouse). Only one session may be active on a seat at a time.
At the present time, all Sessions that are considered "local" to a system will be added the the first Seat and every other Session will be added to its own Seat.
True, hardware, multi-seat capabilities will be added in a later release.
Table of Contents
The session leader process is responsible for asking ConsoleKit to open a new session. In this respect, it is similar to the traditional POSIX user login accounting framework. In the typical case, the session leader is either an immediate descendant of a login manager or the login manager itself. The leader makes a connection to the D-Bus system bus and asks ConsoleKit to open a session. There are two methods available for opening a session: org.freedesktop.ConsoleKit.Manager.OpenSession() and org.freedesktop.ConsoleKit.Manager.OpenSessionWithParameters().
If the operation succeeds, a secret cookie will be returned to the session leader. The session leader should store this secret in the environment as XDG_SESSION_COOKIE so that it may be shared with its child processes.
At this point the session will be registered with ConsoleKit and a particular set of information about the session will be stored along with it.
ConsoleKit will decide, based on the information associated with the session, what Seat the session will be added to.
It will also be determined, based on the same set of information, whether the Session will control the hardware associated with the Seat. In other words, whether the Session will be active for the Seat it is attached to. The exact mechanism for this determination depends on the type of Seat and the capabilities of the host system.
The Session will remain open until the Session Leader disconnects from the D-Bus system bus or calls org.freedesktop.ConsoleKit.Manager.CloseSession(). The session will be removed from its Seat, and deregistered.
Use of this service will usually follow one of the following patterns:
This pattern operates as the Session Leader for a new Session. This pattern needs:
In addition to the requirements for the Text Graphical Login Manager, this pattern is typically used to show information about currently open sessions. It needs:
This is generally a daemon process running outside of a user session as a special user. This pattern needs:
This is a special case of System Daemon that provides catalogs and control mechanisms for hardware devices. In addition to the requirements of System Daemon, this pattern needs:
This is related to the Graphical Login Manager and provides a shortcut to similar functionality. It is usually a tool available in the user session that allows one to quickly switch to another user session. This pattern needs:
This is typically a daemon running in a user session that acts on policy only when the session is active. This pattern needs:
Table of Contents
ConsoleKit provides a D-Bus API for programs to obtain information about the users, sessions, and seats that are present on a system.
Please see the other sections of this manual for an introduction to these concepts.
This API is not yet stable and is likely to change in the future.
Table of Contents
org.freedesktop.ConsoleKit.Manager — Manager interface
Restart () CanRestart (out 'b' can_restart) Stop () CanStop (out 'b' can_stop) OpenSession (out 's' cookie) OpenSessionWithParameters (in 'a(sv)' parameters, out 's' cookie) CloseSession (in 's' cookie, out 'b' result) GetSeats (out 'ao' seats) GetSessions (out 'ao' sessions) GetSessionForCookie (in 's' cookie, out 'o' ssid) GetSessionForUnixProcess (in 'u' pid, out 'o' ssid) GetCurrentSession (out 'o' ssid) GetSessionsForUnixUser (in 'u' uid, out 'ao' sessions) GetSessionsForUser (in 'u' uid, out 'ao' sessions) GetSystemIdleHint (out 'b' idle_hint) GetSystemIdleSinceHint (out 's' iso8601_datetime)
Objects implementing org.freedesktop.ConsoleKit.Manager also implements org.freedesktop.DBus.Introspectable, org.freedesktop.DBus.Properties
OpenSession (out 's' cookie)
This method requests that a new Session be created for the calling process. The properties of this new Session are set automatically from information collected about the calling process.
This new session exists until the calling process disconnects from the system bus or
calls CloseSession()
.
It is the responsibility of the calling process to set the environment variable XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only be made available to child processes of the caller so that they may be identified as members of this session.
See this simple example:
DBusError error; DBusMessage *message; DBusMessage *reply; message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", "OpenSession"); if (message == NULL) { goto out; } dbus_error_init (&error); reply = dbus_connection_send_with_reply_and_block (connector->connection, message, -1, &error); if (reply == NULL) { goto out; } dbus_error_init (&error); if (! dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &cookie, DBUS_TYPE_INVALID)) { goto out; }
cookie
:
See also:
OpenSessionWithParameters()
OpenSessionWithParameters (in 'a(sv)' parameters, out 's' cookie)
This method requests that a new Session be created for the calling process. The properties of this new Session are from the parameters provided.
This new session exists until the calling process disconnects from the system bus or
calls CloseSession()
.
It is the responsibility of the calling process to set the environment variable XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only be made available to child processes of the caller so that they may be identified as members of this session.
See the Session properties for a list of valid parameters.
parameters
:cookie
:See also: org.freedesktop.ConsoleKit.Session
CloseSession (in 's' cookie, out 'b' result)
This method is used to close the session identified by the supplied cookie.
The session can only be closed by the same process that opened the session.
cookie
:result
:GetSeats (out 'ao' seats)
This gets a list of all the Seats that are currently present on the system.
Each Seat ID is an D-Bus object path for the object that implements the Seat interface.
seats
:See also: org.freedesktop.ConsoleKit.Seat
GetSessions (out 'ao' sessions)
This gets a list of all the Sessions that are currently present on the system.
Each Session ID is an D-Bus object path for the object that implements the Session interface.
sessions
:See also: org.freedesktop.ConsoleKit.Session
GetSessionForCookie (in 's' cookie, out 'o' ssid)
Returns the session ID that is associated with the specified cookie.
cookie
:ssid
:GetSessionForUnixProcess (in 'u' pid, out 'o' ssid)
Attempts to determine the session ID for the specified POSIX process ID (pid).
pid
:ssid
:GetCurrentSession (out 'o' ssid)
Attempts to determine the session ID that the caller belongs to.
See this example of using dbus-send:
dbus-send --system --dest=org.freedesktop.ConsoleKit \ --type=method_call --print-reply --reply-timeout=2000 \ /org/freedesktop/ConsoleKit/Manager \ org.freedesktop.ConsoleKit.Manager.GetCurrentSession
ssid
:GetSessionsForUnixUser (in 'u' uid, out 'ao' sessions)
This gets a list of all the Sessions that are currently open for the specified user.
Each Session ID is an D-Bus object path for the object that implements the Session interface.
uid
:sessions
:GetSessionsForUser (in 'u' uid, out 'ao' sessions)
This gets a list of all the Sessions that are currently open for the specified user.
Each Session ID is an D-Bus object path for the object that implements the Session interface.
uid
:sessions
:GetSessionsForUser
is deprecated since version 0.1.3 and should not be used in newly-written code. Use
GetSessionsForUnixUser
instead.
GetSystemIdleHint (out 'b' idle_hint)
Returns TRUE if the idle-hint
property of every open session is TRUE or if there are no open sessions.
idle_hint
:org.freedesktop.ConsoleKit.Seat — Seat interface
GetId (out 'o' sid) GetSessions (out 'ao' sessions) GetDevices (out 'a(ss)' devices) GetActiveSession (out 'o' ssid) CanActivateSessions (out 'b' can_activate) ActivateSession (in 'o' ssid)
ActiveSessionChanged ('o' ssid) SessionAdded ('o' ssid) SessionRemoved ('o' ssid) DeviceAdded ('(ss)' device) DeviceRemoved ('(ss)' device)
Objects implementing org.freedesktop.ConsoleKit.Seat also implements org.freedesktop.DBus.Introspectable, org.freedesktop.DBus.Properties
A seat is a collection of sessions and a set of hardware (usually at least a keyboard and mouse). Only one session may be active on a seat at a time.
GetSessions (out 'ao' sessions)
This gets a list of all the Sessions that are currently attached to this seat.
Each Session ID is an D-Bus object path for the object that implements the Session interface.
sessions
:GetDevices (out 'a(ss)' devices)
This gets a list of all the devices that are currently associated with this seat.
Each device is an D-Bus structure that represents the device type and the device id.
devices
:GetActiveSession (out 'o' ssid)
Gets the Session ID that is currently active on this Seat.
Returns NULL if there is no active session.
ssid
:CanActivateSessions (out 'b' can_activate)
Used to determine whether the seat supports session activation.
can_activate
:ActivateSession (in 'o' ssid)
Attempt to activate the specified session. In most cases, if successful, this will cause the session to become visible and take control of the hardware that is associated with this seat.
ssid
:
See also:
Activate()
ActiveSessionChanged ('o' ssid)
Emitted when the active session has changed.
ssid
:SessionAdded ('o' ssid)
Emitted when a session has been added to the seat.
ssid
:SessionRemoved ('o' ssid)
Emitted when a session has been removed from the seat.
ssid
:org.freedesktop.ConsoleKit.Session — Session interface
GetId (out 'o' ssid) GetSeatId (out 'o' sid) GetSessionType (out 's' type) GetUser (out 'u' uid) GetUnixUser (out 'u' uid) GetX11Display (out 's' display) GetX11DisplayDevice (out 's' x11_display_device) GetDisplayDevice (out 's' display_device) GetRemoteHostName (out 's' remote_host_name) GetLoginSessionId (out 's' login_session_id) IsActive (out 'b' active) IsLocal (out 'b' local) GetCreationTime (out 's' iso8601_datetime) Activate () Lock () Unlock () GetIdleHint (out 'b' idle_hint) GetIdleSinceHint (out 's' iso8601_datetime) SetIdleHint (in 'b' idle_hint)
Objects implementing org.freedesktop.ConsoleKit.Session also implements org.freedesktop.DBus.Introspectable, org.freedesktop.DBus.Properties
'unix-user' readwrite 'u' 'user' readwrite 'u' 'session-type' readwrite 's' 'remote-host-name' readwrite 's' 'display-device' readwrite 's' 'x11-display' readwrite 's' 'x11-display-device' readwrite 's' 'active' readwrite 'b' 'is-local' readwrite 'b' 'idle-hint' readwrite 'b'
Session objects represent and store information related to a user session.
The properties associated with the Session specifically refer to the properties of the "session leader".
GetSeatId (out 'o' sid)
Returns the ID for the Seat the Session is attached to.
sid
:See also: org.freedesktop.ConsoleKit.Seat
GetSessionType (out 's' type)
Returns the type of the session.
Warning: we haven't yet defined the allowed values for this property. It is probably best to avoid this until we do.
type
:
See also:
session-type
GetUser (out 'u' uid)
Returns the user that the session belongs to.
uid
:GetUser
is deprecated since version 0.1.3 and should not be used in newly-written code. Use
GetUnixUser
instead.
See also:
user
GetUnixUser (out 'u' uid)
Returns the POSIX user ID that the session belongs to.
uid
:
See also:
unix-user
GetX11Display (out 's' display)
Returns the value of the X11 DISPLAY for this session if one is present.
display
:
See also:
x11-display
GetX11DisplayDevice (out 's' x11_display_device)
Returns the value of the display device (aka TTY) that the X11 display for the session is connected to. If there is no x11-display set then this value is undefined.
x11_display_device
:
See also:
x11-display-device
GetDisplayDevice (out 's' display_device)
Returns the value of the display device (aka TTY) that the session is connected to.
display_device
:
See also:
display-device
GetRemoteHostName (out 's' remote_host_name)
Returns the value of the remote host name for the session.
remote_host_name
:
See also:
remote-host-name
GetLoginSessionId (out 's' login_session_id)
Returns the value of the login session ID that the underlying system uses to enforce session boundaries. If there is no login session ID set then this value is an empty string.
login_session_id
:IsActive (out 'b' active)
Returns whether the session is active on the Seat that it is attached to.
If the session is not attached to a seat this value is undefined.
active
:
See also:
active
IsLocal (out 'b' local)
Returns whether the session is local
FIXME: we need to come up with a concrete definition for this value. It was originally used as a way to identify XDMCP sessions that originate from a remote system.
local
:
See also:
is-local
GetCreationTime (out 's' iso8601_datetime)
Returns an ISO 8601 date-time string that corresponds to the time that the session was opened.
iso8601_datetime
:Activate ()
Attempt to activate the this session. In most cases, if successful, this will cause the session to become visible and become active on the seat that it is attached to.
See also:
Seat.ActivateSession()
Lock ()
This will cause a Lock
signal to be emitted for this session.
See also:
Lock signal
Unlock ()
This will cause an Unlock
signal to be emitted for this session.
This can be used by login managers to unlock a session before it is re-activated during fast-user-switching.
See also:
Unlock signal
GetIdleHint (out 'b' idle_hint)
Gets the value of the idle-hint
property.
idle_hint
:
See also:
idle-hint
ActiveChanged ('b' is_active)
Emitted when the active property has changed.
is_active
:IdleHintChanged ('b' hint)
Emitted when the idle-hint property has changed.
hint
:Lock ()
Emitted in response to a call to the Lock()
method.
It is intended that the screensaver for the session should lock the screen in response to this signal.
Unlock ()
Emitted in response to a call to the Unlock()
method.
It is intended that the screensaver for the session should unlock the screen in response to this signal.
'user' readwrite 'u'
The user assigned to the session.
user
is deprecated since version 0.1.3 and should not be used in newly-written code. Use
unix-user
instead.
'session-type' readwrite 's'
The type of the session.
Warning: we haven't yet defined the allowed values for this property. It is probably best to avoid this until we do.
'remote-host-name' readwrite 's'
The remote host name for the session.
This will be set in situations where the session is opened and controlled from a remote system.
For example, this value will be set when the session is created from an SSH or XDMCP connection.
'display-device' readwrite 's'
The display device (aka TTY) that the session is connected to.
'x11-display' readwrite 's'
Value of the X11 DISPLAY for this session if one is present.
'x11-display-device' readwrite 's'
The display device (aka TTY) that the X11 display for the session is connected to. If there is no x11-display set then this value is undefined.
'active' readwrite 'b'
Whether the session is active on the Seat that it is attached to.
If the session is not attached to a seat this value is undefined.
'is-local' readwrite 'b'
Whether the session is local
FIXME: we need to come up with a concrete definition for this value. It was originally used as a way to identify XDMCP sessions that originate from a remote system.
'idle-hint' readwrite 'b'
This is a hint used to indicate that the session may be idle.
For sessions with a x11-display
set (ie. graphical
sessions), it is up to each session to delegate the
responsibility for updating this value. Typically, the
screensaver will set this.
However, for non-graphical sessions with a display-device
set
the Session object itself will periodically update this value based
on the activity detected on the display-device itself.
This should not be considered authoritative.