[gnome-control-center] user-accounts: Do not suggest usernames that are too long



commit 0344f663dc8ebe53cf26a750308aee9e6e948ccd
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Fri May 13 19:54:55 2016 -0500

    user-accounts: Do not suggest usernames that are too long
    
    We assume that we only generate valid usernames, so make sure they're
    short enough to be used, else we'll display a dialog with a meaningless
    error message when useradd fails.
    
    Note that this commit doesn't completely fix the bug, as our definition
    of MAXNAMELEN is different from useradd's.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766401

 panels/user-accounts/um-utils.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/panels/user-accounts/um-utils.c b/panels/user-accounts/um-utils.c
index 72eada4..f0de95c 100644
--- a/panels/user-accounts/um-utils.c
+++ b/panels/user-accounts/um-utils.c
@@ -665,6 +665,15 @@ generate_username_choices (const gchar  *name,
         item3 = g_string_append (item3, first_word->str);
         item4 = g_string_prepend (item4, last_word->str);
 
+        g_string_truncate (first_word, MAXNAMELEN);
+        g_string_truncate (last_word, MAXNAMELEN);
+
+        g_string_truncate (item0, MAXNAMELEN);
+        g_string_truncate (item1, MAXNAMELEN);
+        g_string_truncate (item2, MAXNAMELEN);
+        g_string_truncate (item3, MAXNAMELEN);
+        g_string_truncate (item4, MAXNAMELEN);
+
         items = g_hash_table_new (g_str_hash, g_str_equal);
 
         in_use = is_username_used (item0->str);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]