]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Allow autologin as guest
authorRobert Ancell <robert.ancell@canonical.com>
Sat, 16 Jul 2011 08:58:53 +0000 (18:58 +1000)
committerRobert Ancell <robert.ancell@canonical.com>
Sat, 16 Jul 2011 08:58:53 +0000 (18:58 +1000)
NEWS
data/lightdm.conf
src/seat.c
src/seat.h
tests/Makefile.am
tests/scripts/autologin-guest.conf [new file with mode: 0644]
tests/scripts/autologin-guest.script [new file with mode: 0644]
tests/scripts/autologin.script
tests/test-autologin-guest [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index e30ff8a0e9c1d633e67a972bcf7c040d1a0e19ea..7da255e8034f51318feba12fba1d9aec7207c389 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,7 +6,7 @@ Overview of changes in lightdm 0.4.5
     * D-Bus API changes:
       - Rename ShowGreeter() to SwitchToGreeter()
     * Config changes:
-      - Move directories into their own section
+      - Support setting autologin user to guest account
 
 Overview of changes in lightdm 0.4.4
 
index a137cfec81720ad64ed662d6f5d1207b7a1750fa..69bdd1c8620c1f4e0aa0dc6e5b3b109223650ffe 100644 (file)
@@ -23,7 +23,8 @@ seats=Seat0
 # greeter-theme = Greeter theme to use
 # xsession = X session to load by default
 # xsession-wrapper = Wrapper script to run X session with
-# autologin-user = User to log in with by default
+# autologin-guest = True to log in as guest by default
+# autologin-user = User to log in with by default (overrides autologin-guest)
 # autologin-user-timeout = Number of seconds to wait before loading default user
 #
 #[Defaults]
@@ -33,6 +34,7 @@ seats=Seat0
 #greeter-theme=example-gtk-gnome
 #xsession=gnome
 #xsession-wrapper=
+#autologin-guest=false
 #autologin-user=
 #autologin-user-timeout=0
 
index 36d3d518ec8716ef71fb768cf8d52ca7274e0fc4..ee230e82ba3173268397ffce1f29be43a58b9831 100644 (file)
@@ -46,19 +46,19 @@ G_DEFINE_TYPE (Seat, seat, G_TYPE_OBJECT);
 void
 seat_load_config (Seat *seat, const gchar *config_section)
 {
-    gchar *username;
-    guint timeout;
-
-    username = config_get_string (config_get_instance (), config_section, "autologin-user");
-    if (!username)
-        username = config_get_string (config_get_instance (), "Defaults", "autologin-user");
+    if (config_has_key (config_get_instance (), config_section, "autologin-guest"))
+        seat->priv->autologin_guest = config_get_boolean (config_get_instance (), config_section, "autologin-guest");
+    else if (config_has_key (config_get_instance (), "Defaults", "autologin-guest"))
+        seat->priv->autologin_guest = config_get_boolean (config_get_instance (), "Defaults", "autologin-guest");
+    seat->priv->autologin_username = config_get_string (config_get_instance (), config_section, "autologin-user");
+    if (!seat->priv->autologin_username)
+        seat->priv->autologin_username = config_get_string (config_get_instance (), "Defaults", "autologin-user");
     if (config_has_key (config_get_instance (), config_section, "autologin-user-timeout"))
-        timeout = config_get_integer (config_get_instance (), config_section, "autologin-user-timeout");
+        seat->priv->autologin_timeout = config_get_integer (config_get_instance (), config_section, "autologin-user-timeout");
     else
-        timeout = config_get_integer (config_get_instance (), "Defaults", "autologin-user-timeout");
-    if (timeout < 0)
-        timeout = 0;
-    seat_set_autologin_user (SEAT (seat), username, timeout);
+        seat->priv->autologin_timeout = config_get_integer (config_get_instance (), "Defaults", "autologin-user-timeout");
+    if (seat->priv->autologin_timeout < 0)
+        seat->priv->autologin_timeout = 0;
 }
 
 void
@@ -69,28 +69,6 @@ seat_set_can_switch (Seat *seat, gboolean can_switch)
     seat->priv->can_switch = can_switch;
 }
 
-void
-seat_set_autologin_user (Seat *seat, const gchar *username, guint timeout)
-{
-    g_return_if_fail (seat != NULL);
-  
-    g_free (seat->priv->autologin_username);
-    seat->priv->autologin_username = g_strdup (username);
-    seat->priv->autologin_timeout = timeout;
-    seat->priv->autologin_guest = FALSE;
-}
-
-void
-seat_set_autologin_guest (Seat *seat, guint timeout)
-{
-    g_return_if_fail (seat != NULL);
-
-    g_free (seat->priv->autologin_username);
-    seat->priv->autologin_username = NULL;
-    seat->priv->autologin_timeout = timeout;
-    seat->priv->autologin_guest = TRUE;
-}
-
 gboolean
 seat_start (Seat *seat)
 {
index 025d0ccf6333ea26147059fb1b8cfc694e95b297..80388838a85d2045cd31ef3692bf30a2b68b2976 100644 (file)
@@ -49,10 +49,6 @@ void seat_load_config (Seat *seat, const gchar *config_section);
 
 void seat_set_can_switch (Seat *seat, gboolean can_switch);
 
-void seat_set_autologin_user (Seat *seat, const gchar *username, guint timeout);
-
-void seat_set_autologin_guest (Seat *seat, guint timeout);
-
 gboolean seat_start (Seat *seat);
 
 GList *seat_get_displays (Seat *seat);
index c9a793b22ab9d987f30d2e9de904edc7c3949b71..60a28bcc83d928f2ee589159ebb1683b610fa7aa 100644 (file)
@@ -4,6 +4,7 @@ TESTS = \
        test-no-config \
        test-headless \
        test-autologin \
+       test-autologin-guest \
        test-autologin-logout \
        test-login-gobject \
        test-login-gobject-manual \
@@ -37,6 +38,8 @@ EXTRA_DIST = \
        data/xsessions/test-session.desktop \
        scripts/autologin.conf \
        scripts/autologin.script \
+       scripts/autologin-guest.conf \
+       scripts/autologin-guest.script \
        scripts/autologin-logout.conf \
        scripts/autologin-logout.script \
        scripts/headless.conf \
diff --git a/tests/scripts/autologin-guest.conf b/tests/scripts/autologin-guest.conf
new file mode 100644 (file)
index 0000000..c2b35d9
--- /dev/null
@@ -0,0 +1,10 @@
+[LightDM]
+seats=test-seat
+
+[Defaults]
+autologin-guest=true
+
+[GuestAccount]
+enabled=true
+setup-script=test-setup-guest
+cleanup-script=test-cleanup-guest
diff --git a/tests/scripts/autologin-guest.script b/tests/scripts/autologin-guest.script
new file mode 100644 (file)
index 0000000..9085438
--- /dev/null
@@ -0,0 +1,22 @@
+#
+# Check automatically logs in default user
+#
+
+RUNNER DAEMON-START
+
+# X server starts
+XSERVER :50 START
+XSERVER :50 INDICATE-READY
+XSERVER :50 ACCEPT-CONNECT
+
+# Default session starts
+SESSION START USER=guest
+XSERVER :50 ACCEPT-CONNECT
+SESSION CONNECT-XSERVER
+
+# Cleanup
+*STOP-DAEMON
+# Don't know what order they will terminate
+(SESSION TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15)
+(SESSION TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15)
+RUNNER DAEMON-EXIT STATUS=0
index 8a024e6ed7f6a2f8c8a1d0102e9128ec280536f6..28488ece28e296166a5aead0544166fea0daae9f 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Check automaitcally logs in default user
+# Check automatically logs in default user
 #
 
 RUNNER DAEMON-START
diff --git a/tests/test-autologin-guest b/tests/test-autologin-guest
new file mode 100755 (executable)
index 0000000..14feab6
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/test-runner autologin-guest