Merge lp:~uoms-gregt/lightdm-gtk-greeter/trim-username into lp:lightdm-gtk-greeter

Proposed by Greg Trounson
Status: Needs review
Proposed branch: lp:~uoms-gregt/lightdm-gtk-greeter/trim-username
Merge into: lp:lightdm-gtk-greeter
Diff against target: 55 lines (+10/-5)
1 file modified
src/lightdm-gtk-greeter.c (+10/-5)
To merge this branch: bzr merge lp:~uoms-gregt/lightdm-gtk-greeter/trim-username
Reviewer Review Type Date Requested Status
LightDM Gtk+ Greeter Development Team Pending
Review via email: mp+362953@code.launchpad.net

Commit message

Ignore whitespace before and after username when authenticating.

Description of the change

Our use case:
Users press the space bar to either power up the computer or bring the monitor out
of sleep. If the computer is already powered on then that keypress propagates to the username
field in lightdm-gtk-greeter, inserting a <space> before they type their username, resulting in a failed login. With proportional fonts this is almost impossible to see at a glance.

Given that whitespace can never be part of a valid username (cf IEEE 1003.1-2001), this patch trims the beginning and end of the username string before passing it to the authentication code. <Space> characters still appear in the username field, but have no effect.

To test:
At a lightdm login prompt, type:
<space>username
or:
username<space>
then enter your password.

Pre-patch:
The login will fail.
Post-patch:
The login will succeed.

To post a comment you must log in.

Unmerged revisions

477. By Greg Trounson <email address hidden>

Ignore whitespace before and after username when authenticating

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/lightdm-gtk-greeter.c'
--- src/lightdm-gtk-greeter.c 2018-03-15 00:29:41 +0000
+++ src/lightdm-gtk-greeter.c 2019-02-10 20:58:40 +0000
@@ -1999,13 +1999,17 @@
1999 password_prompted = FALSE;1999 password_prompted = FALSE;
2000 prompt_active = FALSE;2000 prompt_active = FALSE;
20012001
2002 gchar* trimmed_username;
2003 trimmed_username = g_strdup (username);
2004 g_strstrip (trimmed_username);
2005
2002 if (pending_questions)2006 if (pending_questions)
2003 {2007 {
2004 g_slist_free_full (pending_questions, (GDestroyNotify) pam_message_finalize);2008 g_slist_free_full (pending_questions, (GDestroyNotify) pam_message_finalize);
2005 pending_questions = NULL;2009 pending_questions = NULL;
2006 }2010 }
20072011
2008 config_set_string (STATE_SECTION_GREETER, STATE_KEY_LAST_USER, username);2012 config_set_string (STATE_SECTION_GREETER, STATE_KEY_LAST_USER, trimmed_username);
20092013
2010 if (g_strcmp0 (username, "*other") == 0)2014 if (g_strcmp0 (username, "*other") == 0)
2011 {2015 {
@@ -2031,7 +2035,7 @@
2031 }2035 }
2032 }2036 }
2033 }2037 }
2034 else if (g_strcmp0 (username, "*guest") == 0)2038 else if (g_strcmp0 (trimmed_username, "*guest") == 0)
2035 {2039 {
2036#ifdef HAVE_LIBLIGHTDMGOBJECT_1_19_22040#ifdef HAVE_LIBLIGHTDMGOBJECT_1_19_2
2037 lightdm_greeter_authenticate_as_guest (greeter, NULL);2041 lightdm_greeter_authenticate_as_guest (greeter, NULL);
@@ -2043,7 +2047,7 @@
2043 {2047 {
2044 LightDMUser *user;2048 LightDMUser *user;
20452049
2046 user = lightdm_user_list_get_user_by_name (lightdm_user_list_get_instance (), username);2050 user = lightdm_user_list_get_user_by_name (lightdm_user_list_get_instance (), trimmed_username);
2047 if (user)2051 if (user)
2048 {2052 {
2049 if (!current_session)2053 if (!current_session)
@@ -2057,11 +2061,12 @@
2057 set_language (NULL);2061 set_language (NULL);
2058 }2062 }
2059#ifdef HAVE_LIBLIGHTDMGOBJECT_1_19_22063#ifdef HAVE_LIBLIGHTDMGOBJECT_1_19_2
2060 lightdm_greeter_authenticate (greeter, username, NULL);2064 lightdm_greeter_authenticate (greeter, trimmed_username, NULL);
2061#else2065#else
2062 lightdm_greeter_authenticate (greeter, username);2066 lightdm_greeter_authenticate (greeter, trimmed_username);
2063#endif2067#endif
2064 }2068 }
2069 g_free (trimmed_username);
2065}2070}
20662071
2067static void2072static void

Subscribers

People subscribed via source and target branches

to all changes: