]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Fix authentication cancel regression caused in 1.5.2
authorRobert Ancell <robert.ancell@canonical.com>
Wed, 3 Apr 2013 02:48:15 +0000 (15:48 +1300)
committerRobert Ancell <robert.ancell@canonical.com>
Wed, 3 Apr 2013 02:48:15 +0000 (15:48 +1300)
NEWS
src/greeter.c
tests/Makefile.am
tests/scripts/cancel-authentication.conf [new file with mode: 0644]
tests/src/test-gobject-greeter.c
tests/src/test-python-greeter
tests/src/test-qt-greeter.cpp
tests/test-gobject-cancel-authentication [new file with mode: 0755]
tests/test-python-cancel-authentication [new file with mode: 0755]
tests/test-qt4-cancel-authentication [new file with mode: 0755]
tests/test-qt5-cancel-authentication [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index c8cf7c44cd670bf735854c4a9132a171d0fd9133..a5159302659011a0a2b7337720f5f0f1ede092a9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 Overview of changes in lightdm 1.5.3
 
     * Fix build with gobject-introspection 1.35.9
+    * Fix authentication cancel regression caused in 1.5.2
 
 Overview of changes in lightdm 1.5.2
 
index 97688b74a4e881626cf6b75ea796dbfd6be5ce1b..9601c0935db7aa4c1b2d8491af5d3f1148114c45 100644 (file)
@@ -635,7 +635,7 @@ get_message_length (Greeter *greeter)
     if (HEADER_SIZE + payload_length < HEADER_SIZE)
     {
         g_warning ("Payload length of %u octets too long", payload_length);
-        return 0;      
+        return HEADER_SIZE;
     }
 
     return HEADER_SIZE + payload_length;
@@ -699,7 +699,7 @@ read_cb (GIOChannel *source, GIOCondition condition, gpointer data)
     if (greeter->priv->n_read >= HEADER_SIZE)
     {
         n_to_read = get_message_length (greeter);
-        if (n_to_read == 0)
+        if (n_to_read <= HEADER_SIZE)
             return FALSE;
     }
 
@@ -722,12 +722,12 @@ read_cb (GIOChannel *source, GIOCondition condition, gpointer data)
     if (greeter->priv->n_read == HEADER_SIZE)
     {
         n_to_read = get_message_length (greeter);
-        if (n_to_read == 0)
-            return FALSE;
-
-        greeter->priv->read_buffer = secure_realloc (greeter, greeter->priv->read_buffer, n_to_read);
-        read_cb (source, condition, greeter);
-        return TRUE;
+        if (n_to_read > HEADER_SIZE)
+        {
+            greeter->priv->read_buffer = secure_realloc (greeter, greeter->priv->read_buffer, n_to_read);
+            read_cb (source, condition, greeter);
+            return TRUE;
+        }      
     }
   
     offset = 0;
index 8a459dec442d3e5206a0d9f5444aae7b03c0bf1f..562e1115d97040b8b42d2719a948ae7ad890ec10 100644 (file)
@@ -21,6 +21,8 @@ TESTS = \
        test-autologin-python-guest-timeout \
        test-change-authentication \
        test-restart-authentication \
+       test-gobject-cancel-authentication \
+       test-python-cancel-authentication \
        test-pam \
        test-login-pam \
        test-denied \
@@ -143,6 +145,7 @@ if COMPILE_LIBLIGHTDM_QT4
 TESTS += \
        test-autologin-qt4-timeout \
        test-autologin-qt4-guest-timeout \
+       test-qt4-cancel-authentication \
        test-login-qt4 \
        test-login-qt4-manual \
        test-login-qt4-manual-previous-session \
@@ -171,6 +174,7 @@ if COMPILE_LIBLIGHTDM_QT5
 TESTS += \
        test-autologin-qt5-timeout \
        test-autologin-qt5-guest-timeout \
+       test-qt5-cancel-authentication \
        test-login-qt5 \
        test-login-qt5-manual \
        test-login-qt5-manual-previous-session \
@@ -222,6 +226,7 @@ EXTRA_DIST = \
        scripts/autologin-timeout.conf \
        scripts/autologin-xserver-crash.conf \
        scripts/change-authentication.conf \
+       scripts/cancel-authentication.conf \
        scripts/console-kit.conf \
        scripts/crash-authenticate.conf \
        scripts/cred-error.conf \
diff --git a/tests/scripts/cancel-authentication.conf b/tests/scripts/cancel-authentication.conf
new file mode 100644 (file)
index 0000000..ccd5eb4
--- /dev/null
@@ -0,0 +1,40 @@
+#
+# Check can cancel authentication
+#
+
+[LightDM]
+minimum-display-number=50
+
+#?RUNNER DAEMON-START
+
+# X server starts
+#?XSERVER :50 START
+#?XSERVER :50 INDICATE-READY
+
+# LightDM connects to X server
+#?XSERVER :50 ACCEPT-CONNECT
+
+# Greeter starts
+#?GREETER :50 START
+#?XSERVER :50 ACCEPT-CONNECT
+#?GREETER :50 CONNECT-XSERVER
+#?GREETER :50 CONNECT-TO-DAEMON
+#?GREETER :50 CONNECTED-TO-DAEMON
+
+# Start authentication
+#?*GREETER :50 AUTHENTICATE USERNAME=have-password1
+#?GREETER :50 SHOW-PROMPT TEXT="Password:"
+
+# Cancel authentication
+#?*GREETER :50 CANCEL-AUTHENTICATION
+
+# Start new authentication
+#?*GREETER :50 AUTHENTICATE USERNAME=have-password2
+#?GREETER :50 SHOW-PROMPT TEXT="Password:"
+
+# Cleanup
+#?*STOP-DAEMON
+# Don't know what order they will terminate
+#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15)
+#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15)
+#?RUNNER DAEMON-EXIT STATUS=0
index 6597b92ef50b9a774306c0b91bfe0a26a95b9dd9..b80b705a85901917ee70e70b9a0486a65151a45d 100644 (file)
@@ -98,6 +98,11 @@ request_cb (const gchar *request)
     }
     g_free (r);
 
+    r = g_strdup_printf ("GREETER %s CANCEL-AUTHENTICATION", getenv ("DISPLAY"));
+    if (strcmp (request, r) == 0)
+        lightdm_greeter_cancel_authentication (greeter);
+    g_free (r);
+
     r = g_strdup_printf ("GREETER %s START-SESSION", getenv ("DISPLAY"));
     if (strcmp (request, r) == 0)
     {
index 44c3e482f7bc88fc190fe2e409b2ed6897ac82c1..91050f180d3dfe1d3dd2ed75ef526c80dd3a177c 100755 (executable)
@@ -57,6 +57,10 @@ def request_cb (channel, condition):
     if request.startswith (r):
         greeter.respond (request[len (r):-1])
 
+    r = 'GREETER %s CANCEL-AUTHENTICATION' % os.getenv ('DISPLAY')
+    if request == r:
+        greeter.cancel_authentication ()
+
     r = 'GREETER %s START-SESSION' % os.getenv ('DISPLAY')
     if request == r:
         if not greeter.start_session_sync (None):
index 68ab1674ea51b1307f9602a9a0b63bd1ade8d71f..65926250b7c1d1abed56f5a537e28ecd515f9e11 100644 (file)
@@ -102,6 +102,11 @@ request_cb (const gchar *request)
     }
     g_free (r);
 
+    r = g_strdup_printf ("GREETER %s CANCEL-AUTHENTICATION", getenv ("DISPLAY"));
+    if (strcmp (request, r) == 0)
+        greeter->cancelAuthentication ();
+    g_free (r);
+
     r = g_strdup_printf ("GREETER %s START-SESSION", getenv ("DISPLAY"));
     if (strcmp (request, r) == 0)
     {
diff --git a/tests/test-gobject-cancel-authentication b/tests/test-gobject-cancel-authentication
new file mode 100755 (executable)
index 0000000..2a8cfb9
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner cancel-authentication test-gobject-greeter
diff --git a/tests/test-python-cancel-authentication b/tests/test-python-cancel-authentication
new file mode 100755 (executable)
index 0000000..458757b
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner cancel-authentication test-python-greeter
diff --git a/tests/test-qt4-cancel-authentication b/tests/test-qt4-cancel-authentication
new file mode 100755 (executable)
index 0000000..298c0af
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner cancel-authentication test-qt4-greeter
diff --git a/tests/test-qt5-cancel-authentication b/tests/test-qt5-cancel-authentication
new file mode 100755 (executable)
index 0000000..eb7436f
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner cancel-authentication test-qt5-greeter