lightdm: add systemd logind support (via Fedora).

This commit is contained in:
Juan RP 2013-01-04 11:45:37 +01:00
parent 5fd993f715
commit 1e716aaefb
6 changed files with 301 additions and 4 deletions

View file

@ -0,0 +1,15 @@
polkit.addRule(function(action, subject) {
if (subject.user == "lightdm") {
polkit.log("action=" + action);
polkit.log("subject=" + subject);
if (action.id.indexOf("org.freedesktop.login1.") == 0) {
return polkit.Result.YES;
}
if (action.id.indexOf("org.freedesktop.consolekit.system.") == 0) {
return polkit.Result.YES;
}
if (action.id.indexOf("org.freedesktop.upower.") == 0) {
return polkit.Result.YES;
}
}
});

View file

@ -1,10 +1,14 @@
[Unit]
Description=Light Display Manager
After=systemd-user-sessions.service
Conflicts=getty@tty1.service
After=systemd-user-sessions.service getty@tty1.service
[Service]
ExecStart=/usr/sbin/lightdm --log-dir=/var/log/lightdm --run-dir=/run/lightdm \
--cache-dir=/var/cache/lightdm
Restart=always
IgnoreSIGPIPE=no
BusName=org.freedesktop.DisplayManager
[Install]
Alias=display-manager.service

View file

@ -0,0 +1,191 @@
--- liblightdm-gobject/power.c.systemd_login1 2011-12-08 19:51:23.000000000 -0600
+++ liblightdm-gobject/power.c 2012-11-05 12:33:21.402801485 -0600
@@ -18,6 +18,7 @@
static GDBusProxy *upower_proxy = NULL;
static GDBusProxy *ck_proxy = NULL;
+static GDBusProxy *login1_proxy = NULL;
static gboolean
upower_call_function (const gchar *function, gboolean default_result, GError **error)
@@ -148,6 +149,59 @@ ck_call_function (const gchar *function,
return function_result;
}
+static gboolean
+login1_call_function (const gchar *function, GVariant *parameters, gboolean default_result, GError **error)
+{
+ GVariant *result;
+ gboolean function_result = FALSE;
+ const gchar *true_result = "yes";
+ gchar *str_result;
+
+ if (!login1_proxy)
+ {
+ login1_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.freedesktop.login1",
+ "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager",
+ NULL,
+ error);
+ if (!login1_proxy)
+ return FALSE;
+ }
+
+ result = g_dbus_proxy_call_sync (login1_proxy,
+ function,
+ parameters,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ error);
+
+ if (!result)
+ return default_result;
+
+ if (g_variant_is_of_type (result, G_VARIANT_TYPE ("(b)")))
+ g_variant_get (result, "(s)", &function_result);
+
+ /**
+ * CanReboot, CanPowerOff returns a string "yes", "no", or "challenge", not a boolean as ConsoleKit
+ **/
+ if (g_variant_is_of_type (result, G_VARIANT_TYPE ("(s)"))) {
+ g_variant_get (result, "(b)", str_result);
+ if(g_strcmp0(str_result,true_result) == 0) {
+ function_result = TRUE;
+ }
+ else {
+ function_result = default_result;
+ }
+ }
+
+ g_variant_unref (result);
+ return function_result;
+}
+
/**
* lightdm_get_can_restart:
*
@@ -158,7 +212,11 @@ ck_call_function (const gchar *function,
gboolean
lightdm_get_can_restart (void)
{
- return ck_call_function ("CanRestart", FALSE, NULL);
+ gboolean function_result = FALSE;
+ function_result = login1_call_function ("CanReboot", NULL, FALSE, NULL);
+ if (!function_result)
+ function_result = ck_call_function ("CanRestart", FALSE, NULL);
+ return function_result;
}
/**
@@ -172,7 +230,11 @@ lightdm_get_can_restart (void)
gboolean
lightdm_restart (GError **error)
{
- return ck_call_function ("Restart", TRUE, error);
+ gboolean function_result = FALSE;
+ function_result = login1_call_function ("Reboot", g_variant_new("(b)",0), TRUE, error);
+ if (!function_result)
+ function_result = ck_call_function ("Restart", TRUE, error);
+ return function_result;
}
/**
@@ -185,7 +247,11 @@ lightdm_restart (GError **error)
gboolean
lightdm_get_can_shutdown (void)
{
- return ck_call_function ("CanStop", FALSE, NULL);
+ gboolean function_result = FALSE;
+ function_result = login1_call_function ("CanPowerOff", NULL, FALSE, NULL);
+ if (!function_result)
+ function_result = ck_call_function ("CanStop", FALSE, NULL);
+ return function_result;
}
/**
@@ -199,5 +265,9 @@ lightdm_get_can_shutdown (void)
gboolean
lightdm_shutdown (GError **error)
{
- return ck_call_function ("Stop", TRUE, error);
+ gboolean function_result = FALSE;
+ function_result = login1_call_function ("PowerOff", g_variant_new("(b)",0), TRUE, error);
+ if (!function_result)
+ function_result = ck_call_function ("Stop", TRUE, error);
+ return function_result;
}
--- liblightdm-qt/power.cpp.systemd_login1 2011-12-08 19:51:23.000000000 -0600
+++ liblightdm-qt/power.cpp 2012-11-05 12:36:47.261292317 -0600
@@ -27,11 +27,13 @@ public:
PowerInterfacePrivate();
QScopedPointer<QDBusInterface> powerManagementInterface;
QScopedPointer<QDBusInterface> consoleKitInterface;
+ QScopedPointer<QDBusInterface> login1Interface;
};
PowerInterface::PowerInterfacePrivate::PowerInterfacePrivate() :
powerManagementInterface(new QDBusInterface("org.freedesktop.UPower","/org/freedesktop/UPower", "org.freedesktop.UPower", QDBusConnection::systemBus())),
- consoleKitInterface(new QDBusInterface("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus()))
+ consoleKitInterface(new QDBusInterface("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus())),
+ login1Interface(new QDBusInterface("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus()))
{
}
@@ -81,34 +83,45 @@ void PowerInterface::hibernate()
bool PowerInterface::canShutdown()
{
+ QDBusReply<QString> reply1 = d->login1Interface->call("CanPowerOff");
+ if ( reply1.isValid()) {
+ return (reply1.value()=="yes");
+ }
QDBusReply<bool> reply = d->consoleKitInterface->call("CanStop");
if (reply.isValid()) {
return reply.value();
}
- else {
- return false;
- }
+ return false;
}
void PowerInterface::shutdown()
{
- d->consoleKitInterface->call("Stop");
+ QDBusReply<bool> reply = d->login1Interface->call("PowerOff",0);
+ if (!reply.isValid())
+ d->consoleKitInterface->call("Stop");
}
bool PowerInterface::canRestart()
{
+
+ QDBusReply<QString> reply1 = d->login1Interface->call("CanReboot");
+ if (reply1.isValid()) {
+ return (reply1.value()=="yes");
+ }
+
QDBusReply<bool> reply = d->consoleKitInterface->call("CanRestart");
if (reply.isValid()) {
return reply.value();
}
- else {
- return false;
- }
+
+ return false;
}
void PowerInterface::restart()
{
- d->consoleKitInterface->call("Restart");
+ QDBusReply<bool> reply = d->login1Interface->call("Reboot",0);
+ if (!reply.isValid())
+ d->consoleKitInterface->call("Restart");
}
#include "power_moc.cpp"

View file

@ -0,0 +1,32 @@
--- data/lightdm.conf.orig 2012-10-05 09:43:48.307845764 +0200
+++ data/lightdm.conf 2012-10-05 09:44:57.956957476 +0200
@@ -19,9 +19,9 @@
#start-default-seat=true
#greeter-user=lightdm
#minimum-display-number=0
-#minimum-vt=7
+minimum-vt=1
#lock-memory=true
-#user-authority-in-system-dir=false
+user-authority-in-system-dir=true
#guest-account-script=guest-account
#log-directory=/var/log/lightdm
#run-directory=/var/run/lightdm
@@ -69,7 +69,7 @@
#xdmcp-manager=
#xdmcp-port=177
#xdmcp-key=
-#greeter-session=example-gtk-gnome
+greeter-session=lightdm-gtk-greeter
#greeter-hide-users=false
#greeter-allow-guest=true
#greeter-show-manual-login=false
@@ -77,7 +77,7 @@
#user-session=default
#allow-guest=true
#guest-session=UNIMPLEMENTED
-#session-wrapper=lightdm-session
+#session-wrapper=lightdm-session
#display-setup-script=
#greeter-setup-script=
#session-setup-script=

View file

@ -0,0 +1,55 @@
# HG changeset patch
# Parent b329fa1badaa454239690c3feb93d53324134915
try to lock the screen before switching users
diff --git a/utils/gdmflexiserver b/utils/gdmflexiserver
--- utils/gdmflexiserver
+++ utils/gdmflexiserver
@@ -9,9 +9,47 @@
#
# See http://www.gnu.org/copyleft/gpl.html for the full text of the license.
+PATH=/usr/local/bin:/bin:/usr/bin
+export PATH
+
if [ -z "$XDG_SEAT_PATH" ]; then
# something went wrong
exit 1
fi
+find_command () {
+ cmd="$1"
+ oIFS="${IFS}"; IFS=:
+ set -- ${PATH}
+ IFS="${oIFS}"
+
+ for part; do
+ [ -x "${part}/${cmd}" ] && return 0
+ done
+ return 1
+}
+
+lock_screen () {
+ for lock_cmd in \
+ "xscreensaver-command -lock" \
+ "gnome-screensaver-command --lock" \
+ "dbus-send --session --dest=org.freedesktop.ScreenSaver --type=method_call /ScreenSaver org.freedesktop.ScreenSaver.Lock"
+ do
+ ${lock_cmd} >/dev/null 2>&1 && return
+ done
+
+ for lock_cmd in \
+ "slock" \
+ "xlock -mode blank"
+ do
+ set -- ${lock_cmd}
+ if find_command "$1"; then
+ ${lock_cmd} >/dev/null 2>&1 &
+ return
+ fi
+ done
+}
+
+lock_screen
+
dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.DisplayManager $XDG_SEAT_PATH org.freedesktop.DisplayManager.Seat.SwitchToGreeter

View file

@ -1,7 +1,7 @@
# Template file for 'lightdm'
pkgname=lightdm
version=1.4.0
revision=1
revision=2
build_style=gnu-configure
configure_args="--with-greeter-session=lightdm-gtk-greeter
--with-greeter-user=lightdm --disable-static --disable-tests"
@ -31,8 +31,6 @@ conf_files="
/etc/pam.d/lightdm
/etc/pam.d/lightdm-autologin"
provides="display-manager-1"
replaces="display-manager>=0"
system_accounts="lightdm"
lightdm_homedir="/var/cache/lightdm"
systemd_services="lightdm.service off"
@ -47,6 +45,8 @@ post_install() {
vinstall ${FILESDIR}/lightdm-autologin.pam 644 etc/pam.d lightdm-autologin
vinstall ${FILESDIR}/xsession 755 etc/lightdm
vinstall ${FILESDIR}/lightdm.rules 644 usr/share/polkit-1/rules.d
# Minimum UID shall be 1000 for ordinary users.
sed -i -e "s|^\(minimum-uid=\).*|\11000|" \
${DESTDIR}/etc/lightdm/users.conf