Difference between revisions of "ConsoleKit"

From ArchWiki
Jump to: navigation, search
(Switching to systemd no longer optional (for support))
(Changed consolekit to consolekit-git, As consolekit has issues with some desktop environments)
 
(38 intermediate revisions by 9 users not shown)
Line 1: Line 1:
 
[[Category:Security]]
 
[[Category:Security]]
[[fr:Consolekit]]
 
 
[[it:ConsoleKit]]
 
[[it:ConsoleKit]]
[[tr:Consolekit]]
+
[[ja:ConsoleKit]]
{{Warning|From ConsoleKit's [http://www.freedesktop.org/wiki/Software/ConsoleKit web site]:<br>
+
{{Related articles start}}
''[http://www.freedesktop.org/wiki/ConsoleKit ConsoleKit] is not actively maintained. The focus has shifted to the built-in seat/user/session management of [http://www.freedesktop.org/wiki/Software/systemd systemd] called [http://0pointer.de/public/systemd-man/systemd-loginctl.html systemd-loginctl].''}}
+
{{Related|PolicyKit}}
 +
{{Related|init}}
 +
{{Related articles end}}
 +
{{Warning|Arch Linux only has official support for ''logind'' [https://www.archlinux.org/news/consolekit-replaced-by-logind/] and [[systemd]]. When using ''ConsoleKit'', please mention so in support requests.}}
 +
{{Note|While Consolekit is no longer maintained upstream, the fork ConsoleKit2 is under development. [https://github.com/ConsoleKit2/ConsoleKit2]}}
 +
'''ConsoleKit2''' is a framework for defining and tracking users, login sessions, and seats. Its function is to support multiuser setups. It also works for a single user, but offers no benefits compared to existing methods. [http://wiki.gentoo.org/wiki/ConsoleKit#Description]
  
See the 2012-10-30 news announcement: https://www.archlinux.org/news/consolekit-replaced-by-logind/
+
== Installation ==
  
If you are looking for a convenient way to mount disks as user, have a look at [[udev]], [[udiskie]] and [[PolicyKit]]. For Arch support, you need to switch to [[systemd]].
+
Install {{AUR|consolekit-git}} and {{AUR|polkit-consolekit}} from the [[AUR]].
  
== Arch Repositories ==
+
== Configuration ==
ConsoleKit is no longer packaged in the [[Official Repositories|official repositories]] [https://www.archlinux.org/news/consolekit-replaced-by-logind/]. It is '''strongly discouraged''' to continue to use or to start using ConsoleKit.
+
 
 +
=== ck-launch-session ===
 +
 
 +
To launch an X session with ConsoleKit, append the following to the {{ic|exec}} statement in {{ic|~/.xinitrc}} e.g.:
 +
 
 +
exec ck-launch-session dbus-launch --sh-syntax --exit-with-session openbox-session
 +
 
 +
This starts [[Openbox]] with proper environment variables so it and its children are able to use ConsoleKit.
 +
 
 +
[[Display manager]]s like [[KDM]], [[GDM]], [[LXDM]] and [[SLiM]] start ConsoleKit automatically with each X session.
 +
 
 +
{{Note|
 +
*Do not nest ConsoleKit sessions by calling one from another, or you will break ConsoleKit.
 +
*In particular, since [[SLiM]] reads {{ic|~/.xinitrc}}, you should make sure ''not'' to run {{ic|ck-launch-session}} there.
 +
}}
 +
 
 +
=== No display manager ===
 +
 
 +
If you are not using a display manager, but starting your window manager via the {{ic|startx}} command, or from [[inittab]].
 +
 
 +
If ConsoleKit is not working ({{ic|ck-list-sessions}} command showing active = FALSE), you should start your window manager using the bash_profile method: [[Start X at login#bash profile]].
 +
 
 +
=== Desktop environments ===
 +
 
 +
==== Xfce ====
 +
 
 +
For a login manager, {{AUR|lxdm-consolekit}} from the [[AUR]] or [[LightDM]] could be used.
 +
 
 +
==== Mate ====
 +
 
 +
[[Install]] {{AUR|mate-session-manager-upower}} and {{AUR|mate-power-manager-upower}}.
 +
 
 +
If you use {{AUR|mdm-display-manager}} as a login manager and have trouble logging in, edit {{ic|/etc/pam.d/mdm}}, comment out {{ic|session required pam_systemd.so}} and restart {{ic|mdm}}. Additionally append {{ic|session optional pam_ck_connector.so nox11}} if you have {{AUR|consolekit}} installed.
 +
 
 +
==== KDE ====
 +
 
 +
The kdebase-workspace package needs to be recompiled for use with consolekit ({{AUR|kdebase-workspace-consolekit}} is available from the AUR).
 +
 
 +
== Tips and tricks ==
 +
 
 +
=== Use D-Bus for power operations ===
 +
 
 +
{{Accuracy|Content must be revised for {{ic|ConsoleKit2}} and other developments}}
 +
 
 +
{{Note|Using ConsoleKit2's D-Bus methods for suspend, hibernate, and hybrid sleep requires {{Pkg|pm-utils}}.}}
 +
 
 +
Shut down:
 +
 
 +
{{bc|1=dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop}}
 +
 
 +
Restart:
 +
 
 +
{{bc|1=dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart}}
 +
 
 +
Suspend:
 +
 
 +
{{bc|1=dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Suspend  boolean:true}}
 +
 
 +
Hibernate (suspend to disk):
 +
 
 +
{{bc|1=dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Hibernate  boolean:true}}
 +
 
 +
Hybrid Sleep (suspend + hibernate):
 +
 
 +
{{bc|1=dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.HybridSleep  boolean:true}}
 +
 
 +
This method assumes that you are given permission to shut the system down via PolicyKit. The default group for this is {{ic|wheel}}. To change this, edit {{ic|/etc/polkit-1/localauthority.conf.d/50-localauthority.conf}} as root.
 +
 
 +
== Troubleshooting ==
 +
 
 +
=== Running several applications from ~/.xinitrc ===
 +
 
 +
If several applications are to be executed from {{ic|~/.xinitrc}}, not all of these will have ConsoleKit environment variables set. In the following example, only children of Compiz will be able to properly use ConsoleKit, but children of xterm will not.
 +
 
 +
{{hc|~/.xinitrc|
 +
xterm &
 +
exec ck-launch-session compiz ccp
 +
}}
 +
 
 +
Typically, this can be an issue when for example using Compiz standalone and some other application launchers, (gnome-do, kupfer, gmrun, xbindkeys, etc.) since children of the application launcher will not be able to use ConsoleKit. A dirty workaround is to have the entire session started by a second script, e.g. {{ic|~/.xstart}}. Do not forget dbus-launch, it is likely that you will need it too:
 +
 
 +
{{hc|~/.xinitrc|
 +
exec ck-launch-session dbus-launch ~/.xstart
 +
}}
 +
 
 +
{{hc|~/.xstart|
 +
xterm &
 +
thunar &
 +
compiz ccp
 +
}}
 +
 
 +
Do not forget to make {{ic|~/.xstart}} executable:
 +
 
 +
$ chmod +x ~/.xstart
 +
 
 +
To see whether everything is started correctly:
 +
 
 +
$ ck-list-sessions
 +
 
 +
It should show at least one session like this one:
 +
 
 +
Session18:
 +
        unix-user = '1000'
 +
        realname = 'Your Name'
 +
        seat = 'Seat1'
 +
        session-type = ''
 +
        active = TRUE
 +
        x11-display = ':0'
 +
        x11-display-device = '/dev/tty2'
 +
        display-device = '/dev/tty1'
 +
        remote-host-name = ''
 +
        is-local = TRUE
 +
        on-since = '2011-11-16T12:01:50.104764Z'
 +
        login-session-id = '7'
 +
 
 +
=== Consolekit blocks active TTY ===
 +
 
 +
Configure [[init]] to start ConsoleKit on an unused TTY, for example:
 +
 
 +
/usr/bin/openvt -c 63 -f -- /usr/sbin/console-kit-daemon --no-daemon &
 +
 
 +
See [https://bugs.freedesktop.org/show_bug.cgi?id=29920] for details.
 +
 
 +
=== Inactive session when launching X on same TTY ===
 +
 
 +
Specify the {{ic|keeptty}} flag to ''startx'' or ''xinit'' [http://www.linuxquestions.org/questions/slackware-14/starting-xorg-on-same-vt-as-login-vt-while-keeping-active-consolekit-session-4175533711/], for example:
 +
 
 +
startx -- -keeptty
 +
 
 +
See also [[Xorg#Broken redirection]].
  
 
== Replacing ConsoleKit with systemd-logind ==
 
== Replacing ConsoleKit with systemd-logind ==
  
{{Note|Starting with {{Pkg|polkit}} 0.107-4, [[ConsoleKit]] must be completely replaced by {{ic|systemd-logind}}[https://www.archlinux.org/news/consolekit-replaced-by-logind/], even when using a display manager. The system must be booted with systemd to be fully functional.}}
+
{{Note|''systemd-logind'' requires booting with [[systemd]] to be functional.}}
 +
 
 +
Remove references to {{ic|ck-launch-session}} from {{ic|~/.xinitrc}}.
  
An easy method to be able to remove [[ConsoleKit]] is to [[Automatic_login_to_virtual_console|automatically log in to a virtual console]] and [[Start_X_at_Boot|start X from there]]. It is important that, as mentioned in the latter article, the X server is started on the same virtual console that you log in to, otherwise logind can not keep track of the user session. You can then simply remove {{ic|ck-launch-session}} from your {{ic|~/.xinitrc}}.
+
See [[Session]] to check the status of your user session.
  
In order to check the status of your user session, you can use {{ic|loginctl}}. To see if your user session is properly set up, check if the following command contains {{ic|1=Active=yes}}. All [[PolicyKit]] actions like suspending the system or mounting external drives with [[Udisks]] should then work automatically.
+
== See also ==
  
$ loginctl show-session $XDG_SESSION_ID
+
* [https://bbs.archlinux.org/viewtopic.php?id=116853 ck-launch-session, Compiz, and mounting in Thunar/udisks]
 +
* [http://wiki.gentoo.org/wiki/ConsoleKit Gentoo wiki]

Latest revision as of 22:05, 19 August 2016

Related articles

Warning: Arch Linux only has official support for logind [1] and systemd. When using ConsoleKit, please mention so in support requests.
Note: While Consolekit is no longer maintained upstream, the fork ConsoleKit2 is under development. [2]

ConsoleKit2 is a framework for defining and tracking users, login sessions, and seats. Its function is to support multiuser setups. It also works for a single user, but offers no benefits compared to existing methods. [3]

Installation

Install consolekit-gitAUR and polkit-consolekitAUR from the AUR.

Configuration

ck-launch-session

To launch an X session with ConsoleKit, append the following to the exec statement in ~/.xinitrc e.g.:

exec ck-launch-session dbus-launch --sh-syntax --exit-with-session openbox-session

This starts Openbox with proper environment variables so it and its children are able to use ConsoleKit.

Display managers like KDM, GDM, LXDM and SLiM start ConsoleKit automatically with each X session.

Note:
  • Do not nest ConsoleKit sessions by calling one from another, or you will break ConsoleKit.
  • In particular, since SLiM reads ~/.xinitrc, you should make sure not to run ck-launch-session there.

No display manager

If you are not using a display manager, but starting your window manager via the startx command, or from inittab.

If ConsoleKit is not working (ck-list-sessions command showing active = FALSE), you should start your window manager using the bash_profile method: Start X at login#bash profile.

Desktop environments

Xfce

For a login manager, lxdm-consolekitAUR from the AUR or LightDM could be used.

Mate

Install mate-session-manager-upowerAUR and mate-power-manager-upowerAUR.

If you use mdm-display-managerAUR as a login manager and have trouble logging in, edit /etc/pam.d/mdm, comment out session required pam_systemd.so and restart mdm. Additionally append session optional pam_ck_connector.so nox11 if you have consolekitAUR installed.

KDE

The kdebase-workspace package needs to be recompiled for use with consolekit (kdebase-workspace-consolekitAUR is available from the AUR).

Tips and tricks

Use D-Bus for power operations

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: Content must be revised for ConsoleKit2 and other developments (Discuss in Talk:ConsoleKit#)
Note: Using ConsoleKit2's D-Bus methods for suspend, hibernate, and hybrid sleep requires pm-utils.

Shut down:

dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

Restart:

dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart

Suspend:

dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Suspend  boolean:true

Hibernate (suspend to disk):

dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Hibernate  boolean:true

Hybrid Sleep (suspend + hibernate):

dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.HybridSleep  boolean:true

This method assumes that you are given permission to shut the system down via PolicyKit. The default group for this is wheel. To change this, edit /etc/polkit-1/localauthority.conf.d/50-localauthority.conf as root.

Troubleshooting

Running several applications from ~/.xinitrc

If several applications are to be executed from ~/.xinitrc, not all of these will have ConsoleKit environment variables set. In the following example, only children of Compiz will be able to properly use ConsoleKit, but children of xterm will not.

~/.xinitrc
xterm &
exec ck-launch-session compiz ccp

Typically, this can be an issue when for example using Compiz standalone and some other application launchers, (gnome-do, kupfer, gmrun, xbindkeys, etc.) since children of the application launcher will not be able to use ConsoleKit. A dirty workaround is to have the entire session started by a second script, e.g. ~/.xstart. Do not forget dbus-launch, it is likely that you will need it too:

~/.xinitrc
exec ck-launch-session dbus-launch ~/.xstart
~/.xstart
xterm &
thunar &
compiz ccp

Do not forget to make ~/.xstart executable:

$ chmod +x ~/.xstart

To see whether everything is started correctly:

$ ck-list-sessions

It should show at least one session like this one:

Session18:
       unix-user = '1000'
       realname = 'Your Name'
       seat = 'Seat1'
       session-type = 
       active = TRUE
       x11-display = ':0'
       x11-display-device = '/dev/tty2'
       display-device = '/dev/tty1'
       remote-host-name = 
       is-local = TRUE
       on-since = '2011-11-16T12:01:50.104764Z'
       login-session-id = '7'

Consolekit blocks active TTY

Configure init to start ConsoleKit on an unused TTY, for example:

/usr/bin/openvt -c 63 -f -- /usr/sbin/console-kit-daemon --no-daemon &

See [4] for details.

Inactive session when launching X on same TTY

Specify the keeptty flag to startx or xinit [5], for example:

startx -- -keeptty

See also Xorg#Broken redirection.

Replacing ConsoleKit with systemd-logind

Note: systemd-logind requires booting with systemd to be functional.

Remove references to ck-launch-session from ~/.xinitrc.

See Session to check the status of your user session.

See also